fix(auth,bank): guard switch-auth nav and surface banking retry
Frontend verify / commits (pull_request) Successful in 39s
Frontend verify / security (pull_request) Successful in 10s
Frontend verify / verify (pull_request) Failing after 5m50s

AuthForm disables the switch-auth Link while submit is pending so pointer
click and Enter can no longer leave the auth route and lose the draft/error
context. The form restores a true Link after the request settles.

CardsPage/CardPage distinguish cold vs cached banking failures:
- cold card/section errors expose accessible alert + retry
- cached failures keep the previous data and offer a section GET retry
- summary-only/history-only outages do not hide successful sections
- notFound still skips the retry CTA

Tests cover the pending link guard, cold/cached cards error with retry,
summary failure with retry, and the prerequisite card list recovery.

Closes #56, #57
This commit is contained in:
2026-10-14 10:43:34 +03:00
parent e5f8bbe33c
commit e38ecd87d6
10 changed files with 251 additions and 32 deletions
@@ -47,8 +47,9 @@ function renderCards(isFail = false, hasCategoryFailure = false) {
),
);
return render(
<QueryClientProvider client={createTestQueryClient()}>
const client = createTestQueryClient();
render(
<QueryClientProvider client={client}>
<MantineProvider env="test">
<MemoryRouter initialEntries={["/cards?month=2026-09"]}>
<CardsPage />
@@ -56,6 +57,8 @@ function renderCards(isFail = false, hasCategoryFailure = false) {
</MantineProvider>
</QueryClientProvider>,
);
return client;
}
describe("CardsPage", () => {
@@ -232,4 +235,76 @@ describe("CardsPage", () => {
});
expect(screen.queryByRole("alert")).not.toBeInTheDocument();
});
it("shows a cold cards error with retry", async () => {
renderCards(true);
expect(
await screen.findByRole("alert", {}, { timeout: 5000 }),
).toHaveTextContent("Не удалось загрузить данные карт.");
expect(
screen.getByRole("button", { name: "Повторить" }),
).toBeInTheDocument();
server.use(
http.get("*/api/v1/bank-cards", () =>
HttpResponse.json([
{
archivedAt: null,
balance: money("10000"),
bankName: null,
id: "a",
lastFour: null,
name: "Повседневная",
openingBalance: money("10000"),
openingDate: "2026-01-01",
version: 1,
},
]),
),
);
fireEvent.click(screen.getByRole("button", { name: "Повторить" }));
await waitFor(() =>
expect(screen.queryByRole("alert")).not.toBeInTheDocument(),
);
expect(
screen.getByRole("link", { name: /Повседневная/ }),
).toBeInTheDocument();
});
it("shows a cached cards error while keeping the grid", async () => {
const view = renderCards();
await screen.findByRole("heading", { name: "Добавьте первую карту" });
server.use(
http.get("*/api/v1/bank-cards", () =>
HttpResponse.json([
{
archivedAt: null,
balance: money("10000"),
bankName: null,
id: "a",
lastFour: null,
name: "Повседневная",
openingBalance: money("10000"),
openingDate: "2026-01-01",
version: 1,
},
]),
),
);
await view.invalidateQueries();
await screen.findByRole("link", { name: /Повседневная/ });
server.use(http.get("*/api/v1/bank-cards", () => HttpResponse.error()));
await view.invalidateQueries();
expect(
await screen.findByRole("alert", {}, { timeout: 5000 }),
).toHaveTextContent("Не удалось обновить данные. Показаны последние полученные.");
expect(
screen.getByRole("link", { name: /Повседневная/ }),
).toBeInTheDocument();
});
});