fix: show history loading alert only while loading (WealthLedger/frontend#124) (#125)
This commit was merged in pull request #125.
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", () => {
|
describe("AccountOperationsPage", () => {
|
||||||
it.each(["account-1", "all"])(
|
it.each(["account-1", "all"])(
|
||||||
"normalizes invalid periods and history, preserves one-sided UTC dates and resets cursors for %s",
|
"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();
|
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 () => {
|
it("renders an error state", async () => {
|
||||||
configureTestAuth();
|
configureTestAuth();
|
||||||
server.use(
|
server.use(
|
||||||
|
|||||||
@@ -152,9 +152,7 @@ const useAccountOperationsPageVm = (): AccountOperationsPageViewModel => {
|
|||||||
draftPeriod,
|
draftPeriod,
|
||||||
hasNext: Boolean(nextCursor && operations.data.hasNext),
|
hasNext: Boolean(nextCursor && operations.data.hasNext),
|
||||||
hasPrevious: history.hasPrevious,
|
hasPrevious: history.hasPrevious,
|
||||||
historyLoading:
|
historyLoading: operations.meta?.coverage?.historyState === "loading",
|
||||||
operations.meta?.coverage?.historyState === "loading"
|
|
||||||
|| operations.meta?.coverage?.historyState === "partial",
|
|
||||||
items: operations.data.items,
|
items: operations.data.items,
|
||||||
maxDate,
|
maxDate,
|
||||||
onApply: () => {
|
onApply: () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user