Files
CherryHQ-cherry-studio/tsconfig.node.json
fullex 8c83072887 feat(test-infra): introduce setupTestDatabase harness
Adds a unified, file-backed SQLite test harness under tests/helpers/db/
that provisions a real database per test file using the production
migrations + CUSTOM_SQL_STATEMENTS, wires it through
MockMainDbServiceUtils.setDb() so production code reaches it via
application.get('DbService').getDb() transparently, truncates user
tables on beforeEach, and cleans up on afterAll. Replaces the need for
hand-written CREATE TABLE SQL and inline vi.mock('@application')
overrides in consumer tests.

Companion changes:

- Register @test-helpers/* path alias (electron.vite.config.ts,
  tsconfig.node.json paths + include, vitest.config.ts main project
  include).
- Relax the global vi.mock stubs for node:fs, node:os, node:path in
  tests/main.setup.ts so third-party libraries (drizzle-orm migrator
  etc.) can read real files. The six existing tests that depended on
  the previous fully-stubbed modules now declare a local
  vi.mock('node:fs', ...) via the new createNodeFsMock helper at
  tests/helpers/mocks/nodeFsMock.ts.
- Self-tests under tests/helpers/db/__tests__/testDatabase.test.ts
  cover PRAGMA state, truncate semantics, FTS5 trigger cascades,
  NULL-searchableText handling, application-mock routing, and
  replay-array accumulation guards.
2026-04-15 09:33:37 -07:00

45 lines
1.7 KiB
JSON

{
"compilerOptions": {
"composite": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"incremental": true,
"moduleResolution": "bundler",
"paths": {
"@application": ["./src/main/core/application"],
"@cherrystudio/provider-registry": ["./packages/provider-registry/src/index.ts"],
"@cherrystudio/provider-registry/node": ["./packages/provider-registry/src/registry-loader.ts"],
"@data/*": ["./src/main/data/*"],
"@logger": ["./src/main/core/logger/LoggerService"],
"@main/*": ["./src/main/*"],
"@mcp-trace/*": ["./packages/mcp-trace/*"],
"@modelcontextprotocol/sdk/*": ["./node_modules/@modelcontextprotocol/sdk/dist/esm/*"],
"@shared/*": ["./packages/shared/*"],
"@test-helpers/*": ["./tests/helpers/*"],
"@test-mocks/*": ["./tests/__mocks__/*"],
"@types": ["./src/renderer/src/types/index.ts"],
"@vectorstores/libsql": ["./packages/vectorstores/libsql/src/index.ts"],
"@vectorstores/libsql/*": ["./packages/vectorstores/libsql/src/*"]
},
"tsBuildInfoFile": ".tsbuildinfo/tsconfig.node.tsbuildinfo",
"types": ["electron-vite/node", "vitest/globals"],
"useDefineForClassFields": true
},
"extends": "@electron-toolkit/tsconfig/tsconfig.node.json",
"include": [
"electron.vite.config.*",
"scripts",
"src/main/**/*",
"src/main/env.d.ts",
"src/preload/**/*",
"src/renderer/src/services/traceApi.ts",
"src/renderer/src/types/*",
"packages/mcp-trace/**/*",
"packages/provider-registry/**/*",
"packages/shared/**/*",
"packages/vectorstores/**/*",
"tests/__mocks__/**/*",
"tests/helpers/**/*"
]
}