Skip to content

Feat/playwright panel screenshots#1279

Draft
acke wants to merge 3 commits into
mainfrom
feat/playwright-panel-screenshots
Draft

Feat/playwright panel screenshots#1279
acke wants to merge 3 commits into
mainfrom
feat/playwright-panel-screenshots

Conversation

@acke

@acke acke commented May 13, 2026

Copy link
Copy Markdown
Contributor

Description

Adds Playwright as an opt-in JS browser test suite alongside the existing node --test suite — and uses it as a visual-regression harness for the seven HTML panels snyk-ls renders.

Two specs:

  • tree-runtime.playwright.spec.mjs — behavior tests for domain/ide/treeview/template/tree.js running in real headless Chromium: IDE placeholder substitution (vscode/intellij/visualStudio/eclipse variants), issue click → __ideExecuteCommand__ bridge call, product row expand/collapse.
  • panel-screenshots.playwright.spec.mjs — visual regression for 7 panels × 4 IDE themes = 28 tests: tree view, config page, code/oss/iac/secrets suggestion, scan summary. Each test renders the real panel HTML, applies that IDE's body bg/fg, screenshots full-page, and compares against committed baselines via expect(page).toHaveScreenshot() (threshold: 0.2, maxDiffPixelRatio: 0.02).

Baselines (js-tests/screenshots/) — 28 Darwin PNGs (~1.1 MB total) committed. Per-platform suffix (<name>-{darwin,linux}.png) so per-OS font rendering doesn't cause false positives. CI Linux baselines need a one-time generation (see README) when wiring this into build.yaml.

scripts/panel-fixtures/main.go — single Go program driven by --panel <name> that builds one canonical example issue/state per panel and renders via the real renderers in infrastructure/{code,oss,iac,secrets} and domain/scanstates. Wired into a panel-fixtures Makefile target consumed by test-js / test-js-browser.

Opt-in: the Playwright suite requires a Chromium download (~150 MB), so it lives behind:

  • make test-js-browser-setup — one-time Chromium install
  • make test-js-browser — run the suite
  • make test-js-all — node tests + Playwright

The default make test path is unchanged. CI is not wired to run the Playwright suite yet — js-tests/README.md includes a sketch for a js-browser-tests job that could be added to .github/workflows/build.yaml.

How to view results: after a run, npx playwright show-report serves an HTML report with each test's full-page screenshot attached.

Checklist

  • Tests added and all succeed (34/34 Playwright tests pass locally on Darwin in ~2.5s)
  • Regenerated mocks, etc. (make generate) — N/A, no Go code that requires generation
  • Linted (make lint-fix) — make test-js (ES5 lint) passes
  • README.md updated, if user-facing — new js-tests/README.md documents setup, run, baseline workflow, and CI sketch
  • License file updated, if new 3rd-party dependency is introduced — @playwright/test added as a js-tests devDependency only, not a runtime dep

Wires Playwright as an opt-in JS browser test suite alongside the existing
node --test suite. Two specs:

- tree-runtime.playwright.spec.mjs: behavior tests for the tree view
  runtime — IDE placeholder substitution, issue click → bridge call,
  product row expand/collapse — exercised in real Chromium against the
  actual domain/ide/treeview/template/tree.js.
- panel-screenshots.playwright.spec.mjs: visual regression for 7 HTML
  panels (tree view, config page, code/oss/iac/secrets suggestion, scan
  summary) × 4 IDE themes (vscode, intellij, visualStudio, eclipse).
  Baselines committed under js-tests/screenshots/ as Darwin PNGs.

scripts/panel-fixtures/main.go is a single Go program driven by --panel
that builds one canonical example issue/state per panel and renders via
the real renderers in infrastructure/{code,oss,iac,secrets} and
domain/scanstates. Wired into a panel-fixtures Makefile target consumed
by test-js / test-js-browser.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@snyk-io

snyk-io Bot commented May 13, 2026

Copy link
Copy Markdown

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues
Code Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@acke acke force-pushed the feat/playwright-panel-screenshots branch from f5780e0 to d20536a Compare May 13, 2026 13:49
…ttern

The viewport screenshot from `screenshot: "on"` already lands in the HTML
report; the explicit testInfo.attach was producing a second, larger PNG
per test. Visual regression continues to compare full-page via
toHaveScreenshot, and failure attachments (actual/expected/diff) still
show full-page. Aligns with reports-ui's playwright setup.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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