mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-10-22 10:02:41 +00:00
🧪 fix: stub useAttachmentPreviewSync in pre-existing Attachment test mocks
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`).
This commit is contained in:
parent
ba8a845f34
commit
80c478c7e4
2 changed files with 9 additions and 0 deletions
|
|
@ -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', () => ({
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue