test: pin date in account events date filter test (WealthLedger/frontend#98)
The test clicked today + 10 days, which falls outside the Mantine calendar grid for some real dates and made the suite fail depending on the run date.
This commit is contained in:
@@ -17,7 +17,7 @@ import {
|
|||||||
useLocation,
|
useLocation,
|
||||||
useNavigate,
|
useNavigate,
|
||||||
} from "react-router";
|
} from "react-router";
|
||||||
import { beforeEach, describe, expect, it, vi } from "vitest";
|
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
||||||
|
|
||||||
import { configureAuthClient } from "@/shared/api";
|
import { configureAuthClient } from "@/shared/api";
|
||||||
import { defaultPeriod, formatDate, moscowDate } from "@/shared/lib";
|
import { defaultPeriod, formatDate, moscowDate } from "@/shared/lib";
|
||||||
@@ -73,6 +73,10 @@ function renderEvents(accountId: string, searches: string[]) {
|
|||||||
|
|
||||||
describe("Upcoming event date filters", () => {
|
describe("Upcoming event date filters", () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
|
// Pin "today": the test picks today + 10 days, which must be inside the visible calendar grid.
|
||||||
|
// Real dates can push it beyond the grid (e.g. 2026-10-23 -> 2 November).
|
||||||
|
vi.useFakeTimers({ toFake: ["Date"] });
|
||||||
|
vi.setSystemTime(new Date("2026-08-10T09:00:00Z"));
|
||||||
configureAuthClient({
|
configureAuthClient({
|
||||||
accessToken: () => "token",
|
accessToken: () => "token",
|
||||||
clear: vi.fn(),
|
clear: vi.fn(),
|
||||||
@@ -80,6 +84,8 @@ describe("Upcoming event date filters", () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
afterEach(() => vi.useRealTimers());
|
||||||
|
|
||||||
it("keeps reads and sync disabled without an account scope", async () => {
|
it("keeps reads and sync disabled without an account scope", async () => {
|
||||||
const requests: string[] = [];
|
const requests: string[] = [];
|
||||||
server.use(
|
server.use(
|
||||||
|
|||||||
Reference in New Issue
Block a user