From e2419115d869897ca38fd718ae0ab654fc05c28b Mon Sep 17 00:00:00 2001 From: Julius Marminge <51714798+juliusmarminge@users.noreply.github.com> Date: Tue, 3 Nov 2026 12:23:40 -0800 Subject: [PATCH] test(web): file editor dismissal test waits for the editor to render The test waited up to vi.waitFor's default 1s for the editor content. On a cold run File paints nothing until the shared highlighter's backend, themes, and TypeScript grammar finish loading, which outlasts that under CI load. Preload the highlighter first; mount then renders synchronously. Co-Authored-By: Claude Opus 5.5 --- .../files/fileEditorDismissal.browser.test.tsx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/apps/web/src/components/files/fileEditorDismissal.browser.test.tsx b/apps/web/src/components/files/fileEditorDismissal.browser.test.tsx index 7f7d6601c68ca..efc7d0fcc82e2 100644 --- a/apps/web/src/components/files/fileEditorDismissal.browser.test.tsx +++ b/apps/web/src/components/files/fileEditorDismissal.browser.test.tsx @@ -1,3 +1,4 @@ +import { DEFAULT_THEMES, preloadHighlighter } from "@pierre/diffs"; import { Editor, type EditorFactory } from "@pierre/diffs/edit"; import { EditProvider, File } from "@pierre/diffs/react"; import { describe, expect, it, vi } from "vite-plus/test"; @@ -12,6 +13,8 @@ describe("installFileEditorDismissal", () => { let editor: Editor<"file" | "file-diff", undefined, undefined> | undefined; const createEditor: EditorFactory = (...args) => (editor = new Editor(...args)); + // File paints nothing until the shared highlighter has loaded; once it has, mount renders synchronously. + await preloadHighlighter({ themes: Object.values(DEFAULT_THEMES), langs: ["typescript"] }); await using screen = await render( <>

Assistant reply

@@ -23,17 +26,14 @@ describe("installFileEditorDismissal", () => { , ); const shadowRoot = () => screen.container.querySelector("diffs-container")?.shadowRoot; - const content = await vi.waitFor(() => { - const element = shadowRoot()?.querySelector("[data-content]"); - expect(element).toBeTruthy(); - return element!; - }); + const content = shadowRoot()?.querySelector("[data-content]"); + expect(content).toBeTruthy(); editor!.setSelections([ { start: { line: 0, character: 8 }, end: { line: 0, character: 8 }, direction: "none" }, ]); const isMac = isMacPlatform(navigator.platform); - content.dispatchEvent( + content!.dispatchEvent( new KeyboardEvent("keydown", { key: "f", code: "KeyF",