test: pin date in all accounts events test (#115)
This commit was merged in pull request #117.
This commit is contained in:
@@ -11,7 +11,7 @@ import {
|
|||||||
} from "@testing-library/react";
|
} from "@testing-library/react";
|
||||||
import { http, HttpResponse } from "msw";
|
import { http, HttpResponse } from "msw";
|
||||||
import { MemoryRouter, useLocation } from "react-router";
|
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 { BrokerageOperation } from "@/entities/broker-operation";
|
||||||
import type { IncomeAnalytics } from "@/entities/income";
|
import type { IncomeAnalytics } from "@/entities/income";
|
||||||
@@ -145,6 +145,7 @@ function renderPage(path: string) {
|
|||||||
return client;
|
return client;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
afterEach(() => vi.useRealTimers());
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
server.use(
|
server.use(
|
||||||
http.post("*/api/v1/auth/refresh", () =>
|
http.post("*/api/v1/auth/refresh", () =>
|
||||||
@@ -271,6 +272,8 @@ describe("All accounts routes", () => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
it("restores applied dates when switching accounts in events", async () => {
|
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.
|
// The events calendar blocks past dates, so pick within selectable dates.
|
||||||
const search = `?from=${defaultPeriod()[0]}&to=${defaultPeriod()[1]}`;
|
const search = `?from=${defaultPeriod()[0]}&to=${defaultPeriod()[1]}`;
|
||||||
renderPage(`/accounts/all/events${search}`);
|
renderPage(`/accounts/all/events${search}`);
|
||||||
|
|||||||
Reference in New Issue
Block a user