test: restriction page specs use the Berlin day like the page
Between 22:00 and 24:00 UTC the UTC day and the Berlin day differ, so the specs failed at night. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
This commit is contained in:
1 parent
ec8c95056d
commit
0091b3d28b
1 file changed
+5
-2
@@ -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/ });
|
||||
|
||||
Reference in new issue
Block a user