Update e2e tests and mocks for locale-based routing
- Adjusted assertions and navigation tests to include `/en` locale prefix for consistency. - Updated next-intl and components-i18n mocks to support locale handling in tests. - Renamed "Components" link and related references to "Design System" in homepage tests. - Disabled typing delay in debounce test for improved test reliability.
This commit is contained in:
5
frontend/tests/__mocks__/components-i18n.tsx
Normal file
5
frontend/tests/__mocks__/components-i18n.tsx
Normal file
@@ -0,0 +1,5 @@
|
||||
/**
|
||||
* Mock for @/components/i18n
|
||||
*/
|
||||
|
||||
export const LocaleSwitcher = () => <div data-testid="locale-switcher">EN</div>;
|
||||
11
frontend/tests/__mocks__/next-intl.tsx
Normal file
11
frontend/tests/__mocks__/next-intl.tsx
Normal file
@@ -0,0 +1,11 @@
|
||||
/**
|
||||
* Mock for next-intl
|
||||
*/
|
||||
|
||||
export const useLocale = jest.fn(() => 'en');
|
||||
export const useTranslations = jest.fn(() => (key: string) => key);
|
||||
export const NextIntlClientProvider = ({ children }: { children: React.ReactNode }) => <>{children}</>;
|
||||
export const useFormatter = jest.fn(() => ({}));
|
||||
export const useMessages = jest.fn(() => ({}));
|
||||
export const useNow = jest.fn(() => new Date());
|
||||
export const useTimeZone = jest.fn(() => 'UTC');
|
||||
@@ -161,14 +161,14 @@ describe('UserListTable', () => {
|
||||
});
|
||||
|
||||
it('calls onSearch after debounce delay', async () => {
|
||||
const user = userEvent.setup();
|
||||
const user = userEvent.setup({ delay: null }); // Disable typing delay for debounce test
|
||||
render(<UserListTable {...defaultProps} />);
|
||||
|
||||
const searchInput = screen.getByPlaceholderText('Search by name or email...');
|
||||
|
||||
await user.type(searchInput, 'alice');
|
||||
|
||||
// Should not call immediately
|
||||
// Should not call immediately (debounce is 300ms)
|
||||
expect(defaultProps.onSearch).not.toHaveBeenCalled();
|
||||
|
||||
// Should call after debounce (300ms)
|
||||
|
||||
Reference in New Issue
Block a user