Skip to content

Commit 1ceb4e6

Browse files
authored
test(webview): add Playwright visual regression harness (#526)
* test(webview): add visual regression harness * fix(webview): resolve relative compose path & font race in visual tests * test(webview): configure Codecov JSDOM coverage ratcheting * feat(webview): add Playwright CT coverage ratcheting * fix(webview): swap visual regression target off deprecated toolkit * chore(webview): address CodeRabbit review feedback * fix(webview): emit Playwright CT coverage LCOV * fix(webview): address code review feedback for Playwright CT harness * docs: prefer committed visual snapshots; split videos into their own lane * revert(RooHero): removing on hover test - can't make it deterministic
1 parent 66120b4 commit 1ceb4e6

20 files changed

Lines changed: 870 additions & 12 deletions

.github/pull_request_template.md

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,35 @@ Detail the steps to test your changes. This helps reviewers verify your work.
3838
- [ ] **Scope**: My changes are focused on the linked issue (one major feature/fix per PR).
3939
- [ ] **Self-Review**: I have performed a thorough self-review of my code.
4040
- [ ] **Testing**: New and/or updated tests have been added to cover my changes (if applicable).
41+
- [ ] **Visual Snapshot** (UI changes only): If a user would notice this change at a glance (layout, theme tokens, brand elements, empty/error states), I've added or updated a `*.visual.tsx` snapshot in `webview-ui/`. See `webview-ui/AGENTS.md` → "When a UI change needs a snapshot".
4142
- [ ] **Documentation Impact**: I have considered if my changes require documentation updates (see "Documentation Updates" section below).
4243
- [ ] **Contribution Guidelines**: I have read and agree to the [Contributor Guidelines](/CONTRIBUTING.md).
4344

44-
### Screenshots / Videos
45+
### Visual Snapshots
4546

4647
<!--
47-
For UI changes, please provide before-and-after screenshots or a short video of the *actual results*.
48-
This greatly helps in understanding the visual impact of your changes.
48+
For UI changes to static rendered state, the primary artifact is a committed
49+
Playwright CT snapshot (`*.visual.tsx` in `webview-ui/`) — that baseline
50+
becomes durable regression coverage for the surface. See
51+
`webview-ui/AGENTS.md` for what deserves a snapshot.
52+
53+
Before/after screenshots pasted here are welcome as a review aid but are not a
54+
substitute for the committed baseline. If a snapshot is possible, prefer the
55+
snapshot.
56+
-->
57+
58+
### Videos (interaction / animation only)
59+
60+
<!--
61+
Snapshots cannot capture motion or multi-step flows. Attach a short screen
62+
recording here when reviewers need to see:
63+
- A new interactive flow (dropdown, form, dialog progression)
64+
- Animation, transition, or timing behavior
65+
- A regression that only manifests during interaction
66+
67+
Videos are a review aid, not regression coverage. If the *result* of the
68+
interaction has a distinct rendered state worth protecting, still commit a
69+
`*.visual.tsx` snapshot of that end-state alongside the video.
4970
-->
5071

5172
### Documentation Updates

.github/workflows/code-qa.yml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,25 +135,32 @@ jobs:
135135
# lanes for behavioral confidence, but duplicating coverage uploads
136136
# there mostly adds Codecov overhead without changing pass/fail
137137
# behavior.
138-
# Coverage is uploaded in three separate steps so each LCOV gets the
138+
# Coverage is uploaded in separate steps so each LCOV gets the
139139
# correct flag set. Codecov double-counts overlapping lines when a
140140
# single upload carries multiple flags whose paths overlap, so the
141-
# two core lanes (which both cover packages/core/src/**) must be
142-
# uploaded individually with their own lane flag.
141+
# core lanes and webview lane must be uploaded individually with
142+
# their own flag.
143143
# See https://docs.codecov.com/docs/flags
144144
- name: Upload non-core coverage to Codecov
145145
if: matrix.upload-coverage
146146
uses: codecov/codecov-action@b9fd7d16f6d7d1b5d2bec1a2887e65ceed900238 # v4
147147
with:
148148
files: >-
149149
src/coverage/lcov.info,
150-
webview-ui/coverage/lcov.info,
151150
packages/cloud/coverage/lcov.info,
152151
packages/telemetry/coverage/lcov.info,
153152
apps/cli/coverage/lcov.info
154153
disable_search: true
155154
flags: ${{ matrix.codecov-flag }}
156155
token: ${{ secrets.CODECOV_TOKEN }}
156+
- name: Upload webview JSDOM coverage to Codecov
157+
if: matrix.upload-coverage
158+
uses: codecov/codecov-action@b9fd7d16f6d7d1b5d2bec1a2887e65ceed900238 # v4
159+
with:
160+
files: webview-ui/coverage/lcov.info
161+
disable_search: true
162+
flags: webview-ui
163+
token: ${{ secrets.CODECOV_TOKEN }}
157164
- name: Upload core unit coverage to Codecov
158165
if: matrix.upload-coverage
159166
uses: codecov/codecov-action@b9fd7d16f6d7d1b5d2bec1a2887e65ceed900238 # v4
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Webview Visual Regression
2+
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
types: [opened, reopened, ready_for_review, synchronize]
7+
paths:
8+
- "webview-ui/**"
9+
- "src/shared/**"
10+
- "package.json"
11+
- "pnpm-lock.yaml"
12+
- ".github/workflows/visual-regression.yml"
13+
merge_group:
14+
types: [checks_requested]
15+
16+
concurrency:
17+
group: ${{ github.workflow }}-${{ github.ref }}
18+
cancel-in-progress: true
19+
20+
permissions:
21+
contents: read
22+
23+
jobs:
24+
webview-visual:
25+
runs-on: ubuntu-latest
26+
timeout-minutes: 10
27+
container:
28+
image: mcr.microsoft.com/playwright:v1.60.0-noble@sha256:9bd26ad900bb5e0f4dee75839e957a89ae89c2b7ab1e76050e559790e946b948
29+
options: --ipc=host
30+
steps:
31+
- name: Checkout code
32+
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
33+
with:
34+
persist-credentials: false
35+
- name: Setup Node.js and pnpm
36+
uses: ./.github/actions/setup-node-pnpm
37+
with:
38+
install-args: "--frozen-lockfile"
39+
- name: Run webview visual tests
40+
run: pnpm --filter @roo-code/vscode-webview test:visual
41+
- name: Upload visual test coverage to Codecov
42+
if: always()
43+
uses: codecov/codecov-action@b9fd7d16f6d7d1b5d2bec1a2887e65ceed900238 # v4
44+
with:
45+
files: webview-ui/coverage-ct/lcov.info
46+
disable_search: true
47+
flags: webview-ui-ct
48+
token: ${{ secrets.CODECOV_TOKEN }}
49+
- name: Upload visual test artifacts
50+
if: failure()
51+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
52+
with:
53+
name: webview-visual-regression
54+
path: |
55+
webview-ui/playwright-report
56+
webview-ui/test-results
57+
if-no-files-found: ignore

codecov.yml

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,33 @@ coverage:
66
default:
77
target: auto # never regress below current baseline
88
threshold: 1%
9+
webview:
10+
target: auto # webview project ratchet: never drop below current baseline
11+
threshold: 0.5%
12+
flags:
13+
- webview-ui
14+
- webview-ui-ct
915
patch:
1016
default:
1117
target: 80% # new lines must be 80% covered
1218
threshold: 0%
19+
webview-patch:
20+
target: 70% # new lines in webview must be 70% covered
21+
threshold: 0%
22+
flags:
23+
- webview-ui
24+
- webview-ui-ct
1325

1426
flag_management:
1527
individual_flags:
28+
- name: webview-ui
29+
paths:
30+
- webview-ui/src/
31+
carryforward: true
32+
- name: webview-ui-ct
33+
paths:
34+
- webview-ui/src/
35+
carryforward: true
1636
- name: core-unit
1737
paths:
1838
- packages/core/src/
@@ -22,6 +42,18 @@ flag_management:
2242
- packages/core/src/
2343
carryforward: true
2444

45+
component_management:
46+
individual_components:
47+
- component_id: webview_components
48+
name: "Webview UI Components"
49+
paths:
50+
- webview-ui/src/components/
51+
- component_id: webview_state
52+
name: "Webview State & Context"
53+
paths:
54+
- webview-ui/src/context/
55+
- webview-ui/src/state/
56+
2557
comment:
26-
layout: "diff, flags"
58+
layout: "diff, flags, components"
2759
behavior: default

knip.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
{
22
"$schema": "https://unpkg.com/knip@5/schema.json",
33
"ignore": ["**/__tests__/**", "apps/vscode-e2e/**", "scripts/**", "apps/cli/scripts/**"],
4-
"ignoreDependencies": ["lint-staged", "ovsx"],
4+
"ignoreDependencies": ["lint-staged"],
55
"ignoreExportsUsedInFile": true,
6+
"playwright": false,
7+
"playwright-ct": false,
68
"workspaces": {
79
"src": {
810
"entry": ["extension.ts", "extension/api.ts", "workers/countTokens.ts"],
@@ -30,7 +32,7 @@
3032
"source-map",
3133
"tailwindcss",
3234
"tailwindcss-animate",
33-
"vscode"
35+
"monocart-reporter"
3436
]
3537
},
3638
"apps/cli": {

0 commit comments

Comments
 (0)