Files
karaoke-gen/frontend/e2e/fixtures
Andrew Beveridge ☄️andClaude Opus 4.6 221f26b0d8 UX overhaul: guidance & simplification across all 4 review stages (#421)
## Summary

Complete UX overhaul of the karaoke video generation review flow,
spanning 4 phases:

- **Phase 1 - Job Creation**: Guided audio source selection with 3-tier
confidence system, responsive stepper, renamed "Find Audio" to "Choose
Audio"
- **Phase 2 - Audio Selection**: Production E2E tests for guided job
creation flow
- **Phase 3 - Lyrics Review**: Guidance panel with workflow steps, gap
navigation scoped to visible lines, simplified review UI with edit
tracking and low-friction feedback
- **Phase 4 - Instrumental Review**: Responsive layout (waveform no
longer disappears on short viewports), canvas-rendered time ruler,
hover-to-highlight waveform regions, dedicated Alternate Instrumental
upload section with duration explanation, dismissable guidance panel

### Key changes
- Root layout switches from viewport-locked (`h-screen overflow-hidden`)
to scrollable (`min-h-screen`) — fixes waveform disappearing on short
viewports
- Bottom section stacks vertically on mobile/tablet, side-by-side on
desktop
- Time ruler rendered directly on canvas with auto-scaling tick
intervals
- Hovering mute region or segment buttons highlights the corresponding
waveform range
- Upload button moved from toolbar to dedicated section with context and
duration requirement
- 21 unit tests added for instrumental review components
- Guidance panels with dismissable tips across lyrics and instrumental
review

## Test plan
- [x] `npx next build` — no errors
- [x] `npx jest --testPathPattern="instrumental-review/__tests__"` —
21/21 pass
- [x] Visual testing at 4 viewports: desktop (1280x800), tablet
(768x1024), mobile (375x667), short (1280x400)
- [x] Hover highlight verified with Playwright MCP
- [x] Time ruler scales correctly at 1x and 2x zoom

@coderabbitai ignore

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-01 02:58:50 -05:00
..

API Fixtures for E2E Testing

This module provides tools for recording and replaying API fixtures to enable deterministic E2E testing without requiring a running backend.

Overview

The fixture system has two modes:

  1. Recording Mode: Intercepts real API calls during test runs and saves them for review
  2. Mock Mode: Replays approved fixtures instead of making real API calls

Workflow

Step 1: Record API Responses

Run E2E tests in recording mode to capture real API responses:

cd frontend
npm run test:e2e:record

This will:

  • Run all E2E tests against the real backend
  • Intercept and save all API calls to e2e/fixtures/data/recordings/
  • Each session creates a new JSON file with all captured requests

Step 2: Review and Approve Fixtures

Review each captured fixture before approving it:

npm run fixtures:review

The review CLI will:

  • Show each captured request/response pair
  • Let you approve, skip, or edit each fixture
  • Save approved fixtures to e2e/fixtures/data/approved/

For each fixture, you can:

  • Approve (a): Save the fixture as-is
  • Edit (e): Add a description or notes before approving
  • Skip (s): Don't save this fixture
  • Quit (q): Exit the review session

Step 3: Use Fixtures in Tests

Once you have approved fixtures, update your tests to use them:

import { test, expect } from '@playwright/test';
import { setupApiFixtures } from './fixtures';

test('shows job list', async ({ page }) => {
  // Set up mock server with approved fixtures
  const api = await setupApiFixtures(page, {
    useApprovedFixtures: true,
  });

  await page.goto('/');

  // Test runs against mock data - no real backend needed
  await expect(page.getByText('My Jobs')).toBeVisible();

  // Verify all requests were handled
  api.assertAllHandled();
});

Test Helper API

setupApiFixtures(page, options)

Main function for setting up API fixtures in a test.

Options:

  • fixtureSet?: string - Load a named fixture set from data/sets/
  • useApprovedFixtures?: boolean - Load all approved fixtures from data/approved/
  • mocks?: Array<{method, path, response}> - Add inline mock responses
  • testFile?: string - Test file name (used in recording mode)

Returns: ApiTestContext with:

  • isRecording: boolean - Whether in recording mode
  • assertAllHandled() - Throws if any requests weren't mocked
  • getUnmatchedRequests() - Returns list of unhandled requests
  • stopRecording() - Stop recording and return captured fixtures

Convenience Functions

// Quick inline mocks
await setupMocks(page, [
  { method: 'GET', path: '/api/v1/jobs', response: { body: [] } },
]);

// Pre-configured scenarios
await setupAuthenticatedUser(page);
await setupUnauthenticatedUser(page);

// Auth helpers
await setAuthToken(page, 'my-token');
await clearAuthToken(page);

Directory Structure

e2e/fixtures/
├── data/
│   ├── recordings/     # Temporary recording sessions (gitignored content)
│   ├── approved/       # Approved fixtures (committed to repo)
│   └── sets/           # Named fixture sets for specific scenarios
├── types.ts            # TypeScript interfaces
├── recorder.ts         # Recording logic
├── mock-server.ts      # Mock server logic
├── test-helper.ts      # Test utilities
├── review-cli.ts       # CLI for reviewing fixtures
└── index.ts            # Module exports

Fixture Format

Each approved fixture is a JSON file:

{
  "id": "get-api-v1-jobs",
  "description": "GET /api/v1/jobs - List all jobs",
  "capturedAt": "2024-01-15T10:30:00.000Z",
  "request": {
    "method": "GET",
    "url": "http://localhost:8000/api/v1/jobs",
    "path": "/api/v1/jobs",
    "headers": { "authorization": "[REDACTED]" }
  },
  "response": {
    "status": 200,
    "statusText": "OK",
    "body": []
  },
  "reviewed": true,
  "reviewNotes": "Empty job list for new user"
}

Best Practices

  1. Review every fixture: Don't blindly approve all recordings. Check that responses are correct and don't contain sensitive data.

  2. Add descriptions: Edit fixtures to add meaningful descriptions that explain what scenario the fixture represents.

  3. Keep fixtures minimal: Only approve the fixtures you actually need for tests. Don't capture unnecessary API calls.

  4. Update fixtures when API changes: If the backend API changes, re-record and review fixtures to ensure tests use correct data.

  5. Use fixture sets for scenarios: Group related fixtures into sets for complex test scenarios (e.g., "user-with-jobs", "empty-state").

Environment Variables

  • RECORD_FIXTURES=true - Enable recording mode
  • NEXT_PUBLIC_API_URL - Backend API URL (default: http://localhost:8000)