fix: show history loading alert only while loading (WealthLedger/frontend#124)
This commit is contained in:
@@ -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(
|
||||
|
||||
@@ -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: () => {
|
||||
|
||||
Reference in New Issue
Block a user