/**
 * Route-level smoke over the backoffice shell: each key module page loads
 * without bouncing back to /auth and without an unhandled crash. Deep
 * per-module behavior belongs in dedicated specs — this catches the broad
 * "page is broken / route is dead / guard rejects seeded role" class.
 * Routes from apps/edr-freight-web/backoffice/src/App.tsx.
 */
const ROUTES = [
  "/dashboard/overview",
  "/dashboard/booking-requests",
  "/dashboard/customers",
  "/dashboard/invoices",
  "/dashboard/contract-requests",
  "/dashboard/shipment-requests",
  "/dashboard/profile",
];

describe("backoffice: route smoke (ceo)", () => {
  beforeEach(() => {
    cy.loginBackoffice("ceo@edr.local");
  });

  ROUTES.forEach((route) => {
    it(`renders ${route}`, () => {
      cy.visit(route);
      cy.location("pathname").should("not.eq", "/auth");
      cy.location("pathname").should("contain", "/dashboard");
      cy.get("#root").should("not.be.empty");
    });
  });
});

describe("backoffice: role-based access", () => {
  it("line staff can reach the dashboard shell", () => {
    cy.loginBackoffice("linestaff@edr.local");
    cy.visit("/dashboard/overview");
    cy.location("pathname").should("not.eq", "/auth");
    cy.get("#root").should("not.be.empty");
  });

  it("operations officer can reach the dashboard shell", () => {
    cy.loginBackoffice("operation@edr.local");
    cy.visit("/dashboard/overview");
    cy.location("pathname").should("not.eq", "/auth");
    cy.get("#root").should("not.be.empty");
  });
});

export {};
