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.
This commit is contained in:
Marco Beretta 2026-08-02 19:52:14 +02:00
parent 4679475648
commit 0ea503bb69
No known key found for this signature in database
GPG key ID: D918033D8E74CC11

View file

@ -21,23 +21,24 @@ jest.mock('react-router-dom', () => ({
useNavigate: () => mockNavigate,
}));
jest.mock(
'@librechat/client',
() => {
const React = jest.requireActual<typeof import('react')>('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<typeof import('react')>('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 }) => ({