learning_ai_notes/backend/package.json
saravanakumardb1 79e936bd68 feat(ci): Cosmos emulator smoke job exercises partition-key paths
The existing 380-test backend suite runs entirely against the in-memory
datastore provider, which treats every partition-key value as equivalent.
This hid one entire class of bug — partition-key mismatches — until
production. D7 closes that gap.

Implementation:

- backend/src/test-helpers.ts adds useCosmosDatastore() that swaps the
  active provider for CosmosDatastoreProvider using COSMOS_ENDPOINT /
  COSMOS_KEY / COSMOS_DATABASE. Throws synchronously when env is missing
  so a misconfigured run fails loudly instead of silently falling back
  to in-memory.

- backend/vitest.config.ts now excludes src/**/*.cosmos.test.ts so the
  default 'pnpm test' run stays green for contributors without Docker.

- backend/vitest.cosmos.config.ts (new) includes ONLY *.cosmos.test.ts,
  bumps testTimeout to 30s / hookTimeout to 60s for the real client
  round-trips, and locks DB_PROVIDER=cosmos in test env.

- backend/src/cosmos.smoke.cosmos.test.ts (new) covers the four most
  important partition-key contracts in NoteLett:
    workspaces      /userId
    notes           /workspaceId
    note_tasks      /workspaceId
    note_shares     /workspaceId  (full create → resolve → delete → null)
  Each test also asserts that a wrong-partition-key lookup returns null,
  which is the failure mode the in-memory provider cannot simulate.

- backend/package.json adds 'test:cosmos' script.

- .github/workflows/ci.yml gains a backend-cosmos job that boots the
  official mcr.microsoft.com/cosmosdb/linux/azure-cosmos-emulator
  container as a service, waits for it to be ready (60 × 5s polls of
  /_explorer/emulator.pem), then runs pnpm test:cosmos against it.
  The job depends on the existing backend job so the emulator only
  spins up after unit tests pass.

Verified locally:
- pnpm --filter @notelett/backend test: 380/380 (cosmos suite excluded)
- vitest list --config vitest.cosmos.config.ts: 4 tests under the cosmos
  smoke suite, as designed
- pnpm run verify: end-to-end green (backend 380/380, web 96/96,
  mobile 97/97)
- ci.yml passes Python yaml.safe_load

CI verification: the new job will execute on the next push. Local
verification against the emulator requires Docker on the dev host.
2026-05-23 00:25:24 -07:00

52 lines
1.5 KiB
JSON

{
"name": "@notelett/backend",
"version": "0.1.0",
"private": true,
"packageManager": "pnpm@10.6.5",
"description": "NoteLett product backend — notes, workspaces, relationships, tasks, artifacts, agent actions",
"type": "module",
"scripts": {
"dev": "tsx watch src/server.ts",
"bootstrap:seed": "tsx src/scripts/bootstrap-seed.ts",
"build": "tsc",
"start": "node dist/server.js",
"test": "vitest run",
"test:watch": "vitest",
"test:cosmos": "vitest run --config vitest.cosmos.config.ts",
"typecheck": "tsc --noEmit",
"lint": "eslint src/"
},
"dependencies": {
"@azure/cosmos": "^4.2.0",
"@bytelyst/auth": "*",
"@bytelyst/backend-config": "*",
"@bytelyst/backend-flags": "*",
"@bytelyst/backend-telemetry": "*",
"@bytelyst/config": "*",
"@bytelyst/cosmos": "*",
"@bytelyst/datastore": "*",
"@bytelyst/errors": "*",
"@bytelyst/fastify-auth": "*",
"@bytelyst/fastify-core": "*",
"@bytelyst/field-encrypt": "*",
"@bytelyst/llm": "*",
"@bytelyst/logger": "*",
"@bytelyst/monitoring": "*",
"@bytelyst/palace": "*",
"@bytelyst/webhook-dispatch": "*",
"fastify": "5.7.4",
"jose": "^6.0.8",
"zod": "^3.24.2"
},
"devDependencies": {
"@bytelyst/testing": "*",
"@eslint/js": "^9.39.4",
"@types/node": "^22.12.0",
"eslint": "^9.0.0",
"tsx": "^4.19.2",
"typescript": "^5.7.3",
"typescript-eslint": "^8.0.0",
"vitest": "^3.0.5"
}
}