refactor(frontend): add broker fsd page entrypoints
This commit is contained in:
parent
9287b97880
commit
a03e3c0240
1
apps/frontend/src/pages/broker-account/index.ts
Normal file
1
apps/frontend/src/pages/broker-account/index.ts
Normal file
@ -0,0 +1 @@
|
|||||||
|
export { BrokerAccountOverviewPage } from './ui/BrokerAccountOverviewPage';
|
||||||
@ -0,0 +1 @@
|
|||||||
|
export { BrokerAccountOverviewPage } from '../../broker/BrokerAccountOverviewPage';
|
||||||
1
apps/frontend/src/pages/broker-accounts/index.ts
Normal file
1
apps/frontend/src/pages/broker-accounts/index.ts
Normal file
@ -0,0 +1 @@
|
|||||||
|
export { BrokerAccountsPage } from './ui/BrokerAccountsPage';
|
||||||
@ -0,0 +1 @@
|
|||||||
|
export { BrokerAccountsPage } from '../../broker/BrokerAccountsPage';
|
||||||
1
apps/frontend/src/pages/broker-operations/index.ts
Normal file
1
apps/frontend/src/pages/broker-operations/index.ts
Normal file
@ -0,0 +1 @@
|
|||||||
|
export { BrokerOperationsPage } from './ui/BrokerOperationsPage';
|
||||||
@ -0,0 +1 @@
|
|||||||
|
export { BrokerOperationsPage } from '../../broker/BrokerOperationsPage';
|
||||||
1
apps/frontend/src/pages/broker-positions/index.ts
Normal file
1
apps/frontend/src/pages/broker-positions/index.ts
Normal file
@ -0,0 +1 @@
|
|||||||
|
export { BrokerPositionsPage } from './ui/BrokerPositionsPage';
|
||||||
@ -0,0 +1 @@
|
|||||||
|
export { BrokerPositionsPage } from '../../broker/BrokerPositionsPage';
|
||||||
@ -5,14 +5,18 @@ import { type ReactElement } from 'react';
|
|||||||
import { MemoryRouter, Route, Routes } from 'react-router-dom';
|
import { MemoryRouter, Route, Routes } from 'react-router-dom';
|
||||||
import { describe, expect, it, vi } from 'vitest';
|
import { describe, expect, it, vi } from 'vitest';
|
||||||
import * as operationsHook from '../../hooks/useBrokerOperations';
|
import * as operationsHook from '../../hooks/useBrokerOperations';
|
||||||
|
import * as brokerAccountsHook from '../../hooks/useBrokerAccounts';
|
||||||
|
import * as brokerAccountPortfoliosHook from '../../hooks/useBrokerAccountPortfolios';
|
||||||
import * as portfolioHook from '../../hooks/useBrokerPortfolio';
|
import * as portfolioHook from '../../hooks/useBrokerPortfolio';
|
||||||
import * as positionsHook from '../../hooks/useBrokerPositions';
|
import * as positionsHook from '../../hooks/useBrokerPositions';
|
||||||
import type { BrokerPortfolio, BrokerPosition } from '../../api/responses';
|
import type { BrokerAccount, BrokerPortfolio, BrokerPosition } from '../../api/responses';
|
||||||
|
import { AppRoutes } from '../../routes';
|
||||||
|
import { renderWithProviders } from '../../test/test-utils';
|
||||||
import { BrokerAccountLayout, useBrokerAccountContext } from './BrokerAccountLayout';
|
import { BrokerAccountLayout, useBrokerAccountContext } from './BrokerAccountLayout';
|
||||||
|
|
||||||
import { BrokerAccountOverviewPage } from './BrokerAccountOverviewPage';
|
import { BrokerAccountOverviewPage } from '../broker-account';
|
||||||
import { BrokerPositionsPage } from './BrokerPositionsPage';
|
import { BrokerPositionsPage } from '../broker-positions';
|
||||||
import { BrokerOperationsPage } from './BrokerOperationsPage';
|
import { BrokerOperationsPage } from '../broker-operations';
|
||||||
|
|
||||||
function renderWithClient(ui: ReactElement, initialEntries = ['/broker']) {
|
function renderWithClient(ui: ReactElement, initialEntries = ['/broker']) {
|
||||||
const client = new QueryClient({ defaultOptions: { queries: { retry: false } } });
|
const client = new QueryClient({ defaultOptions: { queries: { retry: false } } });
|
||||||
@ -81,6 +85,19 @@ function createOverviewPortfolio(overrides: Partial<BrokerPortfolio> = {}): Brok
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function createBrokerAccount(
|
||||||
|
overrides: Partial<BrokerAccount> & Pick<BrokerAccount, 'id' | 'name'>,
|
||||||
|
): BrokerAccount {
|
||||||
|
return {
|
||||||
|
id: overrides.id,
|
||||||
|
name: overrides.name,
|
||||||
|
type: overrides.type ?? 'brokerage',
|
||||||
|
status: overrides.status ?? 'ACCOUNT_STATUS_OPEN',
|
||||||
|
openedAt: overrides.openedAt ?? null,
|
||||||
|
accessLevel: overrides.accessLevel ?? null,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
function mockOverviewOperations(overrides: Record<string, unknown> = {}) {
|
function mockOverviewOperations(overrides: Record<string, unknown> = {}) {
|
||||||
return vi.spyOn(operationsHook, 'useBrokerOperations').mockReturnValue({
|
return vi.spyOn(operationsHook, 'useBrokerOperations').mockReturnValue({
|
||||||
data: {
|
data: {
|
||||||
@ -142,6 +159,55 @@ function BrokerAccountContextProbe({ expectedPortfolio }: { expectedPortfolio: u
|
|||||||
}
|
}
|
||||||
|
|
||||||
describe('Broker pages', () => {
|
describe('Broker pages', () => {
|
||||||
|
it('renders broker routes through fsd entrypoints', async () => {
|
||||||
|
const account = createBrokerAccount({ id: 'acc-1', name: 'Основной брокерский счёт' });
|
||||||
|
|
||||||
|
vi.spyOn(brokerAccountsHook, 'useBrokerAccounts').mockReturnValue({
|
||||||
|
data: [account],
|
||||||
|
isLoading: false,
|
||||||
|
isFetching: false,
|
||||||
|
error: null,
|
||||||
|
} as any);
|
||||||
|
vi.spyOn(brokerAccountPortfoliosHook, 'useBrokerAccountPortfolios').mockReturnValue([
|
||||||
|
{
|
||||||
|
account,
|
||||||
|
query: {
|
||||||
|
data: createOverviewPortfolio({ account }),
|
||||||
|
isLoading: false,
|
||||||
|
isFetching: false,
|
||||||
|
isPending: false,
|
||||||
|
error: null,
|
||||||
|
refetch: vi.fn(),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
] as any);
|
||||||
|
vi.spyOn(portfolioHook, 'useBrokerPortfolio').mockReturnValue({
|
||||||
|
data: createOverviewPortfolio({ account }),
|
||||||
|
isLoading: false,
|
||||||
|
isFetching: false,
|
||||||
|
error: null,
|
||||||
|
} as any);
|
||||||
|
vi.spyOn(positionsHook, 'useBrokerPositions').mockReturnValue({
|
||||||
|
data: {
|
||||||
|
accountId: 'acc-1',
|
||||||
|
items: [],
|
||||||
|
nextCursor: null,
|
||||||
|
hasNext: false,
|
||||||
|
asOf: '2026-06-19T00:00:00.000Z',
|
||||||
|
},
|
||||||
|
isLoading: false,
|
||||||
|
isFetching: false,
|
||||||
|
error: null,
|
||||||
|
} as any);
|
||||||
|
mockOverviewOperations();
|
||||||
|
|
||||||
|
renderWithProviders(<AppRoutes />, { route: '/broker' });
|
||||||
|
|
||||||
|
expect(
|
||||||
|
await screen.findByRole('heading', { level: 1, name: /брокерские счета/i }),
|
||||||
|
).toBeInTheDocument();
|
||||||
|
});
|
||||||
|
|
||||||
it('renders account section navigation with the current nested route', () => {
|
it('renders account section navigation with the current nested route', () => {
|
||||||
vi.spyOn(portfolioHook, 'useBrokerPortfolio').mockReturnValue({
|
vi.spyOn(portfolioHook, 'useBrokerPortfolio').mockReturnValue({
|
||||||
data: {
|
data: {
|
||||||
|
|||||||
@ -10,11 +10,11 @@ import { ProtectedRoute } from './components/ProtectedRoute';
|
|||||||
import { PortfoliosListPage } from './pages/portfolios/PortfoliosListPage';
|
import { PortfoliosListPage } from './pages/portfolios/PortfoliosListPage';
|
||||||
import { PortfolioDetailPage } from './pages/portfolios/PortfolioDetailPage';
|
import { PortfolioDetailPage } from './pages/portfolios/PortfolioDetailPage';
|
||||||
import { ScreenerPage } from './pages/screener/ScreenerPage';
|
import { ScreenerPage } from './pages/screener/ScreenerPage';
|
||||||
import { BrokerAccountsPage } from './pages/broker/BrokerAccountsPage';
|
import { BrokerAccountsPage } from './pages/broker-accounts';
|
||||||
import { BrokerAccountLayout } from './pages/broker/BrokerAccountLayout';
|
import { BrokerAccountLayout } from './pages/broker/BrokerAccountLayout';
|
||||||
import { BrokerAccountOverviewPage } from './pages/broker/BrokerAccountOverviewPage';
|
import { BrokerAccountOverviewPage } from './pages/broker-account';
|
||||||
import { BrokerPositionsPage } from './pages/broker/BrokerPositionsPage';
|
import { BrokerPositionsPage } from './pages/broker-positions';
|
||||||
import { BrokerOperationsPage } from './pages/broker/BrokerOperationsPage';
|
import { BrokerOperationsPage } from './pages/broker-operations';
|
||||||
|
|
||||||
export function AppRoutes() {
|
export function AppRoutes() {
|
||||||
return (
|
return (
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user