test(ui): mock useIsOrgAdmin in cost-optimization view tests

Upstream 255d65192e gated the view's tabs behind useCan, which chains
useAuthorized -> useIsOrgAdmin -> useOrganizations -> useQuery, so the
two view test files now die with 'No QueryClient set' before asserting
anything. Mock useIsOrgAdmin (and useAuthorized in the activity test)
at the boundary the component actually reads; the tests assert tab
behavior, not org-admin resolution. These fail on staging's own full
suite runs too — this fixes the slice that our PR's related-tests job
runs.

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Abhimanyu Kapur 2026-08-10 20:33:35 -07:00
parent 876bbecf3f
commit 77b5e45544
2 changed files with 8 additions and 0 deletions

View file

@ -28,6 +28,12 @@ vi.mock("@/app/(dashboard)/router-settings/_components/general_settings", () =>
vi.mock("./PromptCompressionTab", () => ({ __esModule: true, default: () => <div /> }));
vi.mock("@/app/(dashboard)/hooks/useAuthorized", () => ({
default: () => ({ accessToken: "test-token", userId: "u1", userRole: "proxy_admin" }),
}));
vi.mock("@/app/(dashboard)/hooks/useIsOrgAdmin", () => ({ default: () => false }));
import CostOptimizationView from "./CostOptimizationView";
const singlePage = {

View file

@ -7,6 +7,8 @@ vi.mock("@/app/(dashboard)/hooks/useAuthorized", () => ({
default: useAuthorizedMock,
}));
vi.mock("@/app/(dashboard)/hooks/useIsOrgAdmin", () => ({ default: () => false }));
vi.mock("./UsageTab", () => ({ __esModule: true, default: () => <div data-testid="usage-tab" /> }));
vi.mock("./PromptCompressionTab", () => ({ __esModule: true, default: () => <div data-testid="compression-tab" /> }));
vi.mock("./PromptCachingTab", () => ({ __esModule: true, default: () => <div data-testid="caching-tab" /> }));