refactor: align frontend ownership boundaries

Close audit gaps across API drift, query policy, UI, and tests.
This commit is contained in:
2026-09-06 18:20:05 +03:00
parent 175727bc93
commit c97f62bd98
118 changed files with 2190 additions and 2254 deletions
+3 -22
View File
@@ -1,31 +1,12 @@
import { MantineProvider } from "@mantine/core";
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import { renderHook, waitFor } from "@testing-library/react";
import { HttpResponse, http } from "msw";
import type { FC, PropsWithChildren } from "react";
import { afterEach, describe, expect, it, vi } from "vitest";
import { describe, expect, it, vi } from "vitest";
import { createQueryWrapper } from "@/test/query";
import { server } from "@/test/server";
import { useAuthenticatedQuery } from "./authenticated-query";
import { apiQueryClient, configureAuthClient } from "./client";
function createWrapper() {
const client = new QueryClient();
const TestWrapper: FC<PropsWithChildren> = (props) => {
const { children } = props;
return (
<MantineProvider>
<QueryClientProvider client={client}>{children}</QueryClientProvider>
</MantineProvider>
);
};
return TestWrapper;
}
describe("useAuthenticatedQuery", () => {
afterEach(() => configureAuthClient(null));
it("keeps protected queries idle without a session and loads after session configuration", async () => {
const requests = vi.fn();
server.use(
@@ -47,7 +28,7 @@ describe("useAuthenticatedQuery", () => {
useAuthenticatedQuery(
apiQueryClient.queryOptions("get", "/api/v1/brokerage-accounts"),
),
{ wrapper: createWrapper() },
{ wrapper: createQueryWrapper().wrapper },
);
await new Promise((resolve) => setTimeout(resolve, 0));
+1 -3
View File
@@ -1,11 +1,9 @@
import { HttpResponse, http } from "msw";
import { afterEach, describe, expect, it, vi } from "vitest";
import { describe, expect, it, vi } from "vitest";
import { server } from "@/test/server";
import { apiClient, configureAuthClient } from "./client";
describe("apiClient authentication", () => {
afterEach(() => configureAuthClient(null));
it("refreshes once and retries an unauthorized protected request", async () => {
let token = "expired";
const refresh = vi.fn(async () => {
+1 -1
View File
@@ -232,7 +232,7 @@ export interface components {
TbankConnectionStatusDto: {
connected: boolean;
/** Format: date-time */
connectedAt: Record<string, never> | null;
connectedAt: string | null;
};
PutTbankConnectionDto: {
token: string;
+2
View File
@@ -1,2 +1,4 @@
export { useAuthenticatedQuery } from "./authenticated-query";
export { apiClient, apiQueryClient, configureAuthClient } from "./client";
export type { paths } from "./generated/schema";
export { apiErrorCode } from "./problem-details";
+7
View File
@@ -0,0 +1,7 @@
function apiErrorCode(error: unknown): string | undefined {
return typeof error === "object" && error !== null && "code" in error
? String(error.code)
: undefined;
}
export { apiErrorCode };
+2 -2
View File
@@ -1275,7 +1275,7 @@
"type": "boolean"
},
"connectedAt": {
"type": "object",
"type": "string",
"nullable": true,
"format": "date-time"
}
@@ -1960,4 +1960,4 @@
}
}
}
}
}