diff --git a/tests/unit/campaignQuickActionsDrawer.unit.spec.tsx b/tests/unit/campaignQuickActionsDrawer.unit.spec.tsx index 6d36a643..773528d6 100644 --- a/tests/unit/campaignQuickActionsDrawer.unit.spec.tsx +++ b/tests/unit/campaignQuickActionsDrawer.unit.spec.tsx @@ -54,6 +54,12 @@ const searchWithPriorityPayload: HomeSearchSuccessResponse = { const matchMediaMock = vi.fn() +let innerWidthSpy: ReturnType | undefined + +const stubMobileViewport = () => { + innerWidthSpy = vi.spyOn(window, 'innerWidth', 'get').mockReturnValue(375) +} + beforeEach(() => { matchMediaMock.mockImplementation((query: string) => ({ matches: false, @@ -69,6 +75,8 @@ beforeEach(() => { afterEach(() => { cleanup() + innerWidthSpy?.mockRestore() + innerWidthSpy = undefined vi.mocked(postCampaignJson).mockReset() vi.unstubAllGlobals() }) @@ -358,6 +366,7 @@ describe('CampaignQuickActionsOverlay (B126)', () => { }) it('shows swipe handle and no dialog close on mobile (B146)', () => { + stubMobileViewport() matchMediaMock.mockImplementation((query: string) => ({ matches: query.includes('max-width'), media: query, @@ -393,6 +402,7 @@ describe('CampaignQuickActionsOverlay (B126)', () => { }) it('uses mobile drawer with actions above search', () => { + stubMobileViewport() matchMediaMock.mockImplementation((query: string) => ({ matches: query.includes('max-width'), media: query,