## Why Investigating two bad community picks for one user (jobs 8695c32e, 94c83a7e) found: - a YouTube-bot request was "claimed" by a vote that was later moved, leaving a 0-vote request with a stale owner that was still pickable (`vote_count >= 0`); - the daily pick's `select_best` raised on remote (dict) results and silently fell back to result #0 (logged as a WARNING on 7 days since 10 Oct). ## What - **Real users only:** every request must belong to a real user email (`require_real_email`, enforced in the service); the YouTube comment bot no longer creates requests, it replies with how to request on the board. Legacy placeholder rows are never listed/picked/credited. - **Limits:** 1 request + 1 vote per day (submitting spends the vote → `409 vote_already_used`; `429 submission_limit`). The cap uses a create-only per-day marker, so deleting a request doesn't give the submission back (purged on account deletion). - **Last up-vote deletes the request** after confirmation (`409 would_delete_request` + `request_id` until `confirm_delete=true`), freeing remaining voters' votes. Replaces the claim logic. - **Picker:** needs `vote_count >= 1` and an owner who still up-votes it and hasn't owned it already; deleting a community job reopens its request (or deletes it if nobody backs it). - **Audio:** unattended pick only on an exact artist+title match (torrent ≥3 seeders, else Spotify; ambiguity → none). Otherwise the job parks in `AWAITING_AUDIO_SELECTION` and the owner is emailed. - **Email:** community-pick review email says the song came from the requests board. - **UI:** confirm before spending the daily vote / submitting, thank-you panel with credit-pack CTA (`/app?buy=1`), form disabled once the vote is spent, delete-request warning. Strings in all 33 frontend locales + en/es/de backend. ## Testing - Emulator tests for all service rules (real Firestore transactions), unit tests for routes, audio pick, daily pick parking, notifications; Jest tests for the board client. - Local CodeRabbit review run; all 7 findings fixed. - Note: a handful of existing job-creation emulator tests and `test_internal_api` auth tests fail identically on clean `origin/main` in my local env; CI is the judge. Plan: docs/archive/2026-10-26-requests-board-overhaul-plan.md. Docs: REQUESTS-BOARD.md, API.md, LESSONS-LEARNED.md. @coderabbitai ignore 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Sonnet 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 |