diff --git a/src/pages/account-operations/ui/AccountOperationsPage/AccountOperationsPage.test.tsx b/src/pages/account-operations/ui/AccountOperationsPage/AccountOperationsPage.test.tsx index 968c1b9..c1a17e4 100644 --- a/src/pages/account-operations/ui/AccountOperationsPage/AccountOperationsPage.test.tsx +++ b/src/pages/account-operations/ui/AccountOperationsPage/AccountOperationsPage.test.tsx @@ -217,6 +217,27 @@ describe("LedgerEntryRow", () => { }); }); +const historyStateResource = (historyState: "loading" | "partial") => + HttpResponse.json( + resource( + { + hasNext: false, + items: [operation], + nextCursor: null, + }, + { + coverage: { + asOf: null, + completeRanges: [], + historyBoundary: "unknown", + historyState, + missingRanges: [], + requested: [], + }, + }, + ), + ); + describe("AccountOperationsPage", () => { it.each(["account-1", "all"])( "normalizes invalid periods and history, preserves one-sided UTC dates and resets cursors for %s", @@ -478,6 +499,33 @@ describe("AccountOperationsPage", () => { expect(screen.getByRole("button", { name: "Применить" })).toBeDisabled(); }); + it("does not show the history loading alert when coverage is partial", async () => { + configureTestAuth(); + server.use( + http.get( + "*/api/v1/brokerage-accounts/:accountId/operations", + () => historyStateResource("partial"), + ), + ); + renderPage(); + await screen.findByText("Покупка акций"); + expect(screen.queryByText("История догружается")).not.toBeInTheDocument(); + }); + + it("shows the history loading alert while historyState is loading", async () => { + configureTestAuth(); + server.use( + http.get( + "*/api/v1/brokerage-accounts/:accountId/operations", + () => historyStateResource("loading"), + ), + ); + renderPage(); + expect( + await screen.findByText("История догружается"), + ).toBeInTheDocument(); + }); + it("renders an error state", async () => { configureTestAuth(); server.use( diff --git a/src/pages/account-operations/ui/AccountOperationsPage/AccountOperationsPage.vm.ts b/src/pages/account-operations/ui/AccountOperationsPage/AccountOperationsPage.vm.ts index 55eb5f2..cc4d503 100644 --- a/src/pages/account-operations/ui/AccountOperationsPage/AccountOperationsPage.vm.ts +++ b/src/pages/account-operations/ui/AccountOperationsPage/AccountOperationsPage.vm.ts @@ -152,9 +152,7 @@ const useAccountOperationsPageVm = (): AccountOperationsPageViewModel => { draftPeriod, hasNext: Boolean(nextCursor && operations.data.hasNext), hasPrevious: history.hasPrevious, - historyLoading: - operations.meta?.coverage?.historyState === "loading" - || operations.meta?.coverage?.historyState === "partial", + historyLoading: operations.meta?.coverage?.historyState === "loading", items: operations.data.items, maxDate, onApply: () => {