Skip to content

feat(desktop): add standalone Playwright screenshot helper#795

Merged
wpfleger96 merged 2 commits into
mainfrom
wpfleger/playwright-screenshot-helper
May 29, 2026
Merged

feat(desktop): add standalone Playwright screenshot helper#795
wpfleger96 merged 2 commits into
mainfrom
wpfleger/playwright-screenshot-helper

Conversation

@wpfleger96
Copy link
Copy Markdown
Collaborator

@wpfleger96 wpfleger96 commented May 29, 2026

Adds desktop/tests/helpers/screenshot.mjs, a CLI-driven headless Chromium script for capturing screenshots of the desktop app UI with the E2E mock bridge pre-injected.

The desktop app requires window.__SPROUT_E2E__ to be injected before any page scripts run (via addInitScript) to mock the Tauri IPC layer. The Playwright MCP browser can only evaluate JS after page load, so it can't drive the app directly. This script wraps the same mock bridge setup from bridge.ts into a standalone tool that agents and developers can invoke without writing boilerplate each time.

  • Replicates installMockBridge setup: workspace seeding, onboarding flags, __SPROUT_E2E__ config, and MockNotification mock
  • Accepts --name, --route, --click, --wait, --viewport, and --outdir flags
  • --click accepts bare data-testid values (e.g. open-search) or full CSS selectors
  • Saves PNGs to test-results/screenshots/ (already gitignored) and prints the path to stdout
  • Documents usage in AGENTS.md so future agent sessions can discover and use it

The desktop app requires the E2E mock bridge (`window.__SPROUT_E2E__`)
injected via `addInitScript` before page scripts run. This makes the
Playwright MCP browser unusable for ad-hoc testing since it can only
evaluate JS after page load. Standalone scripts using the Playwright
API can use `addInitScript`, so this helper wraps the mock bridge
setup from `bridge.ts` into a CLI-driven screenshot tool.

Accepts --name, --route, --click, --wait, --viewport, and --outdir
flags. Bare --click values auto-expand to data-testid selectors.
Future agent sessions need to know about the screenshot helper and
why the Playwright MCP browser can't drive the desktop app directly.
@wpfleger96 wpfleger96 marked this pull request as ready for review May 29, 2026 20:44
@wpfleger96 wpfleger96 requested a review from a team as a code owner May 29, 2026 20:44
@wpfleger96 wpfleger96 merged commit 10f37e4 into main May 29, 2026
15 checks passed
@wpfleger96 wpfleger96 deleted the wpfleger/playwright-screenshot-helper branch May 29, 2026 21:10
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.

2 participants