diff --git a/src/components/notifications/NotificationBell.test.tsx b/src/components/notifications/NotificationBell.test.tsx index 902ba537..30589a1d 100644 --- a/src/components/notifications/NotificationBell.test.tsx +++ b/src/components/notifications/NotificationBell.test.tsx @@ -186,6 +186,13 @@ describe("NotificationBell", () => { fireEvent.click(button); expect(screen.getByText("Loading...")).toBeInTheDocument(); + + // Let the mocked 100ms request settle before the test ends — a timer that + // outlives the test fires after vitest tears down jsdom, and the resulting + // state update throws "window is not defined" from an unrelated file. + await waitFor(() => + expect(screen.queryByText("Loading...")).not.toBeInTheDocument() + ); }); it("marks notification as read when clicked", async () => { diff --git a/src/components/reviews/ReviewForm.test.tsx b/src/components/reviews/ReviewForm.test.tsx index a5fb43ec..d3844a35 100644 --- a/src/components/reviews/ReviewForm.test.tsx +++ b/src/components/reviews/ReviewForm.test.tsx @@ -315,6 +315,15 @@ describe("ReviewForm", () => { fireEvent.click(submitButton); expect(screen.getByText("Submitting...")).toBeInTheDocument(); + + // Let the mocked 100ms request settle before the test ends. Otherwise the + // timer outlives the test, vitest tears down jsdom, and the component's + // late setIsSubmitting(false) hits React with no `window` — surfacing as + // "ReferenceError: window is not defined" in an unrelated file. It only + // reproduces under CI timing, so it reads as a random CI failure. + await waitFor(() => + expect(screen.queryByText("Submitting...")).not.toBeInTheDocument() + ); }); it("trims comment before sending", async () => {