Skip to content

Add Playwright e2e coverage for the webview editors - #102

Merged
Frotty merged 2 commits into
masterfrom
playwright-e2e-coverage
Aug 18, 2026
Merged

Add Playwright e2e coverage for the webview editors#102
Frotty merged 2 commits into
masterfrom
playwright-e2e-coverage

Conversation

@Frotty

@Frotty Frotty commented Aug 17, 2026

Copy link
Copy Markdown
Member

Adds a browser-level test tier so the webview editors have real regression cover, and ports the three local-only CDP scripts onto the same framework.

New tier: npm run test:e2e — 56 specs, ~39s

Runs the real webview bundles in real Chromium against the real host code, with only vscode itself faked. No VS Code launch, no Warcraft III install.

Spec Covers
objmod-browse (8) tree grouping, search + match count + clear, rawcode search, selection follow-through, reload persistence (selection / query / density / collapsed branches / scroll)
objmod-fields (11) technical columns, hide-empty / modified-only / category / field filters, int + unreal steppers, edit → dirty → undo/redo → save → re-parsed bytes, Ctrl+S committing a focused editor, rawcode jump chips
objmod-tooltip-editor (11) rich ↔ raw toggle, live used-colour swatches, escaped-pipe handling, preset/used swatch application, custom-colour persistence to globalState, Escape revert, colour markup written on save
objmod-layout (8) splitter keyboard/drag + ARIA range, narrow-layout flip both ways, density scale, objModTooltipWidth clamping, no horizontal page scroll at four widths
w3i-editor (9) TRIGSTR vs inline routing, opaque tail byte-identical after save, flags, tileset, no-op edits
wpm-editor (9) paint / erase / drag as one undo step, Alt+click brush pick, canvas pixels cross-checked against document bytes, save round-trip

Design notes:

  • The harness mounts the actual CustomEditorProvider on a fake panel, so openCustomDocumentresolveCustomEditorbuildHtml → message handler → edit stack → saveCustomDocument are the shipping paths, not reimplementations.
  • The page is served over http with webview.cspSource pointed at that origin, so the shipped CSP has to genuinely admit what the page loads — a CSP regression fails the suite.
  • tsLoader reports __dirname as <root>/dist for anything under src/, matching webpack's output. That is what makes resources/wc3-knowledge-base.json resolve, so field rows exist without a compiler or WC3 install.
  • Specs assert on field ids and fixture values, never on game-data labels, which resolve through WorldEditStrings in CASC and differ per machine.

Bug found by the new suite

.dirty-badge { display: inline-block } outranks the user-agent [hidden] rule, so the .w3i editor showed "● unsaved" on clean documents. Fixed, and every other hidden element across the viewers was audited — this was the only one.

Ported local tier: npm run test:e2e:local

connectOverCDP + a frame search replaces ~115KB of hand-rolled DevTools WebSocket, target-tracking and execution-context plumbing; assertions kept. The three old scripts are deleted.

Two latent bugs in that path surfaced while validating the port:

  • A .w3a passed on the command line opened in the text editor, because on a cold --extensionDevelopmentPath start the extension host has not registered its custom editors yet — so no webview was ever created. Fixed by pinning workbench.editorAssociations in the temp profile.
  • bring-to-foreground.ps1 was invoked with the wrong parameter name, so the VS Code window never took focus, Ctrl+C silently no-opped and Ctrl+V pasted stale clipboard content.

Verified against real VS Code: clipboard suite 4/4, CodeLens asset browser passing, thumbnail DOM-order/scheduling passing. The thumbnail render/budget assertions fail locally (stock doodads come back not-found); the pre-port script restored from git fails identically, so that is environmental rather than a port regression.

Also included

  • Saved custom-colour palette for the tooltip editor (persisted in globalState, seeded through the initial payload) and live "used colours" swatches that refresh as the text changes — both covered by the new tooltip specs.
  • scripts/test-webview.js now uses the shared e2e/harness/tsLoader.js instead of its two local copies.
  • Testing tiers documented in AGENTS.md.

CI

Deliberately not wired into build.yml. That job substitutes .ci/mocks/casc-ts, whose parsers all throw, and these tests parse and re-serialize real binary fixtures. Running e2e in CI would need those mocks to gain real parseObjMod / serializeObjMod / parseW3i / serializeW3i / parseWpm / serializeWpm implementations, or a job with access to the real siblings. npm test is unchanged and still passes under the CI mocks.

npm test, npx tsc -p . --noEmit and npm run lint are all clean (one pre-existing webpack warning).

2:
3:Adds a browser-level test tier that runs the real webview bundles in real
4:Chromium against the real host code, with only `vscode` itself faked. 56 specs
5:cover the objmod editor (browse/search/field filters/tooltip editor/layout) and
6:the editable .w3i and .wpm editors, including full edit -> undo/redo -> save ->
7:bytes-on-disk round-trips.
8:
9:The harness mounts the actual CustomEditorProvider on a fake panel, so
10:openCustomDocument, resolveCustomEditor, buildHtml, the message handler, the
11:edit stack and saveCustomDocument are the shipping code paths rather than
12:reimplementations. The page is served over http with webview.cspSource pointed
13:at that origin, so the shipped CSP has to genuinely admit what the page loads.
14:
15:tsLoader reports __dirname as <root>/dist for anything under src/, matching what
16:webpack emits; that is what makes resources/wc3-knowledge-base.json resolve, so
17:field rows are available without a compiler or Warcraft III install.
18:
19:Also ports the three local-only CDP scripts to Playwright. connectOverCDP plus a
20:frame search replaces the hand-rolled DevTools WebSocket client, target tracking
21:and execution-context bookkeeping; the assertions are kept. Two latent bugs in
22:that path surfaced while validating the port: a .w3a passed on the command line
23:opened in the text editor because the extension host had not registered its
24:custom editors yet (now fixed by pinning workbench.editorAssociations in the
25:temp profile), and bring-to-foreground.ps1 was invoked with the wrong parameter
26:name, so Ctrl+C silently no-opped and Ctrl+V pasted stale clipboard content.
27:
28:Fixes a real bug the new suite caught: `.dirty-badge { display: inline-block }`
29:outranks the user-agent [hidden] rule, so the .w3i editor showed "unsaved" on
30:clean documents.
31:
32:Includes the saved custom-colour palette for the tooltip editor (persisted in
33:globalState, seeded through the initial payload) and live "used colours"
34:swatches that refresh as the text changes, both covered by the new tooltip specs.
35:
36:The e2e tier is not wired into build.yml: that job substitutes .ci/mocks/casc-ts,
37:whose parsers all throw, and these tests parse and re-serialize real binary
38:fixtures. `npm test` is unchanged and still passes under the CI mocks.
39:
41:
@Frotty
Frotty force-pushed the playwright-e2e-coverage branch from 4afa4dc to 6c80147 Compare August 17, 2026 17:17

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4afa4dcb70

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/features/objModPreview.ts Outdated
Comment on lines +2628 to +2629
gap: 4px;
padding-top: 2px;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Route the palette spacing through density variables

When the user switches the object editor to cozy density, the new saved-colour section retains these hard-coded compact gap and padding-top values, making this part of the toolbar inconsistent with the rest of the selected density. Define both values in the existing :root/body.density-cozy variable pair and reference those variables here.

AGENTS.md reference: AGENTS.md:L79-L79

Useful? React with 👍 / 👎.

Comment thread package.json Outdated
"watch-web": "webpack --watch",
"test": "npm run test:fuzzy && npm run test:image-decoders && npm run test:diagnostics && npm run test:webview",
"test:e2e": "npm run compile-web && playwright test --project=webview",
"test:e2e:ui": "playwright test --project=webview --ui",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Compile the webview bundles before opening UI mode

On a fresh checkout or after cleaning the ignored dist/ directory, npm run test:e2e:ui opens Playwright without building dist/webview/objModEditorWebview.js, so the object-editor tests immediately fail with the harness's missing-bundle error instead of running interactively. Prefix this script with npm run compile-web, as the non-UI e2e command already does.

AGENTS.md reference: AGENTS.md:L103-L109

Useful? React with 👍 / 👎.

…e UI mode

The saved-colour group in the tooltip colour popover kept hard-coded compact
`gap`/`padding-top`, so it stayed on the compact scale while the rest of the
editor switched to cozy. Both numbers now live in the :root / body.density-cozy
variable pair as --palette-group-gap / --palette-group-pad, per AGENTS.md.

Covered by a new spec that measures the resolved spacing in both densities;
verified it fails against the hard-coded values it replaces.

`test:e2e:ui` now runs compile-web first, like `test:e2e` already did — on a
fresh checkout it otherwise opened Playwright's UI against a missing
dist/webview bundle and every objmod test failed on the harness guard.
@Frotty

Frotty commented Aug 17, 2026

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 635b24c156

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

const frame = await session.waitForFrame(() => !!window.__wurstModelThumbDebug, 'the objmod webview');
await openAssetBrowser(frame);

const { state, initialKeys, violations } = await drainVisibleThumbnails(frame, 90000);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Honor the configured timeout while draining thumbnails

When local WC3 data takes more than 90 seconds to resolve or render, increasing WURST_OBJMOD_E2E_TIMEOUT_MS only extends VS Code startup and frame discovery because this drain still has a fixed 90-second deadline. The migrated harness previously applied that setting throughout the run, so both thumbnail tests now time out despite the user's override; pass the configured timeout into drainVisibleThumbnails instead.

Useful? React with 👍 / 👎.

@Frotty
Frotty merged commit 0cc1614 into master Aug 18, 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