import { expect, openFromTree, stubDesktop, test } from "./fixtures"; const FILE = "/dev/acme-api/build.gradle.kts"; test("highlighting level: Configure Current File Analysis switches what the editor highlights", async ({ workbench: page, }) => { const editor = await openFromTree(page, "build.gradle.kts"); await stubDesktop(page); await editor.locator(".cm-line", { hasText: "val order: Order" }).click(); await editor.locator(".cm-content").focus(); await page.evaluate((file) => { window.__ipc.emit({ type: "diagnostics", path: file, source: "kotlin", items: [ { range: { start: { line: 20, col: 19 }, end: { line: 20, col: 24 } }, severity: "error", message: "Unresolved reference: Order", source: "kotlin", code: null, }, ], }); }, FILE); const squiggle = editor.locator(".cm-lintRange-error"); await expect(squiggle).toHaveText("Order", { timeout: 15000 }); const menu = page.getByRole("menu", { name: /^Highlighting Level$/ }); const choose = async (level: string) => { await page.evaluate(async () => { const path = "/src/platform/actions.ts"; const { executeAction } = await import(/* @vite-ignore */ path); await executeAction("editor.highlightingLevel"); }); await menu.getByRole("menuitemcheckbox", { name: level, exact: true }).click(); }; // The chooser starts at IDEA's All Problems. await page.evaluate(async () => { const path = "/src/platform/actions.ts"; const { executeAction } = await import(/* @vite-ignore */ path); await executeAction("editor.highlightingLevel"); }); await expect(menu.getByRole("menuitemcheckbox", { name: "All Problems", exact: true })).toHaveAttribute( "aria-checked", "true", ); await page.keyboard.press("Escape"); // Syntax keeps the colouring and takes the diagnostics out of the editor. await choose("Syntax"); await expect(squiggle).toHaveCount(0); // None also reconfigures the lezer highlighter out: a line without the caret keeps no spans. await choose("None"); await editor.locator(".cm-content").focus(); await page.keyboard.press("ArrowUp"); const plainLine = editor.locator(".cm-content .cm-line").filter({ hasText: "// Paged order lookup" }).first(); await expect(plainLine).toBeVisible(); await expect(plainLine.locator("span")).toHaveCount(0); // Back to All Problems: the squiggle returns without a new diagnostics event. await choose("All Problems"); await expect(squiggle).toHaveText("Order"); });