Commit 0f15b8e
test: complete vitest-pool-workers migration, delete SQL-parser mock
Migrates the remaining 9 server tests to vitest-pool-workers and removes
the fragile SQL-parsing mock DB. Pure-library tests (rate-limit,
install-script, validation) and archtests stay on happy-dom — they don't
need D1 or the Workers runtime.
Migrated to pool-workers in this commit:
- src/lib/server/auth.test.ts (JWT + DB-backed getCurrentUser)
- src/routes/api/auth/cli/start/server.test.ts
- src/routes/api/auth/cli/approve/server.test.ts
- src/routes/api/configs/[slug]/server.test.ts
- src/routes/api/configs/[slug]/revisions/server.test.ts
- src/routes/[username]/[slug]/install/server.test.ts
- src/routes/[username]/[slug]/config/server.test.ts
- src/smoke-tests/{cli-auth-flow,config-crud,critical-paths}.test.ts
The CLI auth-flow smoke test now exercises the real approve endpoint
end-to-end (previously had to fake it because the mock couldn't handle
datetime expressions). The config-crud smoke test now verifies UPDATE
side effects in the DB (previously couldn't — mock didn't honor
COALESCE).
Infrastructure:
- Adds src/lib/test/call.ts helper to cut RequestEvent boilerplate
- Extends call() with params/clientAddress for routes that need them
- Deletes src/lib/test/db-mock.ts (~390 lines of SQL-parsing mock)
- Deletes src/lib/test/setup.ts (process.env shims no longer needed)
- Deletes src/lib/test/helpers.ts (unused after migration)
- Trims src/lib/test/fixtures.ts to data-only exports
- Adds @cloudflare/vitest-pool-workers/types to tsconfig.json
- Wires npm test / test:run / test:coverage to run both configs;
adds test:happy-dom and test:workers for targeted runs
Final test layout: 181 tests on pool-workers (14 files, real D1 +
Workers runtime), 99 tests on happy-dom (6 files, pure libs +
archtests). Both green; full npm run validate clean.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent fa06e9b commit 0f15b8e
21 files changed
Lines changed: 1554 additions & 3666 deletions
File tree
- src
- lib
- server
- db
- test
- routes
- [username]/[slug]
- config
- install
- api
- auth/cli
- approve
- start
- configs/[slug]
- revisions
- smoke-tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
| 13 | + | |
14 | 14 | | |
15 | | - | |
16 | | - | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
17 | 19 | | |
18 | 20 | | |
19 | 21 | | |
| |||
0 commit comments