test(ui): stub the org-list query in the admin-only page gate tests

These three files assert that a denied role renders the admin-only notice
and issues no request. They were written when useCan read only the session
role, so a denied render genuinely touched the network zero times.

useCan then grew a useIsOrgAdmin leg, which reads useOrganizations, so every
capability check now issues GET /organization/list regardless of the role or
the capability. Both changes landed the same afternoon and were green on
their own bases, so the break only appeared once they were merged.

Stubbing useOrganizations keeps the zero-request assertion exact instead of
loosening it to ignore whatever else the page happens to fetch. It also
leaves isOrgAdminSessionRole running for real, so the Org Admin case still
proves that a genuine org admin is refused rather than an ordinary user.
This commit is contained in:
Yuneng Jiang 2026-08-11 21:50:06 -07:00
parent 06943b6468
commit 0fcd0f99f9
No known key found for this signature in database
3 changed files with 12 additions and 0 deletions

View file

@ -9,6 +9,10 @@ vi.mock("@/app/(dashboard)/hooks/useAuthorized", () => ({
default: useAuthorizedMock,
}));
vi.mock("@/app/(dashboard)/hooks/organizations/useOrganizations", () => ({
useOrganizations: () => ({ data: undefined }),
}));
const fetchMock = vi.fn();
const requestedUrls = () => fetchMock.mock.calls.map(([url]) => String(url));

View file

@ -9,6 +9,10 @@ vi.mock("@/app/(dashboard)/hooks/useAuthorized", () => ({
default: useAuthorizedMock,
}));
vi.mock("@/app/(dashboard)/hooks/organizations/useOrganizations", () => ({
useOrganizations: () => ({ data: undefined }),
}));
const fetchMock = vi.fn();
const requestedUrls = () => fetchMock.mock.calls.map(([url]) => String(url));

View file

@ -9,6 +9,10 @@ vi.mock("@/app/(dashboard)/hooks/useAuthorized", () => ({
default: useAuthorizedMock,
}));
vi.mock("@/app/(dashboard)/hooks/organizations/useOrganizations", () => ({
useOrganizations: () => ({ data: undefined }),
}));
const fetchMock = vi.fn();
const requestedUrls = () => fetchMock.mock.calls.map(([url]) => String(url));