From 5e18146363d61d5a431fdcbb81d75db0d52a4b68 Mon Sep 17 00:00:00 2001 From: Sergey Krylov Date: Tue, 27 Oct 2026 05:20:46 +0300 Subject: [PATCH] test: pin date in all accounts events test (#115) --- src/app/routes/AppRoutes/AllAccounts.test.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/app/routes/AppRoutes/AllAccounts.test.tsx b/src/app/routes/AppRoutes/AllAccounts.test.tsx index 88676eb..a189416 100644 --- a/src/app/routes/AppRoutes/AllAccounts.test.tsx +++ b/src/app/routes/AppRoutes/AllAccounts.test.tsx @@ -11,7 +11,7 @@ import { } from "@testing-library/react"; import { http, HttpResponse } from "msw"; import { MemoryRouter, useLocation } from "react-router"; -import { beforeEach, describe, expect, it } from "vitest"; +import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; import type { BrokerageOperation } from "@/entities/broker-operation"; import type { IncomeAnalytics } from "@/entities/income"; @@ -145,6 +145,7 @@ function renderPage(path: string) { return client; } +afterEach(() => vi.useRealTimers()); beforeEach(() => { server.use( http.post("*/api/v1/auth/refresh", () => @@ -271,6 +272,8 @@ describe("All accounts routes", () => { ); it("restores applied dates when switching accounts in events", async () => { + vi.useFakeTimers({ toFake: ["Date"] }); + vi.setSystemTime(new Date("2026-10-15T12:00:00Z")); // The events calendar blocks past dates, so pick within selectable dates. const search = `?from=${defaultPeriod()[0]}&to=${defaultPeriod()[1]}`; renderPage(`/accounts/all/events${search}`); -- 2.54.0