Skip to content

fix(web): load shared test compat setup#1662

Merged
Uarmagan merged 5 commits intomainfrom
fix/web-test-compat
Apr 22, 2026
Merged

fix(web): load shared test compat setup#1662
Uarmagan merged 5 commits intomainfrom
fix/web-test-compat

Conversation

@Uarmagan
Copy link
Copy Markdown
Contributor

@Uarmagan Uarmagan commented Apr 22, 2026

Summary

  • load the shared Bun/Jest compatibility setup before web imports the shared core test startup
  • expose Bun test expect globally so direct @testing-library/jest-dom imports work in web tests
  • remove a stale AuthModal TooltipWrapper mock that could bleed into the real TooltipWrapper tests under CI file ordering
  • run each web test file in its own Bun process from the existing shared test dispatcher, so global mock.module state cannot leak between files
  • simplify several useOpenAtCursor test mocks so they no longer require the real module from inside its own mock factory

Why Tests Were Failing

The core test command itself was passing, but the web unit job imports the shared core test startup from web.preload.ts. After the backend/core fix, that shared startup calls jest.mock through mockBSON(). The web preload did not install the shared compatibility setup first, so jest.mock was unavailable and the preload stopped before it created DOM globals. That caused the broad cascade of missing document, window, and related failures in the web job.

After installing the compatibility setup first, the remaining failures came from tests that import @testing-library/jest-dom directly. That package expects expect to be global, while the web preload only imported and extended Bun’s expect locally. The preload now exposes that same expect globally.

CI then exposed Bun 1.2.18 ordering issues in tests that register global mock.module mocks. A stale AuthModal mock for TooltipWrapper leaked into the real TooltipWrapper tests; removing it fixed that leak. Other failures came from interleaved files mocking shared modules like useOpenAtCursor, so the existing test dispatcher now executes each web test file in a separate Bun process.

Verification

  • bunx bun@1.2.18 packages/scripts/src/testing/run.ts web
  • bun run test:web
  • bun run test:core
  • ./node_modules/.bin/biome check package.json packages/scripts/src/testing/run.ts packages/web/src/__tests__/web.preload.ts packages/web/src/components/AuthModal/AuthModal.test.tsx packages/web/src/common/hooks/useEventDNDActions.test.ts packages/web/src/common/hooks/useEventResizeActions.test.ts packages/web/src/views/Day/hooks/events/useOpenEventContextMenu.test.ts packages/web/src/views/Day/hooks/events/useOpenAgendaEventPreview.test.ts packages/web/src/views/Forms/hooks/useCloseEventForm.test.ts

Notes

  • The scoped Biome check exits successfully but still reports existing warning-level items in touched test files.
  • I retried the full backend suite locally while investigating; it failed on Mongo memory-server startup timeouts (Instance failed to start within 10000ms), not on the test-compat code path. The backend CI job had already passed after the original backend fix.

@Uarmagan Uarmagan merged commit 0e7ccac into main Apr 22, 2026
8 checks passed
@Uarmagan Uarmagan deleted the fix/web-test-compat branch April 22, 2026 20:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant