From 80c478c7e4eab88f7939c08ecfd2177326438238 Mon Sep 17 00:00:00 2001 From: Danny Avila Date: Tue, 5 May 2026 12:47:35 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=AA=20fix:=20stub=20`useAttachmentPrev?= =?UTF-8?q?iewSync`=20in=20pre-existing=20Attachment=20test=20mocks?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The new `useAttachmentPreviewSync` hook is called unconditionally inside `FileAttachment` (added in the prior commit). Two pre-existing test files mock `~/hooks` to provide `useLocalize` only — the un-mocked preview hook reference resolved to undefined and crashed render with `(0 , _hooks.useAttachmentPreviewSync) is not a function` on the Ubuntu/Windows CI runners. Fix is local to the test mocks: add a no-op stub that returns `{ status: 'ready' }` so the component renders the legacy chip path. The two-phase preview behavior itself has its own dedicated suites (`useAttachmentHandler.spec.tsx`, `useAttachmentPreviewSync.spec.tsx`). --- .../Content/Parts/__tests__/ArtifactRouting.test.tsx | 5 +++++ .../Messages/Content/Parts/__tests__/TextAttachment.test.tsx | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/client/src/components/Chat/Messages/Content/Parts/__tests__/ArtifactRouting.test.tsx b/client/src/components/Chat/Messages/Content/Parts/__tests__/ArtifactRouting.test.tsx index 4b6c93ae92..305c117532 100644 --- a/client/src/components/Chat/Messages/Content/Parts/__tests__/ArtifactRouting.test.tsx +++ b/client/src/components/Chat/Messages/Content/Parts/__tests__/ArtifactRouting.test.tsx @@ -11,6 +11,11 @@ jest.mock('~/hooks', () => ({ () => (key: string): string => key, + /* `FileAttachment` calls this hook unconditionally to bridge the + * two-phase preview lifecycle into the attachment cache. The + * routing tests don't exercise the preview flow itself — stub it + * to a no-op so it doesn't blow up jsdom rendering. */ + useAttachmentPreviewSync: () => ({ status: 'ready', previewError: undefined, isPolling: false }), })); jest.mock('../LogLink', () => ({ diff --git a/client/src/components/Chat/Messages/Content/Parts/__tests__/TextAttachment.test.tsx b/client/src/components/Chat/Messages/Content/Parts/__tests__/TextAttachment.test.tsx index c5a8369796..fcadf31005 100644 --- a/client/src/components/Chat/Messages/Content/Parts/__tests__/TextAttachment.test.tsx +++ b/client/src/components/Chat/Messages/Content/Parts/__tests__/TextAttachment.test.tsx @@ -13,6 +13,10 @@ jest.mock('~/hooks', () => ({ }; return translations[key] ?? key; }, + /* `FileAttachment` calls this hook unconditionally to bridge the + * two-phase preview lifecycle. Stub to a no-op for tests that + * don't exercise the preview flow. */ + useAttachmentPreviewSync: () => ({ status: 'ready', previewError: undefined, isPolling: false }), })); const mockHandleDownload = jest.fn();