feat: show persisted investment data and sync state

Consume the provided resource-envelope API snapshot. Preserve financial snapshots during
refresh, observe synchronization without importing, and fence late responses across
account and connection changes.
This commit is contained in:
2026-09-26 21:22:49 +03:00
parent b987fd8e78
commit 4e5f564fa1
81 changed files with 4714 additions and 1420 deletions
+4 -3
View File
@@ -1,5 +1,6 @@
import { HttpResponse, http } from "msw";
import { describe, expect, it, vi } from "vitest";
import { resource } from "@/test/resource";
import { server } from "@/test/server";
import { apiClient, configureAuthClient } from "./client";
@@ -16,14 +17,14 @@ describe("apiClient authentication", () => {
authorization.push(request.headers.get("Authorization") ?? "");
return authorization.length === 1
? HttpResponse.json({ code: "UNAUTHORIZED" }, { status: 401 })
: HttpResponse.json([]);
: HttpResponse.json(resource([]));
}),
);
configureAuthClient({ accessToken: () => token, refresh, clear: vi.fn() });
const { data } = await apiClient.GET("/api/v1/brokerage-accounts");
expect(data).toEqual([]);
expect(data?.data).toEqual([]);
expect(refresh).toHaveBeenCalledOnce();
expect(authorization).toEqual(["Bearer expired", "Bearer fresh"]);
});
@@ -76,7 +77,7 @@ describe("apiClient authentication", () => {
if (++calls === 1)
return HttpResponse.json({ code: "UNAUTHORIZED" }, { status: 401 });
await pending;
return HttpResponse.json([{ id: "previous-user-account" }]);
return HttpResponse.json(resource([{ id: "previous-user-account" }]));
}),
);
configureAuthClient({