test: pin mid-month date in upcoming events filter test (WealthLedger/frontend#101)
This commit is contained in:
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user