diff --git a/tests/e2e/cases-read-only.spec.ts b/tests/e2e/cases-read-only.spec.ts index 22183302f14..b40226ea49e 100644 --- a/tests/e2e/cases-read-only.spec.ts +++ b/tests/e2e/cases-read-only.spec.ts @@ -76,9 +76,17 @@ test("browses passive cases and rolled-up task documents without starting work o await page.setViewportSize({ width: 1440, height: 1000 }); // The agentless dashboard offers onboarding. Start on the ordinary task // list so this zero-agent fixture can use Cases navigation without setup. + let releaseCompanies!: () => void; + const companiesHeld = new Promise(resolve => { releaseCompanies = resolve; }); + await page.route(url => url.pathname === "/api/companies", async route => { + await companiesHeld; + await route.continue(); + }); await page.goto(`/${company.issuePrefix}/issues`); await page.getByRole("button", { name: "More workspace pages", exact: true }).click(); await page.getByRole("link", { name: /^Cases\b/ }).first().click(); + await expect(page).toHaveURL(new RegExp(`/${company.issuePrefix}/cases$`)); + releaseCompanies(); const casePage = page.getByTestId("case-pages"); const list = page.getByRole("region", { name: "Case list", exact: true }); const choose = async (filter: string, option: string) => { diff --git a/ui/src/lib/company-routes.test.ts b/ui/src/lib/company-routes.test.ts index 0b2631debe6..713b55ff4d7 100644 --- a/ui/src/lib/company-routes.test.ts +++ b/ui/src/lib/company-routes.test.ts @@ -139,6 +139,14 @@ describe("company routes", () => { expect(toCompanyRelativePath("/PAP/timeline")).toBe("/timeline"); }); + it.each(["cases", "status"])("keeps the active company on /%s navigation links", (root) => { + expect(isBoardPathWithoutPrefix(`/${root}`)).toBe(true); + expect(extractCompanyPrefixFromPath(`/${root}`)).toBeNull(); + expect(applyCompanyPrefix(`/${root}`, "PAP")).toBe(`/PAP/${root}`); + expect(applyCompanyPrefix(`/PAP/${root}`, "REA")).toBe(`/PAP/${root}`); + expect(toCompanyRelativePath(`/PAP/${root}`)).toBe(`/${root}`); + }); + it("treats Skill Studio create mode as an unprefixed board route", () => { expect(isBoardPathWithoutPrefix("/skills/studio/new")).toBe(true); expect(extractCompanyPrefixFromPath("/skills/studio/new")).toBeNull(); diff --git a/ui/src/lib/company-routes.ts b/ui/src/lib/company-routes.ts index 34012edc128..5b0b2c6c818 100644 --- a/ui/src/lib/company-routes.ts +++ b/ui/src/lib/company-routes.ts @@ -31,6 +31,8 @@ const BOARD_ROUTE_ROOTS = new Set([ "search", "settings", "timeline", + "cases", + "status", ]); const GLOBAL_ROUTE_ROOTS = new Set(["auth", "invite", "board-claim", "cli-auth", "mcp-connect", "dot-connect", "assistant-connections", "docs", "instance"]); @@ -93,11 +95,6 @@ export function applyCompanyPrefix(path: string, companyPrefix: string | null | * Build a company-prefixed href for an experimental Cases route, e.g. * `caseHref("PAP", "PAP-C5")` → `/PAP/cases/PAP-C5`. * - * Case paths carry identifiers like `PAP-C5` in the first segment, which the - * generic {@link applyCompanyPrefix} mistakes for a company prefix ("CASES") and - * therefore leaves `/cases/...` unprefixed — every case link then only resolves - * via the PAP-13002 unprefixed→prefixed redirect. This builder emits the - * prefixed href directly so case-to-case navigation matches the rest of the app. * Falls back to the unprefixed path (still valid via the redirect) when no * company is active. */