diff --git a/ApiCore-Frontend/src/app/(app)/compliance/restrictions/page.spec.tsx b/ApiCore-Frontend/src/app/(app)/compliance/restrictions/page.spec.tsx index 20332d9..fc2f4dc 100644 --- a/ApiCore-Frontend/src/app/(app)/compliance/restrictions/page.spec.tsx +++ b/ApiCore-Frontend/src/app/(app)/compliance/restrictions/page.spec.tsx @@ -3,6 +3,7 @@ import { fireEvent, render, screen, waitFor, within } from "@testing-library/rea import userEvent from "@testing-library/user-event"; import { QueryClient, QueryClientProvider } from "@tanstack/react-query"; import { fetchApiaries } from "@/lib/apiaries/api"; +import { berlinCalendarDay } from "@/lib/dates"; import { endRestriction, fetchRestrictions, @@ -115,7 +116,7 @@ describe("RestrictionsPage", () => { const field = within(dialog).getByLabelText(/Letzter Tag/) as HTMLInputElement; const yesterday = new Date(Date.now() - 36 * 60 * 60 * 1000).toISOString().slice(0, 10); expect(field.value >= "2020-10-01").toBe(true); - expect(field.value <= new Date().toISOString().slice(0, 10)).toBe(true); + expect(field.value <= berlinCalendarDay(new Date().toISOString())).toBe(true); expect(field.value >= yesterday).toBe(true); }); @@ -206,7 +207,9 @@ describe("RestrictionsPage", () => { }); it("explains that a restriction that started today ends at the end of today at the earliest", async () => { - const today = new Date().toISOString().slice(0, 10); + // The page decides "today" by the Berlin calendar day; a UTC day would + // disagree between 22:00 and 24:00 UTC. + const today = berlinCalendarDay(new Date().toISOString()); vi.mocked(fetchRestrictions).mockResolvedValue([row({ id: "r-1", startsOn: `${today}T00:00:00.000Z` })]); renderPage(); const active = await screen.findByRole("region", { name: /Aktiv/ });