fix(canvas): add missing budgetLimit/budget_limit to test fixtures, fix AuthGate mock types

The budget PR (#541) added budgetLimit: number | null as a required field
on WorkspaceNodeData and budget_limit: number | null on WorkspaceData.
Seven test fixture factories were not updated, causing tsc --noEmit to
produce 34 TS2322/TS2345 errors (runtime tests still passed because
Vitest transpiles via esbuild which strips types).

Fixes:
- canvas-events.test.ts: makeNode factory +budgetLimit: null
- canvas-events-pan.test.ts: makeNode factory +budgetLimit: null
- canvas-capabilities.test.ts: makeNodeData factory +budgetLimit: null
- canvas-topology.test.ts: makeWS factory +budget_limit: null
- canvas.test.ts: makeWS factory +budget_limit: null; two inline
  summarizeWorkspaceCapabilities args +budgetLimit: null; context-menu
  fixture +budgetLimit: null
- ProvisioningTimeout.test.tsx: makeWS factory +budget_limit: null

Also fixes 3 TS2348 errors in AuthGate.test.tsx: newer Vitest type defs
resolve ReturnType<typeof vi.fn> to Mock<Procedure|Constructable> which
TypeScript no longer considers directly callable in a vi.mock factory.
Fix: intersect the mock variables with a plain function type so both the
call expression and the mock API (mockReturnValue etc.) type-check.

tsc --noEmit: 0 errors. npm test: 722/722.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Molecule AI Frontend Engineer 2026-04-17 21:37:50 +00:00
parent 8d1bbd56f2
commit fef664d6d0
7 changed files with 19 additions and 6 deletions

View File

@ -8,14 +8,18 @@ afterEach(() => {
});
// ── Mocks (defined before dynamic import of component) ───────────────────────
let mockFetchSession: ReturnType<typeof vi.fn>;
let mockRedirectToLogin: ReturnType<typeof vi.fn>;
let mockGetTenantSlug: ReturnType<typeof vi.fn>;
// Use a function type so TypeScript accepts the mock as callable in vi.mock factories.
// ReturnType<typeof vi.fn> resolves to Mock<Procedure|Constructable> in newer Vitest
// type defs, which TS no longer considers directly callable. Casting to a plain
// function type avoids the TS2348 error while keeping full mock API (mockReturnValue etc.).
let mockFetchSession: ((...args: unknown[]) => unknown) & ReturnType<typeof vi.fn>;
let mockRedirectToLogin: ((...args: unknown[]) => unknown) & ReturnType<typeof vi.fn>;
let mockGetTenantSlug: ((...args: unknown[]) => unknown) & ReturnType<typeof vi.fn>;
beforeEach(() => {
mockFetchSession = vi.fn();
mockRedirectToLogin = vi.fn();
mockGetTenantSlug = vi.fn(() => null); // default: non-SaaS (pass-through)
mockFetchSession = vi.fn() as typeof mockFetchSession;
mockRedirectToLogin = vi.fn() as typeof mockRedirectToLogin;
mockGetTenantSlug = vi.fn(() => null) as typeof mockGetTenantSlug;
});
vi.mock("@/lib/auth", () => ({

View File

@ -28,6 +28,7 @@ function makeWS(overrides: Partial<WorkspaceData> & { id: string }): WorkspaceDa
y: 0,
collapsed: false,
runtime: "",
budget_limit: null,
...overrides,
};
}

View File

@ -22,6 +22,7 @@ function makeNodeData(overrides: Partial<WorkspaceNodeData> = {}): WorkspaceNode
currentTask: "",
needsRestart: false,
runtime: "",
budgetLimit: null,
...overrides,
};
}

View File

@ -34,6 +34,7 @@ function makeNode(
currentTask: "",
needsRestart: false,
runtime: "",
budgetLimit: null,
...overrides,
},
};

View File

@ -31,6 +31,7 @@ function makeNode(
currentTask: "",
needsRestart: false,
runtime: "",
budgetLimit: null,
...overrides,
},
};

View File

@ -24,6 +24,7 @@ function makeWS(overrides: Partial<WorkspaceData> & { id: string }): WorkspaceDa
y: 0,
collapsed: false,
runtime: "",
budget_limit: null,
...overrides,
};
}

View File

@ -27,6 +27,7 @@ function makeWS(overrides: Partial<WorkspaceData> & { id: string }): WorkspaceDa
y: 0,
collapsed: false,
runtime: "",
budget_limit: null,
...overrides,
};
}
@ -172,6 +173,7 @@ describe("summarizeWorkspaceCapabilities", () => {
currentTask: "Reviewing docs",
needsRestart: false,
runtime: "claude-code",
budgetLimit: null,
});
expect(summary.runtime).toBe("claude-code");
@ -197,6 +199,7 @@ describe("summarizeWorkspaceCapabilities", () => {
currentTask: " ",
needsRestart: false,
runtime: "",
budgetLimit: null,
});
expect(summary.runtime).toBeNull();
@ -554,6 +557,7 @@ describe("context menu", () => {
currentTask: "",
needsRestart: false,
runtime: "",
budgetLimit: null,
},
};