From 268205fc2fcdfe4c00ee5ee70aa7f338062a465d Mon Sep 17 00:00:00 2001 From: gnezim Date: Tue, 21 Apr 2026 19:35:39 +0300 Subject: [PATCH] Stub geolocation + matchMedia in OB start-page integration test (P2 regression fix) --- .../online-board/start-page.test.tsx | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tests/integration/online-board/start-page.test.tsx b/tests/integration/online-board/start-page.test.tsx index 11a3cee7..709e9990 100644 --- a/tests/integration/online-board/start-page.test.tsx +++ b/tests/integration/online-board/start-page.test.tsx @@ -65,6 +65,30 @@ vi.mock("@/ui/city-autocomplete/index.js", () => ({ describe("Start page integration", () => { beforeEach(() => { vi.clearAllMocks(); + + // Stub matchMedia for useIsMobileViewport (jsdom doesn't implement it). + Object.defineProperty(window, "matchMedia", { + value: vi.fn().mockImplementation((query: string) => ({ + matches: false, + media: query, + addEventListener: () => {}, + removeEventListener: () => {}, + dispatchEvent: () => false, + })), + configurable: true, + }); + + // Stub geolocation for useGeoCityDefault (jsdom doesn't implement it). + Object.defineProperty(navigator, "geolocation", { + value: { + getCurrentPosition: vi.fn().mockImplementation( + (_s: PositionCallback, onErr: PositionErrorCallback) => { + onErr({ code: 1, message: "denied" } as GeolocationPositionError); + }, + ), + }, + configurable: true, + }); }); it("renders the page layout with data-testid", () => {