refactor: align frontend ownership boundaries
Close audit gaps across API drift, query policy, UI, and tests.
This commit is contained in:
@@ -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 { configureAuthClient } from "@/shared/api";
|
||||
import { createQueryWrapper } from "@/test/query";
|
||||
import { server } from "@/test/server";
|
||||
import { useBrokerageEvents } from "./useBrokerageEvents";
|
||||
|
||||
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("useBrokerageEvents", () => {
|
||||
afterEach(() => configureAuthClient(null));
|
||||
|
||||
it("loads future cash events through the authenticated query seam", async () => {
|
||||
configureAuthClient({
|
||||
accessToken: () => "token",
|
||||
@@ -54,7 +35,7 @@ describe("useBrokerageEvents", () => {
|
||||
);
|
||||
|
||||
const { result } = renderHook(() => useBrokerageEvents("account-1"), {
|
||||
wrapper: createWrapper(),
|
||||
wrapper: createQueryWrapper().wrapper,
|
||||
});
|
||||
|
||||
await waitFor(() => expect(result.current.isSuccess).toBe(true));
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
import { apiQueryClient, useAuthenticatedQuery } from "@/shared/api";
|
||||
import type { paths } from "@/shared/api/generated/schema";
|
||||
import {
|
||||
apiQueryClient,
|
||||
type paths,
|
||||
useAuthenticatedQuery,
|
||||
} from "@/shared/api";
|
||||
|
||||
type EventsEndpoint =
|
||||
paths["/api/v1/brokerage-accounts/{accountId}/events"]["get"];
|
||||
@@ -15,7 +18,6 @@ function useBrokerageEvents(accountId: string | undefined) {
|
||||
),
|
||||
enabled: Boolean(accountId),
|
||||
staleTime: 30_000,
|
||||
retry: false,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user