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:
@@ -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({
|
||||
|
||||
Reference in New Issue
Block a user