-
Notifications
You must be signed in to change notification settings - Fork 339
[tests] Added mock db for easier testing #396
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
brandonkachen
wants to merge
18
commits into
main
Choose a base branch
from
brandon/mock-db
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
+1,105
−218
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- Add TestableDb interface to common/types/contracts/database.ts for type-safe database mocking - Move mock-db.ts from web/src/testing to common/src/testing - Add createSelectOnlyMockDb for version-utils query patterns - Add createMockDb, createMockDbWithErrors for API route testing - Update API routes to use TestableDb interface instead of CodebuffPgDatabase - Refactor test files to use shared mock-db utilities without type assertions - All 1,647+ tests passing across packages
Use runtime detection to conditionally load bun:test mock function. Falls back to identity function when running in Jest.
Jest cannot resolve bun:test at parse time even with runtime checks. Add moduleNameMapper to stub bun:test with an identity function.
Add testPathIgnorePatterns for dependencies test that uses bun:test directly.
…ping Playwright requires test.use() to be called inside a describe block.
TestableDb is a testing-specific interface, so it belongs with the mock utilities.
TestableDb implied it was only for testing, but it is used as a parameter type in production code. DbOperations is more accurate.
… location - Move DbOperations and DbWhereResult from testing/mock-db.ts to types/contracts/database.ts - Update production imports in version-utils.ts, agent-runs/_post.ts, steps/_post.ts - Re-export from mock-db.ts for backwards compatibility with test imports - Fix type error in dependencies/_get.ts by handling version: string | null - Update knowledge.md with proper import guidance
- Rename store-hydration.test.ts -> store-hydration.e2e.ts - Rename store-ssr.test.ts -> store-ssr.e2e.ts - Update playwright.config.ts to match .e2e.ts files - Add web/bunfig.toml for test runner configuration This prevents Bun test runner from picking up Playwright tests, which should only be run via `bun run e2e`
The .e2e.ts extension is sufficient to exclude Playwright tests from Bun test runner
Tests in lib/__tests__ use bun:test mock.module() which is not supported by the Jest stub. These tests should run with bun test only. This fixes CI failure where ban-conditions.test.ts failed due to missing fetch polyfill when Stripe SDK was initialized.
…ib/__tests__ agent-tree.test.ts uses Jest globals and should run in CI
# Conflicts: # web/jest.config.cjs # web/playwright.config.ts # web/src/__tests__/e2e/store-ssr.e2e.ts
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
No description provided.