fix: add missing mocks for auth test dependencies (#5418)#5422
fix: add missing mocks for auth test dependencies (#5418)#5422clubanderson merged 1 commit intomainfrom
Conversation
PR #5412 added clearClusterCacheOnLogout (from hooks/mcp/shared), clearPermissionsCache, disconnectPresence, and clearSSECache imports to auth.tsx. The auth tests did not mock these new dependencies, causing 50 test failures. The demoMode mock also lacked exports (isNetlifyDeployment, isDemoMode, isDemoToken, subscribeDemoMode) that hooks/mcp/shared requires at module load time. Closes #5418 Signed-off-by: Andrew Anderson <[email protected]>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
✅ Deploy Preview for kubestellarconsole ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
👋 Hey @clubanderson — thanks for opening this PR!
This is an automated message. |
|
Thank you for your contribution! Your PR has been merged. Check out what's new:
Stay connected: Slack #kubestellar-dev | Multi-Cluster Survey |
There was a problem hiding this comment.
Pull request overview
This PR fixes Vitest failures introduced after auth.tsx started importing additional cleanup/cache modules by adding the missing vi.mock declarations and expanding the existing demoMode mock to include exports required during module initialization.
Changes:
- Extend the
../demoModetest mock with additional exports (isNetlifyDeployment,isDemoMode,isDemoToken,subscribeDemoMode). - Add missing mocks for newly imported auth dependencies:
hooks/mcp/shared,hooks/usePermissions,hooks/useActiveUsers, andlib/sseClient.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
web/src/lib/__tests__/auth.test.ts |
Adds missing mocks so auth.tsx and its transitive imports can load in tests without pulling in real cache/side-effect modules. |
web/src/lib/__tests__/auth-expand.test.ts |
Mirrors the same missing mocks/exports to stabilize the expanded auth test suite. |
|
Post-merge build verification passed ✅ Both Go and frontend builds compiled successfully against merge commit |
✅ Post-Merge Verification: passedCommit: |
Summary
vi.mockdeclarations for 4 modules newly imported byauth.tsxin PR fix: SSE cache poisoning, cluster data leak, exec audit, upgrade auth #5412:hooks/mcp/shared(clearClusterCacheOnLogout),hooks/usePermissions(clearPermissionsCache),hooks/useActiveUsers(disconnectPresence), andlib/sseClient(clearSSECache)isNetlifyDeployment,isDemoMode,isDemoToken,subscribeDemoMode) to thedemoModemock, whichhooks/mcp/sharedrequires at module load timeCloses #5418
Test plan
npx vitest run src/lib/__tests__/auth-expand.test.ts-- 35/35 pass (was 14 failures)npx vitest run src/lib/__tests__/auth.test.ts-- 61/61 pass (was 36 failures)