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 { describe, expect, it, vi } from 'vitest';
|
||||
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 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 { BrokerAccountOverviewPage } from './BrokerAccountOverviewPage';
|
||||
import { BrokerPositionsPage } from './BrokerPositionsPage';
|
||||
import { BrokerOperationsPage } from './BrokerOperationsPage';
|
||||
import { BrokerAccountOverviewPage } from '../broker-account';
|
||||
import { BrokerPositionsPage } from '../broker-positions';
|
||||
import { BrokerOperationsPage } from '../broker-operations';
|
||||
|
||||
function renderWithClient(ui: ReactElement, initialEntries = ['/broker']) {
|
||||
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> = {}) {
|
||||
return vi.spyOn(operationsHook, 'useBrokerOperations').mockReturnValue({
|
||||
data: {
|
||||
@ -142,6 +159,55 @@ function BrokerAccountContextProbe({ expectedPortfolio }: { expectedPortfolio: u
|
||||
}
|
||||
|
||||
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', () => {
|
||||
vi.spyOn(portfolioHook, 'useBrokerPortfolio').mockReturnValue({
|
||||
data: {
|
||||
|
||||
@ -10,11 +10,11 @@ import { ProtectedRoute } from './components/ProtectedRoute';
|
||||
import { PortfoliosListPage } from './pages/portfolios/PortfoliosListPage';
|
||||
import { PortfolioDetailPage } from './pages/portfolios/PortfolioDetailPage';
|
||||
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 { BrokerAccountOverviewPage } from './pages/broker/BrokerAccountOverviewPage';
|
||||
import { BrokerPositionsPage } from './pages/broker/BrokerPositionsPage';
|
||||
import { BrokerOperationsPage } from './pages/broker/BrokerOperationsPage';
|
||||
import { BrokerAccountOverviewPage } from './pages/broker-account';
|
||||
import { BrokerPositionsPage } from './pages/broker-positions';
|
||||
import { BrokerOperationsPage } from './pages/broker-operations';
|
||||
|
||||
export function AppRoutes() {
|
||||
return (
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user