refactor: enforce frontend view model boundaries
This commit is contained in:
@@ -20,9 +20,11 @@ describe("useBrokerageEvents", () => {
|
||||
server.use(
|
||||
http.get("*/api/v1/brokerage-accounts/:accountId/events", requested),
|
||||
);
|
||||
|
||||
const { result } = renderHook(() => useBrokerageEvents(undefined), {
|
||||
wrapper: createQueryWrapper().wrapper,
|
||||
});
|
||||
|
||||
await waitFor(() => expect(result.current.fetchStatus).toBe("idle"));
|
||||
expect(requested).not.toHaveBeenCalled();
|
||||
});
|
||||
@@ -35,7 +37,8 @@ describe("useBrokerageEvents", () => {
|
||||
server.use(
|
||||
http.get("*/api/v1/brokerage-accounts/account-1/events", () =>
|
||||
HttpResponse.json(
|
||||
resource((/* eslint-disable unicorn/no-null -- Fixture preserves the production contract’s explicit null values. */
|
||||
/* eslint-disable unicorn/no-null -- Fixture preserves the production contract’s explicit null values. */
|
||||
resource(
|
||||
{
|
||||
accountId: "account-1",
|
||||
calculatedAt: "2026-08-14T00:00:00Z",
|
||||
@@ -52,8 +55,9 @@ describe("useBrokerageEvents", () => {
|
||||
type: "dividend",
|
||||
},
|
||||
],
|
||||
}
|
||||
/* eslint-enable unicorn/no-null */)),
|
||||
},
|
||||
/* eslint-enable unicorn/no-null */
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
@@ -63,20 +67,20 @@ describe("useBrokerageEvents", () => {
|
||||
});
|
||||
|
||||
await waitFor(() => expect(result.current.isSuccess).toBe(true));
|
||||
/* eslint-disable unicorn/no-null -- Fixture preserves the production contract’s explicit null values. */
|
||||
expect(result.current.data?.events).toEqual([
|
||||
(/* eslint-disable unicorn/no-null -- Fixture preserves the production contract’s explicit null values. */
|
||||
{
|
||||
date: "2026-09-01",
|
||||
dateKind: "registry",
|
||||
displayName: "Сбер",
|
||||
figi: "figi-1",
|
||||
instrumentUid: null,
|
||||
logoName: "sber3.png",
|
||||
projectedAmount: { currency: "RUB", value: "12.34" },
|
||||
ticker: "SBER",
|
||||
type: "dividend",
|
||||
}
|
||||
/* eslint-enable unicorn/no-null */),
|
||||
{
|
||||
date: "2026-09-01",
|
||||
dateKind: "registry",
|
||||
displayName: "Сбер",
|
||||
figi: "figi-1",
|
||||
instrumentUid: null,
|
||||
logoName: "sber3.png",
|
||||
projectedAmount: { currency: "RUB", value: "12.34" },
|
||||
ticker: "SBER",
|
||||
type: "dividend",
|
||||
},
|
||||
/* eslint-enable unicorn/no-null */
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -3,6 +3,7 @@ import { apiQueryClient, type paths, useResourceQuery } from "@/shared/api";
|
||||
type BrokerageEvent = NonNullable<
|
||||
EventsEndpoint["responses"][200]["content"]["application/json"]["data"]
|
||||
>["events"][number];
|
||||
|
||||
type EventsEndpoint
|
||||
= paths["/api/v1/brokerage-accounts/{accountId}/events"]["get"];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user