Skip to content
TypeScript

test(web): fix flaky attachment preview and ACP search tests (#21893)

Julius Marmingef740a97947cc
diff --git a/apps/web/src/components/files/AttachmentFilePreview.browser.test.tsx b/apps/web/src/components/files/AttachmentFilePreview.browser.test.tsx
index 14a24dbc9c6..1f3f1742ac2 100644
--- a/apps/web/src/components/files/AttachmentFilePreview.browser.test.tsx
+++ b/apps/web/src/components/files/AttachmentFilePreview.browser.test.tsx
@@ -10,8 +10,8 @@ vi.mock(import("~/assets/assetUrls"), async (original) => ({
useAssetUrlRefresh: () => refresh,
}));
// The real source view highlights through a worker pool; the text it receives is what matters here.
-vi.mock(import("./ReadOnlySourcePreview"), async (original) => ({
- ...(await original()),
+// Never load the original: its highlighter graph can outlast waitFor on a cold CI browser.
+vi.mock(import("./ReadOnlySourcePreview"), () => ({
default: ({ text }: { text: string }) => <pre>{text}</pre>,
}));
diff --git a/apps/web/src/components/settings/AcpRegistrySearchStep.browser.test.tsx b/apps/web/src/components/settings/AcpRegistrySearchStep.browser.test.tsx
index c4e3acf4a92..095ef3864c8 100644
--- a/apps/web/src/components/settings/AcpRegistrySearchStep.browser.test.tsx
+++ b/apps/web/src/components/settings/AcpRegistrySearchStep.browser.test.tsx
@@ -163,6 +163,8 @@ it("shows the loading, error, and empty states", async () => {
it("submits a typed query at once and refreshes when the same query is submitted again", async () => {
await render();
+ // A slow runner must not let the typing debounce submit the query before Enter does.
+ vi.useFakeTimers({ toFake: ["setTimeout", "clearTimeout"] });
await userEvent.fill(searchBox(), "Codex");
await userEvent.keyboard("{Enter}");
expect(lastQuery()).toBe("Codex");