@devries-cameron20 / t3code-1 / commits / 49582b7b2a
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

test(web): attachment font and large-text preview tests wait for the real load (#26314)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

Julius Marminge committed Oct 27, 2026 at 22:34 UTC 49582b7b2ab2bc8bab51bdc1cc6d07a9937ac278
1 file changed +13
apps/web/src/components/files/AttachmentFilePreview.browser.test.tsx
+13
@@ -51,6 +51,7 @@ import { boundedZip } from "@t3tools/client-runtime/zip/bounded-zip";
51 import BinaryViewer from "./BinaryViewer";
52 import { decodeImagePreview } from "./decodeImagePreview";
53 import type { BinaryWorkerResult } from "./binaryPreviewProtocol";
54 +import type { TextPreviewResult } from "./largeTextProtocol";
55
56 // Real worker imports and WASM initialization can exceed waitFor's default second
57 // when the full browser project runs concurrently on CI.
@@ -462,12 +463,20 @@ describe("large text preview recovery", () => {
463 const original = URL.createObjectURL(new Blob(["original\n".repeat(1000)]));
464 const changed = URL.createObjectURL(new Blob(["changed\n".repeat(1000)]));
465 const workers: Worker[] = [];
466 + const indexed: Promise<void>[] = [];
467 using _worker = stubGlobal(
468 "Worker",
469 class extends Worker {
470 constructor(...args: ConstructorParameters<typeof Worker>) {
471 super(...args);
472 workers.push(this);
473 + indexed.push(
474 + new Promise((resolve) =>
475 + this.addEventListener("message", (event: MessageEvent<TextPreviewResult>) => {
476 + if (event.data.type === "meta" && event.data.complete) resolve();
477 + }),
478 + ),
479 + );
480 }
481 },
482 );
@@ -499,6 +508,8 @@ describe("large text preview recovery", () => {
508 await using screen = await render(preview("first"));
509 await vi.waitFor(() => expect(workers).toHaveLength(1));
510 await vi.waitFor(() => expect(screen.container.textContent).toContain("original"));
511 + // A cold worker can take longer than waitFor allows to load and index on CI.
512 + await indexed[0];
513 await vi.waitFor(() => expect(screen.container.textContent).toContain("1,000 lines"));
514 const viewport = screen.container.querySelector<HTMLElement>('[tabindex="0"]')!;
515 await act(() =>
@@ -2273,6 +2284,8 @@ it("loads a font attachment through the lazy preview", async () => {
2284 const { default: fontUrl } =
2285 await import("../../../node_modules/@betteroffice/fonts/assets/Carlito-Regular.ttf?url");
2286 const file = await (await fetch(fontUrl)).blob();
2287 + // Both lazy chunks can take longer than waitFor allows to load cold on CI.
2288 + await Promise.all([import("./FontFilePreview"), import("./FontViewer")]);
2289 await using screen = await render(
2290 <AttachmentFilePreview
2291 name="Carlito.ttf"