Skip to content

Add comprehensive testing infrastructure#15

Merged
johnpc merged 16 commits into
mainfrom
add-testing-infrastructure
Jun 13, 2026
Merged

Add comprehensive testing infrastructure#15
johnpc merged 16 commits into
mainfrom
add-testing-infrastructure

Conversation

@johnpc

@johnpc johnpc commented Jun 13, 2026

Copy link
Copy Markdown
Owner

Summary

  • Migrate from Jest to Vitest with Istanbul coverage (65% threshold) and CRAP score analysis (threshold 15)
  • Add 966 unit tests across 66 files covering all services, hooks, components, API routes, and utilities
  • Add Playwright + playwright-bdd for Gherkin acceptance tests with queue-management feature
  • Add GitHub Actions CI pipeline enforcing lint, format, coverage, CRAP, build, and acceptance tests
  • Add Husky pre-commit hooks running lint-staged, tests, and build

Test plan

  • CI pipeline runs lint and format checks
  • CI pipeline runs unit tests with coverage thresholds
  • CI pipeline runs CRAP score analysis
  • CI pipeline runs build
  • CI pipeline runs Gherkin acceptance tests
  • Pre-commit hook blocks commits that fail lint/test/build

johnpc added 16 commits June 13, 2026 14:09
Migrate from Jest to Vitest with Istanbul coverage (65% threshold).
Add CRAP score analysis (threshold 15), Playwright + playwright-bdd
for Gherkin acceptance tests, GitHub Actions CI pipeline, and
pre-commit hooks enforcing lint/test/build gates. Write 966 unit
tests across 66 files covering all services, hooks, components,
API routes, and utility functions.
…coverage

- Extract all component logic into custom hooks (useSearchInterface, useTVDisplay,
  useAudioPlayer, useLyricsSync, usePWAInstall, useCacheManager, useWebSocket/)
- Split large components into focused sub-components (<100 lines each)
- Extract pure utility functions for CRAP score reduction
- Add 1372 unit tests across 82 test files (91% coverage)
- Add 7 Gherkin e2e feature files (63 scenarios) including multi-user tests
- CRAP score: 0 violations (784 functions analyzed, all <= 15)
- Coverage: 91% statements, 82% branches, 91% functions, 91% lines
…or e2e

- next lint was removed in Next.js 16; use eslint src/ --quiet instead
- Pass JELLYFIN_SERVER_URL/API_KEY/USERNAME secrets to acceptance tests
- Ignore test-results/ and playwright-report/ from git and prettier
- Remove stale eslint-disable directive
- Regenerate .features-gen from bddgen
…server

Rewrote all Gherkin scenarios and step definitions to work against a real
Jellyfin instance via .env.local credentials. Removed flaky scenarios that
depended on mocked state, fixed WebSocket wait strategies (domcontentloaded
instead of networkidle), and handled the auto-play behavior where songs
become now-playing rather than pending queue items. Also removed Docker
build-and-push from PR triggers (main only).
Next.js reads config from .env.local, not environment variables directly.
In CI, use npm start (production server from prior build step) instead of
npm run dev which was getting killed before compiling. Increased webServer
timeout to 60s.
Multi-user tests need additional work for modal handling in CI. Single-user
project (29 scenarios) covers all core functionality. Removed dead Cypress
npm scripts since the workflow was already deleted.
Includes 5 multi-user scenarios testing shared queue interactions,
real-time WebSocket sync between users, TV display transitions, and
song skip via API. Fixed confirmation dialog blocking by dismissing it
explicitly, and handled auto-play behavior (now-playing vs queue-item).
All 33 acceptance tests pass against real Jellyfin server.
New 'full-playback' Playwright project runs headed (via xvfb in CI) with
real Jellyfin audio streaming. Tests complete song lifecycle: lyrics display,
progress bar advancement, rating animation, next-song splash, and back-to-back
song transitions. Uses Weird Al (index 0) and 3 Doors Down (index 4) for
distinct songs. Added data-testid attributes to PlaybackFooter for progress
bar assertions.
- Add queue cleanup at start of each multi-user scenario to prevent
  state pollution between test runs (verified stable 5/5 runs)
- Show next song title, artist, and singer on the rating/grade screen
- Update RatingAnimation unit tests to match new "Up Next" display
Remote Jellyfin API can be slow from CI runners. Increase assertion
timeouts from default 5s to 15s for search results, artist songs,
and playlist operations.
The default 30s Playwright timeout is too tight when hitting a remote
Jellyfin server from CI. Multi-user tests need extra headroom because
they open 3 browser contexts (Alice, Bob, TV) that each independently
load data from the API.
Root cause of flakiness: clearQueue was passing `queueItemId` but the
API expects `itemId`, so deletions silently failed (400). Also, the
API rejects deletion of currently-playing songs, so we must skip those
first. Added project-level timeouts (60s/90s) as additional headroom.
@johnpc
johnpc merged commit ac6f149 into main Jun 13, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant