Skip to content

test(gui): add Playwright screenshot harness - #619

Merged
LargeModGames merged 1 commit into
mainfrom
feat/gui-screenshot-harness
Sep 26, 2026
Merged

LargeModGames merged 1 commit into
mainfrom
feat/gui-screenshot-harness

Conversation

@LargeModGames

@LargeModGames LargeModGames commented Sep 26, 2026 •

Copy link
Copy Markdown
Owner

Summary

Adds a Playwright screenshot harness for the browser frontend in gui/, so the GUI screens can be checked as pictures without a Spotify session or a running spotatui.

  • npm run shots builds the page, serves dist with vite preview, and fakes the bridge with page.routeWebSocket. The page code is unchanged.
  • The fake bridge messages in gui/e2e/fixtures.ts are typed with the ts-rs bindings, so a protocol change breaks tsc instead of silently breaking the pictures.
  • Three scenes for now (expired, onboarding, playing), each saved as a 1440x900 PNG per browser in gui/shots/: Chromium, Firefox and WebKit. spotatui-gui opens the user's default browser, and WebKit is the engine a desktop shell uses on Linux and macOS.
  • The GUI workflow installs the three browsers, runs npm run shots and uploads the pictures as the gui-shots artifact.
  • Pictures only: no committed baselines and no pixel diff yet. The screens will change a lot soon, and Windows renders fonts differently from the Linux runner. Baselines can come when the design settles.
  • Spec files use the *.shot.ts name so vitest does not pick them up. AGENTS.md documents the command.

Testing

Run in gui/ on Windows:

> npm run lint
> eslint .

> npm run format:check
All matched files use Prettier code style!

> npm run typecheck
> tsc --noEmit

> npm test
 Test Files  3 passed (3)
      Tests  21 passed (21)

> npm run shots
  ok 1 [firefox] › e2e\scenes.shot.ts:5:1 › expired (1.1s)
  ok 8 [firefox] › e2e\scenes.shot.ts:11:1 › onboarding (602ms)
  ok 9 [firefox] › e2e\scenes.shot.ts:17:1 › playing (614ms)
  9 passed (5.9s)

All nine pictures are 1440x900; I opened the Chromium, Firefox and WebKit ones and they show the page driven by the fake bridge. No Rust code changed; the slim cargo test --no-default-features --features telemetry,tui passed (1263 passed) before the push.

Not run here: the workflow on ubuntu-latest (npx playwright install --with-deps pulls the browsers' system packages there).

Additional notes

The pictures of this PR's CI run are in the gui-shots artifact of the GUI workflow.


💬 Questions or want to chat with other contributors? Join the spotatui Discord.

Summary by CodeRabbit

  • Tests
    • Added automated screenshot checks for expired connections, onboarding, and playback across Chromium, Firefox, and WebKit.
    • CI now saves screenshots as downloadable build artifacts, even if an earlier workflow step fails. The captured screens make it easier to review the GUI’s appearance across supported browsers and spot visual differences in key app states.

@coderabbitai

coderabbitai Bot commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository: LargeModGames/spotatui/.coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: 2b304835-acc4-42a2-ae08-adb7834baa4d

📥 Commits

Reviewing files that changed from the base of the PR and between f83ed1d and a0df7a5.

⛔ Files ignored due to path filters (1)
  • gui/package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (11)
  • .github/workflows/gui.yml
  • .gitignore
  • AGENTS.md
  • gui/.prettierignore
  • gui/e2e/bridge.ts
  • gui/e2e/fixtures.ts
  • gui/e2e/scenes.shot.ts
  • gui/eslint.config.js
  • gui/package.json
  • gui/playwright.config.ts
  • gui/tsconfig.json

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.


📝 Walkthrough

Walkthrough

Adds Playwright screenshot tests for three GUI scenes. The GUI workflow installs the required browsers, runs the tests, and uploads generated screenshots as an artifact.

Changes

GUI Screenshot Testing

Layer / File(s) Summary
Configure Playwright screenshot runs
gui/package.json, gui/playwright.config.ts, gui/tsconfig.json, .gitignore, gui/.prettierignore, gui/eslint.config.js
Adds the Playwright dependency and shots command, configures browser projects and test compilation, and excludes generated screenshot and test output from tooling.
Render and capture GUI scenes
gui/e2e/bridge.ts, gui/e2e/fixtures.ts, gui/e2e/scenes.shot.ts
Adds typed server-message fixtures and helpers to send messages through a routed WebSocket and save screenshots. Tests capture the expired, onboarding, and playing scenes after checking their expected text.
Generate and upload screenshots in CI
.github/workflows/gui.yml, AGENTS.md
The GUI workflow installs browsers, runs screenshot tests, and uploads gui/shots even if an earlier step fails. The instructions describe local screenshot generation and the CI artifact.

Priority: ⬇️ Low

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Other

Sequence Diagram(s)

sequenceDiagram
  participant SceneTests as scenes.shot.ts
  participant BridgeHelper as openWith
  participant GUIPage as GUI page
  participant ScreenshotHelper as shot
  SceneTests->>BridgeHelper: Supply server-message fixtures
  BridgeHelper->>GUIPage: Route WebSocket and send messages
  BridgeHelper->>GUIPage: Navigate to launch-code page
  GUIPage-->>SceneTests: Render expected scene text
  SceneTests->>ScreenshotHelper: Capture scene
  ScreenshotHelper->>GUIPage: Wait for document.fonts.ready
  ScreenshotHelper-->>SceneTests: Save PNG by browser project
Loading

Merge Risk: ⚪ Minimal · up to a0df7

The screenshot harness and CI artifact workflow are ready to merge after normal checks.

Architecture Summary

Architecture risk: 🟡 Medium · up to a0df7

The change affects 2 systems.

Changed systems: gui, AGENTS.md

Architecture concerns
No architecture-level concerns identified.

Review details

Systems and components

  • observed — gui (service) was modified; 8 changed files map to changed impact.
  • observed — AGENTS.md (service) was modified; 1 changed file maps to changed impact.

Before / after behavior

  • observed — Modified behavior in AGENTS.md: Adds instructions for generating GUI screenshots with Playwright, including the one-time browser installation, fake-bridge rendering, PNG output location, and CI artifact name.
  • observed — Modified behavior in gui/.prettierignore: Added shots, test-results, and playwright-report to the Prettier ignore rules.
  • observed — Modified behavior in gui/e2e/bridge.ts: Adds openWith, which sends each supplied ServerMessage over the routed WebSocket in order, then navigates to /#code=shot.
  • observed — Modified behavior in gui/e2e/bridge.ts: Adds shot, which waits for document.fonts.ready before saving a screenshot to shots/<project name>/<name>.png.

Reliability and maintainability

  • inferred — Risk-relevant change factors for gui: blast_radius_1; direct_dependents_1
🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title uses the allowed conventional-commit prefix test:, includes the gui scope, and concisely describes the Playwright screenshot harness added by the pull request.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
✨ Simplify code
  • Commit to this branch
  • Create a new PR

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Sep 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@LargeModGames
LargeModGames merged commit f3b0c7f into main Sep 26, 2026
35 checks passed
@LargeModGames
LargeModGames deleted the feat/gui-screenshot-harness branch September 26, 2026 23:35
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