## Summary - **Local stack:** `scripts/local-stack.sh up --frontend` runs the **real** backend on the Firestore + GCS emulators with `FAKE_WORKERS=1`. In-process fake workers move jobs through their real states in seconds, using tiny real media, so web Playwright and mobile Maestro full-journey tests can run offline against the same endpoints. - **Email-code sign-in** (nomad-mobile spec §4.1): `POST /api/users/auth/send-code` + `verify-code`. The code logic is shared with kjbox via `LoginCodeStore`, and sends are throttled per email and per IP. - **Bug fix found by the new suite:** `confirm-duration` moved jobs to `separating_stage1`, from which they can never reach review. It now resumes at `downloading`. No prod job had taken this path yet. ## Changes - `backend/services/fake_workers/`: dispatch seam in `WorkerService.trigger_*`, plus fake search, download, checkout and outbox, scenarios, and per-user config. The real stem upload, transcode, backing-vocals analysis and preview render are reused. Every check is strict (`is True`), so a MagicMock settings object never enables the fakes, and startup **refuses FAKE_WORKERS in production**. - `/api/test/*` router (mounted only in that mode): `status`, `scenario`, `fake-config`, `emails`, `reset`, plus the fake Stripe checkout page. Paying it runs the real webhook handler. - `frontend/e2e/local-stack/` (9 specs, ~50s): - sign-up → make → review → instrumental → download - buy and cancel credits - duration confirm, failed, complete and review states - code sign-in and lockout - New required CI job `local-stack-e2e`. - Docs: TESTING.md § Local stack, DEVELOPMENT.md, API.md, README, LESSONS-LEARNED. - `MAX_SIGNUPS_PER_IP` can now be set by env. Only the local stack raises it; production keeps the default of 2. ## Testing - [x] Backend unit: 6175 passed - [x] Emulator: 152 passed - [x] Frontend Jest: 1706 passed - [x] Local-stack Playwright: 9/9 passed (CI mode) ## Review - [x] CodeRabbit CLI review completed locally. 1 minor finding declined: it suggested swallowing infrastructure errors in send-code as fake "sent" responses, which would hide real outages from users. @coderabbitai ignore --- 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01AGuxtgoscF6RJGtpjHPg3W --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Karaoke Generator Frontend
Next.js frontend for the Karaoke Generator application.
Quick Start
# Install dependencies
npm install
# Run development server
npm run dev
The app will be available at http://localhost:3000
Development Setup
Connecting to the Cloud Backend
In development, the frontend proxies API requests to the cloud backend (api.nomadkaraoke.com) via Next.js rewrites. This avoids CORS issues and allows local development without running a local backend.
The proxy is configured in next.config.mjs:
- All
/api/*requests are forwarded to the cloud backend - You can override the backend URL with
BACKEND_URLenvironment variable
Authentication
The backend requires authentication. To authenticate:
-
Create a
.env.localfile in the frontend directory:KARAOKE_ACCESS_TOKEN=your-token-here -
The token is automatically loaded by Playwright tests
-
In the browser, the token is stored in
localStorageaskaraoke_access_token
Testing
Unit Tests (Jest)
# Run tests in watch mode
npm test
# Run tests with coverage
npm run test:coverage
# Run tests in CI mode
npm run test:ci
E2E Tests (Playwright)
E2E tests run against the local dev server connected to the real cloud backend.
# Run all E2E tests
npm run test:e2e
# Run with UI (interactive mode)
npm run test:e2e:ui
# Run in headed mode (see the browser)
npm run test:e2e:headed
# Run in debug mode
npm run test:e2e:debug
Authentication for E2E Tests
E2E tests require a valid access token. Set it in .env.local:
KARAOKE_ACCESS_TOKEN=your-token-here
The Playwright config (playwright.config.ts) automatically loads this file.
Test Structure
Tests are located in e2e/:
karaoke-generation.spec.ts- Main test suite covering:- Homepage loading and form display
- Search tab functionality
- Audio search submission
- Audio selection dialog flow
- API health checks
Test Architecture
┌─────────────────┐ ┌──────────────────┐ ┌─────────────────────┐
│ Playwright │────▶│ Next.js Dev │────▶│ Cloud Backend │
│ Browser │ │ Server (:3000) │ │ api.nomadkaraoke │
└─────────────────┘ └──────────────────┘ └─────────────────────┘
│
▼
API Proxy
/api/* → backend
Debugging Test Failures
- Screenshots: Failed tests save screenshots to
test-results/ - Videos: First retry captures video (when retries enabled)
- Traces: View detailed traces with
npx playwright show-trace <trace.zip> - HTML Report: After running tests, view
npx playwright show-report
Common Issues
- 401 Unauthorized: Token missing or invalid - check
.env.local - Socket hang up: Backend operation taking too long - some operations (like audio download) can take minutes
- Element outside viewport: Dialog scrolling issues - tests use JavaScript click to handle this
Project Structure
frontend/
├── app/ # Next.js app router pages
├── components/ # React components
│ ├── ui/ # shadcn/ui components
│ └── audio-search/ # Audio search feature components
├── lib/ # Utilities and API client
│ └── api.ts # Backend API client
├── e2e/ # Playwright E2E tests
├── playwright.config.ts # Playwright configuration
└── next.config.mjs # Next.js configuration
Scripts
| Script | Description |
|---|---|
npm run dev |
Start development server |
npm run build |
Build for production |
npm run start |
Start production server |
npm run lint |
Run ESLint |
npm test |
Run unit tests (watch mode) |
npm run test:ci |
Run unit tests (CI mode with coverage) |
npm run test:e2e |
Run E2E tests |
npm run test:e2e:ui |
Run E2E tests with interactive UI |