chore: finish frontend ESLint migration #18
Enable every plugin recommended preset and replace Biome with ESLint formatting. Preserve API contracts and JSX whitespace; verify source, tests, builds and tooling.
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
import { act, renderHook, waitFor } from "@testing-library/react";
|
||||
import { HttpResponse, http } from "msw";
|
||||
import { http, HttpResponse } from "msw";
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
|
||||
import { apiQueryClient, configureAuthClient } from "@/shared/api";
|
||||
import { createQueryWrapper } from "@/test/query";
|
||||
import { server } from "@/test/server";
|
||||
|
||||
import {
|
||||
type InvestmentScreen,
|
||||
useTbankSync,
|
||||
@@ -17,22 +19,20 @@ describe("sync connection and session boundaries", () => {
|
||||
async (boundary) => {
|
||||
let generation = 0;
|
||||
configureAuthClient({
|
||||
generation: () => generation,
|
||||
accessToken: () => "synthetic",
|
||||
refresh: async () => true,
|
||||
clear: vi.fn(),
|
||||
generation: () => generation,
|
||||
refresh: () => Promise.resolve(true),
|
||||
});
|
||||
let release!: () => void;
|
||||
const blocked = new Promise<void>((resolve) => {
|
||||
release = resolve;
|
||||
});
|
||||
|
||||
const { promise: blocked, resolve: release } = Promise.withResolvers<void>();
|
||||
const accepted = {
|
||||
id: "work",
|
||||
scope: { screen: "accounts" },
|
||||
now: "2026-09-25T12:00:00Z",
|
||||
scope: { screen: "accounts" },
|
||||
};
|
||||
let started = 0;
|
||||
let changed = false;
|
||||
let isChanged = false;
|
||||
server.use(
|
||||
http.post("*/api/v1/tbank-sync", async () => {
|
||||
started += 1;
|
||||
@@ -40,29 +40,31 @@ describe("sync connection and session boundaries", () => {
|
||||
return HttpResponse.json(accepted, { status: 202 });
|
||||
}),
|
||||
http.get("*/api/v1/tbank-sync/:id", async () => {
|
||||
const now = changed ? "2026-09-25T12:01:00Z" : accepted.now;
|
||||
const now = isChanged ? "2026-09-25T12:01:00Z" : accepted.now;
|
||||
started += 1;
|
||||
await blocked;
|
||||
return HttpResponse.json({
|
||||
...accepted,
|
||||
now,
|
||||
state: "succeeded",
|
||||
errorCode: null,
|
||||
progress: { total: 1, completed: 1, discovering: false },
|
||||
resources: [],
|
||||
});
|
||||
return HttpResponse.json((/* eslint-disable unicorn/no-null -- Fixture preserves the production contract’s explicit null values. */
|
||||
{
|
||||
...accepted,
|
||||
errorCode: null,
|
||||
now,
|
||||
progress: { completed: 1, discovering: false, total: 1 },
|
||||
resources: [],
|
||||
state: "succeeded",
|
||||
}
|
||||
/* eslint-enable unicorn/no-null */));
|
||||
}),
|
||||
);
|
||||
const { wrapper, queryClient } = createQueryWrapper();
|
||||
const { queryClient, wrapper } = createQueryWrapper();
|
||||
const published: string[] = [];
|
||||
const unsubscribe = queryClient.getQueryCache().subscribe((event) => {
|
||||
if (
|
||||
(event.query.queryKey as readonly unknown[])[1] ===
|
||||
"/api/v1/tbank-sync/{id}"
|
||||
) {
|
||||
const data = event.query.state.data as { now?: string } | undefined;
|
||||
if (data?.now) published.push(data.now);
|
||||
if ((event.query.queryKey as readonly unknown[])[1]
|
||||
!== "/api/v1/tbank-sync/{id}") {
|
||||
return;
|
||||
}
|
||||
|
||||
const data = event.query.state.data as undefined | { now?: string };
|
||||
if (data?.now) published.push(data.now);
|
||||
});
|
||||
const { result } = renderHook(
|
||||
() => ({
|
||||
@@ -82,12 +84,14 @@ describe("sync connection and session boundaries", () => {
|
||||
});
|
||||
await waitFor(() => expect(started).toBe(2));
|
||||
await act(async () => {
|
||||
changed = true;
|
||||
isChanged = true;
|
||||
if (boundary === "connection")
|
||||
commitTbankConnectionBoundary(queryClient, {
|
||||
connected: false,
|
||||
connectedAt: null,
|
||||
});
|
||||
commitTbankConnectionBoundary(queryClient, (/* eslint-disable unicorn/no-null -- Fixture preserves the production contract’s explicit null values. */
|
||||
{
|
||||
connected: false,
|
||||
connectedAt: null,
|
||||
}
|
||||
/* eslint-enable unicorn/no-null */));
|
||||
else {
|
||||
generation += 1;
|
||||
queryClient.clear();
|
||||
@@ -104,9 +108,11 @@ describe("sync connection and session boundaries", () => {
|
||||
).queryKey;
|
||||
// A new request may start after a successful connection boundary; an old result cannot win it.
|
||||
if (boundary === "session")
|
||||
// eslint-disable-next-line vitest/no-conditional-expect -- The fixed table case selects the expected outcome; every case asserts its own branch.
|
||||
expect(queryClient.getQueryData(key)).toBeUndefined();
|
||||
else
|
||||
await waitFor(() =>
|
||||
// eslint-disable-next-line vitest/no-conditional-expect -- The fixed table case selects the expected outcome; every case asserts its own branch.
|
||||
expect(queryClient.getQueryData(key)).toMatchObject({
|
||||
now: "2026-09-25T12:01:00Z",
|
||||
}),
|
||||
|
||||
Reference in New Issue
Block a user