fix: keep session when refresh fails on network error or 5xx (WealthLedger/frontend#97)
Frontend verify / commits (push) Skipped
Frontend verify / security (push) Successful in 1m3s
Frontend verify / verify (push) Failing after 7m11s

This commit was merged in pull request #100.
This commit is contained in:
2026-10-23 15:06:20 +03:00
parent 7b6f34c776
commit 3af9df0ae2
9 changed files with 154 additions and 15 deletions
+19
View File
@@ -67,6 +67,25 @@ describe("apiClient authentication", () => {
expect(clear).toHaveBeenCalledOnce();
});
it("keeps the session when refresh failed because the server was unreachable", async () => {
const clear = vi.fn();
server.use(
http.get("*/api/v1/brokerage-accounts", () =>
HttpResponse.json({ code: "UNAUTHORIZED" }, { status: 401 }),
),
);
configureAuthClient({
accessToken: () => "expired",
clear,
refresh: () => Promise.resolve(false),
unavailable: () => true,
});
await apiClient.GET("/api/v1/brokerage-accounts");
expect(clear).not.toHaveBeenCalled();
});
it("does not attach Bearer auth to authentication endpoints", async () => {
let authorization: null | string