fix(canvas): mock WorkspaceUsage in BudgetLimit.DetailsTab test

DetailsTab renders WorkspaceUsage alongside BudgetSection. The test suite
sets api.get to return [] (a valid empty peers list) but WorkspaceUsage
calls api.get for metrics and crashes on undefined input_tokens when the
mock returns an array instead of a WorkspaceMetrics object.

Add a stub vi.mock following the same pattern already used for BudgetSection.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Molecule AI Frontend Engineer 2026-04-17 06:22:07 +00:00
parent ea26e89064
commit 0adf5d5a5f

View File

@ -44,6 +44,15 @@ vi.mock("../tabs/BudgetSection", () => ({
),
}));
// Mock WorkspaceUsage — it has its own test suite (WorkspaceUsage.test.tsx).
// Without this mock its internal api.get call races against the shared mock
// and crashes when the return value is not a valid WorkspaceMetrics object.
vi.mock("../WorkspaceUsage", () => ({
WorkspaceUsage: ({ workspaceId }: { workspaceId: string }) => (
<div data-testid="workspace-usage-stub" data-ws={workspaceId} />
),
}));
import { api } from "@/lib/api";
import { DetailsTab } from "../tabs/DetailsTab";