Skip to content

Commit 5c71508

Browse files
fix(web): satisfy type-check in sidebar dismiss tests
Co-authored-by: Tyler Dane <tyler-dane@users.noreply.github.com>
1 parent 646789d commit 5c71508

2 files changed

Lines changed: 22 additions & 15 deletions

File tree

packages/web/src/components/Sidebar/SidebarShell.test.tsx

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { render, screen } from "@testing-library/react";
1+
import { act, render, screen } from "@testing-library/react";
22
import userEvent from "@testing-library/user-event";
33
import { createStoreWrapper } from "@web/__tests__/render-with-store";
44
import { SIDEBAR_AUTO_COLLAPSE_BREAKPOINT } from "@web/components/AuthenticatedLayout/responsive.constants";
@@ -41,8 +41,8 @@ function renderShell() {
4141
onCloseShortcuts={mock()}
4242
onToggleShortcuts={mock()}
4343
shortcutSections={[]}
44-
SidebarActionsComponent={() => null}
45-
ShortcutsOverlayComponent={() => null}
44+
SidebarActionsComponent={() => <></>}
45+
ShortcutsOverlayComponent={() => <></>}
4646
>
4747
<div>Sidebar body</div>
4848
</SidebarShell>,
@@ -89,17 +89,19 @@ describe("SidebarShell", () => {
8989

9090
it("keeps dismiss available on narrow layouts while an event form is open", () => {
9191
mockViewport(true);
92-
viewActions.setSidebarOpen(false);
93-
draftActions.startGridDraft({
94-
activity: "gridClick",
95-
draft: createGridEventDraft(
96-
timedGridSchedule(
97-
new Date("2026-05-20T09:00:00.000Z"),
98-
new Date("2026-05-20T10:00:00.000Z"),
92+
act(() => {
93+
viewActions.setSidebarOpen(false);
94+
draftActions.startGridDraft({
95+
activity: "gridClick",
96+
draft: createGridEventDraft(
97+
timedGridSchedule(
98+
new Date("2026-05-20T09:00:00.000Z"),
99+
new Date("2026-05-20T10:00:00.000Z"),
100+
),
99101
),
100-
),
102+
});
103+
draftActions.setFormOpen(true);
101104
});
102-
draftActions.setFormOpen(true);
103105

104106
renderShell();
105107

packages/web/src/components/Sidebar/hooks/useIsNarrowSidebarLayout.test.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,11 @@ const originalMatchMedia = window.matchMedia;
77

88
function mockMatchMedia(matchesMinWidth: boolean) {
99
const listeners = new Set<(event: MediaQueryListEvent) => void>();
10+
let matches = matchesMinWidth;
1011
const query = {
11-
matches: matchesMinWidth,
12+
get matches() {
13+
return matches;
14+
},
1215
media: `(min-width: ${SIDEBAR_AUTO_COLLAPSE_BREAKPOINT}px)`,
1316
onchange: null,
1417
addEventListener: mock(
@@ -32,14 +35,16 @@ function mockMatchMedia(matchesMinWidth: boolean) {
3235
}
3336
return {
3437
...query,
35-
matches: false,
38+
get matches() {
39+
return false;
40+
},
3641
media,
3742
} as MediaQueryList;
3843
}) as typeof window.matchMedia;
3944

4045
return {
4146
setMatches(next: boolean) {
42-
query.matches = next;
47+
matches = next;
4348
const event = { matches: next } as MediaQueryListEvent;
4449
listeners.forEach((listener) => listener(event));
4550
},

0 commit comments

Comments
 (0)