feat: add operations page
This commit is contained in:
@@ -1,8 +1,11 @@
|
||||
import { MantineProvider } from "@mantine/core";
|
||||
import { cleanup, render, screen } from "@testing-library/react";
|
||||
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
||||
import { cleanup, render, screen, waitFor } from "@testing-library/react";
|
||||
import { HttpResponse, http } from "msw";
|
||||
import { MemoryRouter } from "react-router";
|
||||
import { afterEach, describe, expect, it, vi } from "vitest";
|
||||
import type { Portfolio } from "@/entities/portfolio";
|
||||
import { server } from "@/test/server";
|
||||
import {
|
||||
AccountPageEmpty,
|
||||
AccountPageError,
|
||||
@@ -12,9 +15,11 @@ import {
|
||||
|
||||
function renderPage(ui: React.ReactNode) {
|
||||
return render(
|
||||
<MantineProvider>
|
||||
<MemoryRouter>{ui}</MemoryRouter>
|
||||
</MantineProvider>,
|
||||
<QueryClientProvider client={new QueryClient()}>
|
||||
<MantineProvider>
|
||||
<MemoryRouter>{ui}</MemoryRouter>
|
||||
</MantineProvider>
|
||||
</QueryClientProvider>,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -114,4 +119,26 @@ describe("AccountPage states", () => {
|
||||
screen.getByRole("heading", { level: 1, name: "Основной" }),
|
||||
).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("keeps the portfolio visible when recent events fail", async () => {
|
||||
server.use(
|
||||
http.get("*/api/v1/brokerage-accounts/:accountId/operations", () =>
|
||||
HttpResponse.json({ code: "TBANK_UNAVAILABLE" }, { status: 503 }),
|
||||
),
|
||||
);
|
||||
renderPage(
|
||||
<AccountPageLoaded
|
||||
accountId="account-1"
|
||||
accessToken="token"
|
||||
portfolio={portfolio}
|
||||
/>,
|
||||
);
|
||||
|
||||
await waitFor(() =>
|
||||
expect(
|
||||
screen.getByText("Не удалось загрузить последние события."),
|
||||
).toBeInTheDocument(),
|
||||
);
|
||||
expect(screen.getByText("Вторая")).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user