Skip to content

Commit 5cc5a37

Browse files
test(webview): use the real VS Code toolkit in Playwright visual baselines (#2163)
* test(webview): render the real VS Code toolkit in every gallery story The gallery vite config resolved @vscode/webview-ui-toolkit/react to the Vitest mock for every story except realToolkitImporters (only the Ollama story). The mock draws a plain input with the label after the field, so baselines showing toolkit components did not look like the extension, which renders the real custom elements with the label above the field, padding, and borders. Drop the playwright-gallery-toolkit-mock plugin so every story imports the real toolkit, and keep pre-bundling it via optimizeDeps.include so a cold Vite cache does not re-optimize and reload mid-test. The Vitest mock stays in place for unit tests. * test(webview): regenerate toolkit baselines from the pinned container Baselines for the nine stories that render toolkit components, captured by the pinned mcr.microsoft.com/playwright:v1.62.1-noble container via the Visual Regression workflow: auto-approve settings, Bedrock custom ARN, empty history, IO Intelligence, OpenAI-compatible Azure guidance and extra body, telemetry banner, terminal settings, and UI settings. The real toolkit draws text-field labels above their inputs and gives checkboxes, textareas, links, and buttons the extension's borders and padding, so these baselines now match what users see. --------- Co-authored-by: Roomote <[email protected]>
1 parent 64908ab commit 5cc5a37

27 files changed

Lines changed: 3 additions & 17 deletions

‎webview-ui/playwright/vite.config.ts‎

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,6 @@ const rooCodeTypesShimImporters = [
1515
"/webview-ui/src/components/settings/UISettings.tsx",
1616
]
1717

18-
// Every story gets the Vitest toolkit mock, which draws a text field's label
19-
// below its input. These importers get the real toolkit so the story looks
20-
// like the extension. Add an importer here only with its own baseline.
21-
const realToolkitImporters = ["/settings/providers/Ollama.tsx"]
22-
const toolkitMock = path.resolve(webviewRoot, "src/__mocks__/@vscode/webview-ui-toolkit/react.tsx")
23-
2418
export default defineConfig({
2519
root: path.resolve(dirname, "gallery"),
2620
plugins: [
@@ -37,15 +31,6 @@ export default defineConfig({
3731
}
3832
},
3933
},
40-
{
41-
name: "playwright-gallery-toolkit-mock",
42-
enforce: "pre",
43-
resolveId(source, importer) {
44-
if (source !== "@vscode/webview-ui-toolkit/react") return
45-
if (importer && realToolkitImporters.some((suffix) => importer.endsWith(suffix))) return
46-
return toolkitMock
47-
},
48-
},
4934
react({
5035
babel: {
5136
plugins: [["babel-plugin-react-compiler", { target: "18" }]],
@@ -82,8 +67,9 @@ export default defineConfig({
8267
"process.env.PKG_RELEASE_CHANNEL": JSON.stringify("stable"),
8368
},
8469
optimizeDeps: {
85-
// Pre-bundle the real toolkit (see realToolkitImporters). If Vite finds it
86-
// during the first page load, it re-optimizes and reloads mid-test.
70+
// Pre-bundle the real toolkit: every story now renders the same toolkit
71+
// custom elements the extension uses. If Vite finds it during the first
72+
// page load, it re-optimizes and reloads mid-test.
8773
include: ["@vscode/webview-ui-toolkit/react"],
8874
exclude: ["@vscode/codicons"],
8975
},
465 Bytes
Loading
-281 Bytes
Loading
-338 Bytes
Loading
-414 Bytes
Loading
-364 Bytes
Loading
3.57 KB
Loading
3.55 KB
Loading
2.62 KB
Loading
3.53 KB
Loading

0 commit comments

Comments
 (0)