mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-08-04 14:57:42 +00:00
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:
parent
4679475648
commit
0ea503bb69
1 changed files with 18 additions and 17 deletions
|
|
@ -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 }) => ({
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue