Uh oh!
There was an error while loading. Please reload this page.
improvement(testing): consolidate @sim/db mocks into one table-aware chain mock - #5856
Conversation
…chain mock - back databaseMock and dbChainMock with the SAME db instance so a module bound to either export hits identical chain fns — rival-mock divergence between the two @sim/testing db mocks is structurally impossible now - add queueTableRows(table, rows): FIFO per-table select routing keyed by schema-mock table identity, consumed at where() materialization and resolved by every downstream terminal (limit/orderBy/groupBy/for/joins) - delete createMockDb (duplicate chain implementation, no external users) - migrate the five suites that hand-rolled table routing + databaseMock delegation (billing plan/usage/usage-log, admin dashboard-organizations, workspaces/utils) onto queueTableRows; net -295 lines - add a contract test for the mock itself and a test script to @sim/testing so its tests actually run under turbo
The latest updates on your projects. Learn more about Vercel for GitHub. |
PR SummaryLow Risk Overview Five Reviewed by Cursor Bugbot for commit 46e056c. Configure here. |
Uh oh!
There was an error while loading. Please reload this page.
Greptile SummaryThis PR consolidates the database test mocks around one table-aware shared instance. The main changes are:
Confidence Score: 5/5This looks safe to merge.
Important Files Changed
Reviews (5): Last reviewed commit: "fix(testing): lazy queue consumption at ..." | Re-trigger Greptile |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
…from, mutation isolation - track the chain's tables as a list (from + joins) so rows queued for a join-only table route correctly; from-table queue checked first - make the from/join builder a lazy thenable so awaiting a select with no where clause resolves queued rows (dequeue at await, never double-consumed) - update/delete/set clear the routing context so a mutation's where() can never consume rows queued for a select - document the left-to-right chain-construction assumption; contract tests for all three behaviors
waleedlatif1
commented
Jul 22, 2026
waleedlatif1
commented
Jul 22, 2026
@cursor review |
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit d34ca5f. Configure here.
waleedlatif1
commented
Jul 22, 2026
waleedlatif1
commented
Jul 22, 2026
@cursor review |
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 858ae53. Configure here.
- shared dbChainMockFns entries become pure spy/override ports: their default implementation returns a sentinel that chain-local builders replace, while any mock* override on the spy wins verbatim - each select().from() captures its own immutable table list; where(), joins, terminals, and direct awaits all resolve through that closure, so partially-built chains for different tables interleave without cross-talk - no module-level routing state remains
waleedlatif1
commented
Jul 22, 2026
waleedlatif1
commented
Jul 22, 2026
@cursor review |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
…e on reset - each chain holds one lazy rows supplier: the queued set is dequeued only when a default thenable actually resolves, so a chain answered by a per-test terminal override leaves its queued rows for the next chain - resetDbChainMock also mockReset()s the stable db entry-point wrappers so direct overrides on databaseMock.db.* cannot outlive a suite
waleedlatif1
commented
Jul 22, 2026
waleedlatif1
commented
Jul 22, 2026
@cursor review |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 46e056c. Configure here.
Uh oh!
There was an error while loading. Please reload this page.
Summary
databaseMock(global setup mock) anddbChainMockwith the same db instance — a module bound to either export now hits identical chain fns, eliminating the rival-implementation split between the two@sim/testingdb mocksqueueTableRows(table, rows): first-class FIFO per-table select routing keyed by schema-mock table identity; every downstream terminal (limit/orderBy/groupBy/for/joins/direct await) resolves the queued rowscreateMockDb— a duplicate chain implementation with no external consumersdatabaseMockdelegation (billing plan/usage/usage-log, admin dashboard-organizations, workspaces/utils) onto the new API — net −295 lines of bespoke test plumbingtestscript to@sim/testingso its tests actually run under turbo (they previously never ran in CI)isolate: false) campaign: with one shared db-mock instance, first-importer binding freezes can no longer split@sim/dbbehavior between suitesType of Change
Testing
Full apps/sim suite green locally (13640/13642; the two failures are a pre-existing local ripgrep dependency and an unrelated load-induced regex-timing flake, both passing standalone). New
@sim/testingcontract test covers instance sharing, FIFO routing, terminal resolution, override precedence, reset, and transactions. tsc + biome clean on both packages.Checklist