Skip to content

Restore the workspace provider mock in every web test file that replaces it #415

Closed

Description

@imshashank

bun test keeps a mock.module for the rest of the process, so a test file that mocks @/features/issues/workspace-provider.tsx and never restores it changes what the next file sees. That is what turned main red on the IssueCard suite this week (#398): one file replaced the whole module with a single export.

#398 fixed the one file that dropped exports. Fifteen more files still mock the provider without restoring it. They spread the real module, so they do not drop exports, but each leaks its useWorkspace fixture into whichever file loads next, and the failure shows up somewhere unrelated when directory order changes:

  • apps/web/tests/features/docs/doc-surface-access.test.tsx
  • apps/web/tests/features/docs/doc-surface-return.test.tsx
  • apps/web/tests/features/filters/filter-bar.test.tsx
  • apps/web/tests/features/inbox/inbox-issue.test.tsx
  • apps/web/tests/features/issues/board.test.tsx
  • apps/web/tests/features/issues/copy-branch-name.test.tsx
  • apps/web/tests/features/issues/issue-copy-actions.test.tsx
  • apps/web/tests/features/issues/issue-deletion.test.tsx
  • apps/web/tests/features/issues/issue-detail-delete.test.tsx
  • apps/web/tests/features/issues/issue-properties.test.tsx
  • apps/web/tests/features/issues/quick-create.test.tsx
  • apps/web/tests/features/views/create-view-dialog.test.tsx
  • apps/web/tests/features/views/saved-view-page.test.tsx
  • apps/web/tests/features/views/unresolvable-scope.test.tsx
  • apps/web/tests/features/views/views-page.test.tsx

In each: call restoreModulesAfterThisFile(['@/features/issues/workspace-provider.tsx']) from tests-support.ts before the mock, and if the factory calls the real hook, capture it first (const real = mod.useWorkspace) because bun rewires the live binding and mod.useWorkspace() inside the factory calls the mock itself. card-controls.test.tsx shows the pattern after #398.

Run bun run test in apps/web before and after; nothing should change except that file order stops mattering.

Activity

  1. added
    good first issue
    help wanted
    tests
    ready
    area: web
    size: small
    points: 2
    on Sep 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: webgood first issuehelp wantedpoints: 2readysize: smalltests

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions