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", () => {
|
||||
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(
|
||||
|
||||
Reference in New Issue
Block a user