test(ui): scope the role-gate assertions to each page's own endpoint

The memory, workflows, and guardrails-monitor page tests asserted that a denied
role fires no request at all. Their names, and the assertion on the very next
line, say the intent is narrower: the page must not fetch its own data.

Resolving whether a caller is an org admin goes through /organization/list for
every role, since deciding org-admin-for-any-org needs the list, and the route
scopes rows per caller. That legitimate request fails a blanket no-fetch
assertion, so all three files went red on staging for a reason unrelated to
what they test.

Drops the blanket assertion and keeps the scoped one. Bypassing the gate in
memory/page.tsx still fails five tests, so the narrower assertion continues to
catch a genuinely broken gate.
This commit is contained in:
Tin 2026-08-11 21:38:14 -07:00
parent 06943b6468
commit 884d93ce15
3 changed files with 9 additions and 3 deletions

View file

@ -46,7 +46,9 @@ describe("Guardrails Monitor page access by role", () => {
renderAs(userRole);
expect(await screen.findByText("Guardrails Monitor is only available to admin users.")).toBeInTheDocument();
await waitFor(() => expect(fetchMock).not.toHaveBeenCalled());
// Scoped to this page's own endpoint, not every request. Resolving whether a caller is an org
// admin goes through /organization/list for every role, so a blanket "no fetch at all" would
// fail on a request that has nothing to do with this page's gate.
expect(requestedUrls().filter((url) => url.includes("/guardrails/usage"))).toEqual([]);
},
);

View file

@ -46,7 +46,9 @@ describe("Memory page access by role", () => {
renderAs(userRole);
expect(await screen.findByText("Memory is only available to admin users.")).toBeInTheDocument();
await waitFor(() => expect(fetchMock).not.toHaveBeenCalled());
// Scoped to this page's own endpoint, not every request. Resolving whether a caller is an org
// admin goes through /organization/list for every role, so a blanket "no fetch at all" would
// fail on a request that has nothing to do with this page's gate.
expect(requestedUrls().filter((url) => url.includes("/v1/memory"))).toEqual([]);
},
);

View file

@ -46,7 +46,9 @@ describe("Workflows page access by role", () => {
renderAs(userRole);
expect(await screen.findByText("Workflow Runs is only available to admin users.")).toBeInTheDocument();
await waitFor(() => expect(fetchMock).not.toHaveBeenCalled());
// Scoped to this page's own endpoint, not every request. Resolving whether a caller is an org
// admin goes through /organization/list for every role, so a blanket "no fetch at all" would
// fail on a request that has nothing to do with this page's gate.
expect(requestedUrls().filter((url) => url.includes("/v1/workflows"))).toEqual([]);
},
);