mirror of
https://github.com/nomadkaraoke/karaoke-gen.git
synced 2026-11-20 13:07:57 +09:00
## 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>
58 lines
2.1 KiB
TypeScript
58 lines
2.1 KiB
TypeScript
import { defineConfig, devices } from '@playwright/test';
|
|
|
|
/**
|
|
* Full-journey E2E against the gen LOCAL STACK: the real backend on the
|
|
* Firestore + GCS emulators with fake workers (scripts/local-stack.sh). Unlike
|
|
* e2e/regression (static per-test API mocks), every request here hits real
|
|
* routes, and jobs move through their real states in seconds.
|
|
*
|
|
* npm run test:e2e:local-stack # starts the stack if it isn't up
|
|
* scripts/local-stack.sh up --frontend # or keep it running between runs
|
|
*
|
|
* Ports: LOCAL_STACK_API_PORT (8010), LOCAL_STACK_WEB_PORT (3010).
|
|
* See docs/TESTING.md § "Local stack".
|
|
*/
|
|
const API_PORT = process.env.LOCAL_STACK_API_PORT || '8010';
|
|
const WEB_PORT = process.env.LOCAL_STACK_WEB_PORT || '3010';
|
|
const API_URL = `http://127.0.0.1:${API_PORT}`;
|
|
const WEB_URL = `http://127.0.0.1:${WEB_PORT}`;
|
|
|
|
process.env.LOCAL_STACK_API_URL = process.env.LOCAL_STACK_API_URL || API_URL;
|
|
|
|
export default defineConfig({
|
|
testDir: './e2e/local-stack',
|
|
// Every test creates its own user, and fake-worker knobs are per user, so
|
|
// tests are independent. One worker keeps the Next dev server's first-compile
|
|
// cost from timing out parallel tests; raise it once the pages are warm.
|
|
fullyParallel: true,
|
|
workers: process.env.LOCAL_STACK_WORKERS ? Number(process.env.LOCAL_STACK_WORKERS) : 1,
|
|
forbidOnly: !!process.env.CI,
|
|
retries: process.env.CI ? 1 : 0,
|
|
reporter: [['html', { open: 'never', outputFolder: 'playwright-report-local-stack' }], ['list']],
|
|
timeout: 180_000,
|
|
expect: { timeout: 30_000 },
|
|
use: {
|
|
baseURL: WEB_URL,
|
|
trace: 'retain-on-failure',
|
|
screenshot: 'only-on-failure',
|
|
video: 'retain-on-failure',
|
|
actionTimeout: 30_000,
|
|
},
|
|
projects: [{ name: 'chromium', use: { ...devices['Desktop Chrome'] } }],
|
|
webServer: [
|
|
{
|
|
command: '../scripts/local-stack.sh serve',
|
|
url: `${API_URL}/api/test/status`,
|
|
reuseExistingServer: !process.env.CI,
|
|
timeout: 180_000,
|
|
},
|
|
{
|
|
command: `npx next dev -p ${WEB_PORT} -H 127.0.0.1`,
|
|
url: WEB_URL,
|
|
reuseExistingServer: !process.env.CI,
|
|
timeout: 180_000,
|
|
env: { BACKEND_URL: API_URL },
|
|
},
|
|
],
|
|
});
|