Stub geolocation + matchMedia in OB start-page integration test (P2 regression fix)

This commit is contained in:
2026-04-21 19:35:39 +03:00
parent 5362d8d6c4
commit 268205fc2f
@@ -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", () => {