chore: add typed ESLint checks #18
Refs WealthLedger/main#18. Keep Biome; add no Prettier dependencies.
This commit is contained in:
@@ -18,6 +18,57 @@ function auth() {
|
||||
});
|
||||
}
|
||||
describe("page-owned screen synchronization", () => {
|
||||
it("ignores a late sync acceptance after the account scope changes", async () => {
|
||||
auth();
|
||||
let release!: () => void;
|
||||
const blocked = new Promise<void>((resolve) => {
|
||||
release = resolve;
|
||||
});
|
||||
const posted: string[] = [];
|
||||
const polled: string[] = [];
|
||||
server.use(
|
||||
http.post("*/api/v1/tbank-sync", async ({ request }) => {
|
||||
const scope = (await request.json()) as {
|
||||
screen: "account";
|
||||
accountId: string;
|
||||
};
|
||||
posted.push(scope.accountId);
|
||||
await blocked;
|
||||
return HttpResponse.json(
|
||||
{ id: scope.accountId, scope, now: "2026-09-25T00:00:00Z" },
|
||||
{ status: 202 },
|
||||
);
|
||||
}),
|
||||
http.get("*/api/v1/tbank-sync/:id", ({ params }) => {
|
||||
polled.push(String(params.id));
|
||||
return HttpResponse.json({
|
||||
id: params.id,
|
||||
state: "succeeded",
|
||||
resources: [],
|
||||
});
|
||||
}),
|
||||
);
|
||||
const { result, rerender } = renderHook(
|
||||
({ accountId }) => useScreenSync({ screen: "account", accountId }, []),
|
||||
{
|
||||
initialProps: { accountId: "old" },
|
||||
wrapper: createQueryWrapper().wrapper,
|
||||
},
|
||||
);
|
||||
let pending!: Promise<void>;
|
||||
act(() => {
|
||||
pending = result.current.refresh();
|
||||
});
|
||||
await waitFor(() => expect(posted).toEqual(["old"]));
|
||||
rerender({ accountId: "new" });
|
||||
await act(async () => {
|
||||
release();
|
||||
await pending;
|
||||
});
|
||||
await act(() => result.current.refresh());
|
||||
await waitFor(() => expect(polled).toEqual(["new"]));
|
||||
expect(posted).toEqual(["old", "new"]);
|
||||
});
|
||||
it.each([false, true])(
|
||||
"retries a failed GET without forcing the source (cached=%s)",
|
||||
async (cached) => {
|
||||
@@ -155,7 +206,7 @@ describe("page-owned screen synchronization", () => {
|
||||
);
|
||||
expect(published).not.toContainEqual(
|
||||
expect.objectContaining({
|
||||
meta: expect.objectContaining({ stateVersion: "old" }),
|
||||
meta: expect.objectContaining({ stateVersion: "old" }) as unknown,
|
||||
}),
|
||||
);
|
||||
unsubscribe();
|
||||
@@ -354,7 +405,7 @@ describe("page-owned screen synchronization", () => {
|
||||
});
|
||||
expect(modes).toEqual([null, "observe"]);
|
||||
if (boundary === "leave") unmount();
|
||||
else await act(() => configureAuthClient(null));
|
||||
else act(() => configureAuthClient(null));
|
||||
const stopped = polls;
|
||||
await act(async () => {
|
||||
await new Promise((resolve) => setTimeout(resolve, 1100));
|
||||
|
||||
Reference in New Issue
Block a user