From 0ea503bb699790a391d139e9b7e060676cf887fb Mon Sep 17 00:00:00 2001 From: Marco Beretta <81851188+berry-13@users.noreply.github.com> Date: Sun, 2 Aug 2026 19:52:14 +0200 Subject: [PATCH] fix: mock the client package normally so the upload dialog stub holds `{ virtual: true }` is for modules with no file on disk, and `@librechat/client` is a real workspace package. Registering a real module virtually let resolution fall through to the package itself often enough to fail roughly one full-suite run in three: the dialog then rendered through its Radix portal, putting the file input outside the container the helper read, and `useToastContext` handed back the real context so the size-rejection assertion watched a spy nothing called. Both symptoms were the same mock going missing. Drop the flag and read the input from the document, which stays correct whether or not the stub is the module that resolves. Eight consecutive full runs clean. --- .../__tests__/UploadSkillDialog.spec.tsx | 35 ++++++++++--------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/client/src/components/Skills/dialogs/__tests__/UploadSkillDialog.spec.tsx b/client/src/components/Skills/dialogs/__tests__/UploadSkillDialog.spec.tsx index b9c4236b4f..9de03ed088 100644 --- a/client/src/components/Skills/dialogs/__tests__/UploadSkillDialog.spec.tsx +++ b/client/src/components/Skills/dialogs/__tests__/UploadSkillDialog.spec.tsx @@ -21,23 +21,24 @@ jest.mock('react-router-dom', () => ({ useNavigate: () => mockNavigate, })); -jest.mock( - '@librechat/client', - () => { - const React = jest.requireActual('react'); - return { - OGDialog: ({ open, children }: { open: boolean; children: ReactNode }) => - open ? React.createElement('div', null, children) : null, - OGDialogContent: ({ children }: { children: ReactNode }) => - React.createElement('div', null, children), - Spinner: () => React.createElement('div', { 'data-testid': 'spinner' }), - useToastContext: () => ({ - showToast: mockShowToast, - }), - }; - }, - { virtual: true }, -); +/* Not `{ virtual: true }`: that option is for modules with no file on disk, and + `@librechat/client` is a real workspace package. Registering a real module + virtually let resolution fall through to the package itself, which rendered + the dialog through its Radix portal and handed back the real toast context — + so the file input escaped the container and `showToast` was never the spy. */ +jest.mock('@librechat/client', () => { + const React = jest.requireActual('react'); + return { + OGDialog: ({ open, children }: { open: boolean; children: ReactNode }) => + open ? React.createElement('div', null, children) : null, + OGDialogContent: ({ children }: { children: ReactNode }) => + React.createElement('div', null, children), + Spinner: () => React.createElement('div', { 'data-testid': 'spinner' }), + useToastContext: () => ({ + showToast: mockShowToast, + }), + }; +}); jest.mock('~/data-provider', () => ({ useGetFileConfig: ({ select }: { select?: (data: FileConfigInput | undefined) => unknown }) => ({