Fix failing performance and unit tests
CI Pipeline / test (18) (pull_request) Failing after 3m29s
CI Pipeline / test (20) (pull_request) Failing after 4m23s
CI Pipeline / e2e (chromium) (pull_request) Successful in 3m0s
CI Pipeline / e2e (firefox) (pull_request) Successful in 5m45s
CI Pipeline / e2e (webkit) (pull_request) Successful in 4m22s
CI Pipeline / performance (pull_request) Successful in 4m0s
CI Pipeline / storybook (pull_request) Successful in 1m20s
CI Pipeline / visual-regression (pull_request) Successful in 6m7s
CI Pipeline / build (pull_request) Successful in 1m33s
CI Pipeline / test (18) (pull_request) Failing after 3m29s
CI Pipeline / test (20) (pull_request) Failing after 4m23s
CI Pipeline / e2e (chromium) (pull_request) Successful in 3m0s
CI Pipeline / e2e (firefox) (pull_request) Successful in 5m45s
CI Pipeline / e2e (webkit) (pull_request) Successful in 4m22s
CI Pipeline / performance (pull_request) Successful in 4m0s
CI Pipeline / storybook (pull_request) Successful in 1m20s
CI Pipeline / visual-regression (pull_request) Successful in 6m7s
CI Pipeline / build (pull_request) Successful in 1m33s
This commit is contained in:
@@ -42,6 +42,38 @@ vi.mock("next/dynamic", () => {
|
||||
};
|
||||
});
|
||||
|
||||
// Mock window.matchMedia for media query tests
|
||||
Object.defineProperty(window, "matchMedia", {
|
||||
writable: true,
|
||||
value: vi.fn().mockImplementation((query: string) => {
|
||||
// Parse the media query to determine if it matches
|
||||
const minWidthMatch = query.match(/min-width:\s*(\d+)px/);
|
||||
const maxWidthMatch = query.match(/max-width:\s*(\d+)px/);
|
||||
|
||||
// Use window.innerWidth if set by tests, otherwise default to desktop (1200px)
|
||||
// This allows tests to override viewport width by setting window.innerWidth
|
||||
const viewportWidth = (typeof window !== "undefined" && window.innerWidth) || 1200;
|
||||
let matches = true;
|
||||
|
||||
if (minWidthMatch) {
|
||||
matches = viewportWidth >= parseInt(minWidthMatch[1], 10);
|
||||
} else if (maxWidthMatch) {
|
||||
matches = viewportWidth <= parseInt(maxWidthMatch[1], 10);
|
||||
}
|
||||
|
||||
return {
|
||||
matches,
|
||||
media: query,
|
||||
onchange: null,
|
||||
addListener: vi.fn(), // deprecated
|
||||
removeListener: vi.fn(), // deprecated
|
||||
addEventListener: vi.fn(),
|
||||
removeEventListener: vi.fn(),
|
||||
dispatchEvent: vi.fn(),
|
||||
};
|
||||
}),
|
||||
});
|
||||
|
||||
// MSW for API integration tests (mock fetch)
|
||||
beforeAll(() => server.listen({ onUnhandledRequest: "bypass" }));
|
||||
afterEach(() => {
|
||||
|
||||
Reference in New Issue
Block a user