Skip to content

test(support): stop the route tests from opening a real database connection - #221

Merged
cihanalagoz merged 1 commit into
mainfrom
fix/support-route-tests-db-mock
Aug 17, 2026
Merged

test(support): stop the route tests from opening a real database connection#221
cihanalagoz merged 1 commit into
mainfrom
fix/support-route-tests-db-mock

Conversation

@cihanalagoz

Copy link
Copy Markdown
Collaborator

Fixes the CI failure on main introduced by #220.

withApiRequestContext binds the session's tenant DB around every handler, so
src/__tests__/api/support.test.ts opened a real MongoDB connection on each
request. That passed locally, where an instance happens to be running, and
timed out after five seconds on all ten cases in CI:

× GET /api/support/status > reports whether an entry point should be shown 5006ms
× POST /api/support/handoff > passes the session identity to the handoff service 5000ms
...

The test now mocks @/lib/database with a runWithTenant that simply invokes
the callback, the same shape the other Fastify plugin tests use. That keeps the
tenant-binding branch exercised instead of skipping it.

10 tests, 5006ms → 55ms, no database required.

…ection

withApiRequestContext binds the session's tenant DB around every handler, so
the support route tests connected to MongoDB for real. That passed locally,
where an instance happens to be running, and timed out after five seconds on
every case in CI.
@cihanalagoz
cihanalagoz merged commit 71698ef into main Aug 17, 2026
1 check passed
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