chore(test): scaffold vitest and add waitlist route tests#3
Merged
Conversation
Adds vitest as a devDependency with test/test:watch scripts and a vitest.config.ts that aliases @/ to repo root and runs in the node environment (Cloudflare Workers' nodejs_compat flag matches). Covers the waitlist POST handler across all 8 branches: - missing/invalid email (400) - missing NOTION_TOKEN or NOTION_WAITLIST_DB_ID (500) - no A/B variant (Notion payload without Variant, no trackConversion) - variant 'A' assigned (Variant select + trackConversion called) - Notion API non-ok response (500) - malformed request body (500 via outer catch) Resolves audit TEST-08 (.audit-report.md). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
3 tasks
This was referenced May 23, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Mocking strategy: `vi.mock('@/lib/ab-testing', ...)` for `getVariant` / `trackConversion`, `vi.stubEnv` for env vars (with `vi.resetModules()` + dynamic `import()` of the route per test because env is captured at module-load time), `vi.spyOn(global, 'fetch')` for the Notion call.
Resolves audit TEST-08 from `.audit-report.md`. This is the first test in the repo — the waitlist is the only ingress for real user data so getting coverage here was the highest-leverage starting point.
Test plan
🤖 Generated with Claude Code