mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-03-16 04:36:34 +01:00
📦 chore: npm audit bump (#12074)
* chore: npm audit - Bumped versions for several packages: `@hono/node-server` to 1.19.10, `@tootallnate/once` to 3.0.1, `hono` to 4.12.5, `serialize-javascript` to 7.0.4, and `svgo` to 2.8.2. - Removed deprecated `@trysound/sax` package from package-lock.json. - Updated integrity hashes and resolved URLs in package-lock.json to reflect the new versions. * chore: update dependencies and package versions - Bumped `jest-environment-jsdom` to version 30.2.0 in both package.json and client/package.json. - Updated related Jest packages to version 30.2.0 in package-lock.json, ensuring compatibility with the latest features and fixes. - Added `svgo` package with version 2.8.2 to package.json for improved SVG optimization. * chore: add @happy-dom/jest-environment and update test files - Added `@happy-dom/jest-environment` version 20.8.3 to `package.json` and `package-lock.json` for improved testing environment. - Updated test files to utilize the new Jest environment, replacing mock implementations of `window.location` with `window.history.replaceState` for better clarity and maintainability. - Refactored tests in `SourcesErrorBoundary`, `useFocusChatEffect`, `AuthContext`, and `StartupLayout` to enhance reliability and reduce complexity.
This commit is contained in:
parent
956f8fb6f0
commit
0ef369af9b
7 changed files with 566 additions and 1208 deletions
|
|
@ -1,3 +1,6 @@
|
|||
/**
|
||||
* @jest-environment @happy-dom/jest-environment
|
||||
*/
|
||||
import React from 'react';
|
||||
import { render, screen, fireEvent } from '@testing-library/react';
|
||||
import '@testing-library/jest-dom';
|
||||
|
|
@ -11,15 +14,6 @@ const ThrowError = ({ shouldThrow }: { shouldThrow: boolean }) => {
|
|||
return <div data-testid="normal-component">{'Normal component'}</div>;
|
||||
};
|
||||
|
||||
// Mock window.location.reload
|
||||
const mockReload = jest.fn();
|
||||
Object.defineProperty(window, 'location', {
|
||||
value: {
|
||||
reload: mockReload,
|
||||
},
|
||||
writable: true,
|
||||
});
|
||||
|
||||
describe('SourcesErrorBoundary - NEW COMPONENT test', () => {
|
||||
beforeEach(() => {
|
||||
jest.clearAllMocks();
|
||||
|
|
@ -53,6 +47,8 @@ describe('SourcesErrorBoundary - NEW COMPONENT test', () => {
|
|||
});
|
||||
|
||||
it('should reload page when refresh button is clicked', () => {
|
||||
const reloadSpy = jest.spyOn(window.location, 'reload').mockImplementation(() => {});
|
||||
|
||||
render(
|
||||
<SourcesErrorBoundary>
|
||||
<ThrowError shouldThrow={true} />
|
||||
|
|
@ -62,6 +58,6 @@ describe('SourcesErrorBoundary - NEW COMPONENT test', () => {
|
|||
const refreshButton = screen.getByRole('button', { name: 'Reload the page' });
|
||||
fireEvent.click(refreshButton);
|
||||
|
||||
expect(mockReload).toHaveBeenCalled();
|
||||
expect(reloadSpy).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue