refactor: clarify frontend module ownership
Frontend verify / commits (pull_request) Failing after 1m19s
Frontend verify / security (pull_request) Skipped
Frontend verify / verify (pull_request) Skipped

This commit is contained in:
2026-09-29 07:07:36 +03:00
parent 7c28a423dd
commit f9f0f6921e
91 changed files with 1292 additions and 1050 deletions
+22 -18
View File
@@ -6,6 +6,8 @@ import { apiClient, configureAuthClient } from "@/shared/api";
import { createQueryWrapper } from "@/test/query";
import { server } from "@/test/server";
import type { BankCard, CreateBankOperation } from "./types";
import {
useCreateBankOperation,
useDeleteBankOperation,
@@ -14,8 +16,6 @@ import {
useUpdateExpenseCategory,
} from "./mutations";
import {
type BankCard,
type CreateBankOperation,
useBankCard,
useBankCards,
useBankCategories,
@@ -106,14 +106,14 @@ function useReadModels() {
const categories = useBankCategories();
const history = useBankOperations("a", {
limit: 20,
month: "2026-09",
page: 2,
from: "2026-09-01",
limit: 20, page: 2,
to: "2026-09-30",
});
const expenses = useBankExpenses("a", { page: 1 });
const september = useBankSummary("2026-09");
const august = useBankSummary("2026-08", "b");
const september = useBankSummary({ from: "2026-09-01", to: "2026-09-30" });
const august = useBankSummary({ from: "2026-08-01", to: "2026-08-31" }, "b");
const original = useBankOperation("original");
return {
@@ -144,7 +144,8 @@ describe("banking API", () => {
const page = Number(url.searchParams.get("page"));
pages.push(page);
expect(url.searchParams.get("limit")).toBe("100");
expect(url.searchParams.get("month")).toBe("2026-09");
expect(url.searchParams.get("from")).toBe("2026-09-01");
expect(url.searchParams.get("to")).toBe("2026-09-30");
if (isFail && page === 2)
return HttpResponse.json({ code: "FAILED" }, { status: 500 });
@@ -158,7 +159,7 @@ describe("banking API", () => {
);
const { result } = renderHook(
() => useBankOperations("a", { limit: "all", month: "2026-09", page: 1 }),
() => useBankOperations("a", { from: "2026-09-01", limit: "all", page: 1, to: "2026-09-30" }),
{ wrapper: createQueryWrapper().wrapper },
);
@@ -171,7 +172,7 @@ describe("banking API", () => {
isFail = true;
const { result: failedResult } = renderHook(
() => useBankOperations("a", { limit: "all", month: "2026-09", page: 1 }),
() => useBankOperations("a", { from: "2026-09-01", limit: "all", page: 1, to: "2026-09-30" }),
{ wrapper: createQueryWrapper().wrapper },
);
@@ -179,7 +180,7 @@ describe("banking API", () => {
expect(failedResult.current.data).toBeUndefined();
});
it("uses session-aware banking endpoints and explicit month/page without T-Bank", async () => {
it("uses session-aware banking endpoints and explicit period/page without T-Bank", async () => {
const counts = new Map<string, number>();
server.use(...readHandlers(counts));
@@ -191,12 +192,15 @@ describe("banking API", () => {
expect(result.current.reads.every(read => read.isSuccess)).toBe(true),
);
expect(counts.keys()).toContain("/api/v1/bank-cards?includeArchived=true");
expect(counts.keys()).toContain(
"/api/v1/bank-cards/a/operations?limit=20&month=2026-09&page=2",
);
expect(counts.keys()).toContain(
"/api/v1/bank-cards/summary?cardId=b&month=2026-08",
);
const urls = Array.from(counts.keys(), path => new URL(path, "http://localhost"));
const history = urls.find(url => url.pathname === "/api/v1/bank-cards/a/operations");
const summary = urls.find(url => url.pathname === "/api/v1/bank-cards/summary" && url.searchParams.get("cardId") === "b");
expect(Object.fromEntries(history?.searchParams ?? [])).toEqual({
from: "2026-09-01", limit: "20", page: "2", to: "2026-09-30",
});
expect(Object.fromEntries(summary?.searchParams ?? [])).toEqual({
cardId: "b", from: "2026-08-01", to: "2026-08-31",
});
expect(counts.size).toBe(9);
});
@@ -303,7 +307,7 @@ describe("banking API", () => {
expect(result.current.query.data?.balance.value).toBe("100");
});
it("refetches both cards, every month, categories, journal and source expenses after a transfer without invalidating brokerage", async () => {
it("refetches both cards, every period, categories, journal and source expenses after a transfer without invalidating brokerage", async () => {
const counts = new Map<string, number>();
server.use(
...readHandlers(counts),