mirror of
https://github.com/simstudioai/sim.git
synced 2026-09-24 15:45:35 +08:00
* improvement(testing): consolidate @sim/db mocks into one table-aware 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 * fix(testing): harden table routing — join-table queues, direct-await 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 * fix(testing): close routing over each chain's own tables for direct-await builders * refactor(testing): move all chain routing state into per-chain closures - 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 * fix(testing): lazy queue consumption at resolution and wrapper restore 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
64 lines
1.5 KiB
JSON
64 lines
1.5 KiB
JSON
{
|
|
"name": "@sim/testing",
|
|
"version": "0.1.0",
|
|
"private": true,
|
|
"sideEffects": [
|
|
"./src/setup/*"
|
|
],
|
|
"type": "module",
|
|
"license": "Apache-2.0",
|
|
"engines": {
|
|
"bun": ">=1.2.13",
|
|
"node": ">=20.0.0"
|
|
},
|
|
"exports": {
|
|
".": {
|
|
"types": "./src/index.ts",
|
|
"default": "./src/index.ts"
|
|
},
|
|
"./factories": {
|
|
"types": "./src/factories/index.ts",
|
|
"default": "./src/factories/index.ts"
|
|
},
|
|
"./builders": {
|
|
"types": "./src/builders/index.ts",
|
|
"default": "./src/builders/index.ts"
|
|
},
|
|
"./mocks": {
|
|
"types": "./src/mocks/index.ts",
|
|
"default": "./src/mocks/index.ts"
|
|
},
|
|
"./mocks/executor": {
|
|
"types": "./src/mocks/executor.mock.ts",
|
|
"default": "./src/mocks/executor.mock.ts"
|
|
},
|
|
"./assertions": {
|
|
"types": "./src/assertions/index.ts",
|
|
"default": "./src/assertions/index.ts"
|
|
},
|
|
"./setup": {
|
|
"types": "./src/setup/vitest.setup.ts",
|
|
"default": "./src/setup/vitest.setup.ts"
|
|
}
|
|
},
|
|
"scripts": {
|
|
"test": "vitest run",
|
|
"type-check": "tsc --noEmit",
|
|
"lint": "biome check --write --unsafe .",
|
|
"lint:check": "biome check .",
|
|
"format": "biome format --write .",
|
|
"format:check": "biome format ."
|
|
},
|
|
"peerDependencies": {
|
|
"vitest": "^3.0.0 || >=4.1.0 <5.0.0"
|
|
},
|
|
"devDependencies": {
|
|
"@sim/tsconfig": "workspace:*",
|
|
"typescript": "^7.0.2",
|
|
"vitest": "^4.1.0"
|
|
},
|
|
"dependencies": {
|
|
"@sim/utils": "workspace:*"
|
|
}
|
|
}
|