From zero automated tests to production-grade coverage
The codebase has zero automated test files. No Vitest, no Jest, no Playwright test runner, no test scripts in package.json. The v3 cost analysis noted "Vitest configured, minimal tests" — that was inaccurate. All testing to date has been manual QA: a 60-test QA checklist, Stitch's 83 manual API tests (Layer 1), and Pixel's 124-test Pre-Launch UI Testing Plan (Layer 2, in progress).
The manual QA is thorough and has caught real bugs. But there is no regression safety net — any code change risks breaking something that was previously verified. This plan creates that safety net.
Phase 1 gets us to B (2–3 days). Phase 2 gets us to B+ (3–4 more days). Phase 3 gets us to A (2–3 more days). Total: 7–10 AI-assisted days.
Install Vitest, write critical-path backend tests. This is the highest-ROI phase — protects the routes that handle real money and real user data.
Test the business logic layer: churn detection, retention emails, trial reminders, Instagram OAuth, onboarding.
Frontend component tests, E2E automation, CI pipeline with coverage thresholds.
Charlotte has prepared the following files in documents/test-prep/. These are ready to copy into the codebase and fill in.
| File | What It Is | Action |
|---|---|---|
backend/vitest.config.ts | Vitest configuration with v8 coverage, thresholds, test patterns | Copy to backend/ |
backend/tests/setup.js | Global test setup — mocks for ALL external services (Supabase, Stripe, AI, Kit, Cloudinary, Resend, Twilio, Instagram) | Copy to backend/tests/ |
backend/tests/routes/authRoutes.test.js | 17 test stubs for auth routes | Fill in test bodies |
backend/tests/routes/billingRoutes.test.js | 16 test stubs for billing/Stripe | Fill in test bodies |
backend/tests/routes/contentRoutes.test.js | 28 test stubs for content CRUD + AI generation | Fill in test bodies |
backend/tests/routes/publishRoutes.test.js | 9 test stubs for Instagram publishing | Fill in test bodies |
backend/tests/routes/instagramRoutes.test.js | 11 test stubs for Instagram OAuth + insights | Fill in test bodies |
backend/tests/routes/onboardingRoutes.test.js | 7 test stubs for onboarding flow | Fill in test bodies |
backend/tests/routes/adminRoutes.test.js | 7 test stubs for admin dashboard | Fill in test bodies |
backend/tests/middleware/auth.test.js | 9 test stubs for JWT middleware | Fill in test bodies |
backend/tests/middleware/featureGate.test.js | 10 test stubs for tier gating | Fill in test bodies |
backend/tests/services/churnDetection.test.js | 9 test stubs for churn detection | Fill in test bodies |
backend/tests/services/retentionService.test.js | 8 test stubs for retention emails | Fill in test bodies |
backend/package-additions.json | devDependencies + scripts to add to package.json | Merge into package.json |
ci/test.yml | GitHub Actions workflow for automated test runs | Copy to .github/workflows/ |
The setup.js mocks assume import paths like ../src/services/aiService. Stitch will need to verify these match the actual project structure. The mock implementations are realistic (returning plausible data shapes) but may need tweaking based on actual service return types.
Adding tests does NOT change application behavior and is safe during the Meta App Review production freeze. Test files, config, and devDependencies don't affect the production build.