test: pin mid-month date in upcoming events filter test (WealthLedger/frontend#101)
Frontend verify / commits (pull_request) Successful in 1m3s
Frontend verify / security (pull_request) Failing after 26s
Frontend verify / verify (pull_request) Skipped

This commit is contained in:
2026-10-23 16:24:20 +03:00
parent 9ae9a807a0
commit 95f1679718
@@ -17,7 +17,7 @@ import {
useLocation,
useNavigate,
} 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 { defaultPeriod, formatDate, moscowDate } from "@/shared/lib";
@@ -72,6 +72,9 @@ function renderEvents(accountId: string, searches: string[]) {
}
describe("Upcoming event date filters", () => {
afterEach(() => {
vi.useRealTimers();
});
beforeEach(() => {
configureAuthClient({
accessToken: () => "token",
@@ -229,6 +232,10 @@ describe("Upcoming event date filters", () => {
it.each(["account-1", "all"])(
"applies dates only on submit, restores URL dates, and resets from empty results for %s",
async (accountId) => {
// Pin "today" mid-month so "today + 10 days" stays in the calendar's
// visible month regardless of the real date.
vi.useFakeTimers({ toFake: ["Date"] });
vi.setSystemTime(new Date("2026-10-15T12:00:00+03:00"));
const [defaultFrom, defaultTo] = defaultPeriod();
const searches: string[] = [];
server.use(