phase 16: vitest + MSW frontend tests, CI integration
This commit is contained in:
@@ -0,0 +1,154 @@
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { screen, waitFor } from '@testing-library/react';
|
||||
import userEvent from '@testing-library/user-event';
|
||||
import { renderRoute } from './render';
|
||||
|
||||
describe('Home page', () => {
|
||||
it('renders the title and key metrics', async () => {
|
||||
renderRoute('/');
|
||||
await waitFor(() => {
|
||||
expect(screen.getByText('Stonks Oracle')).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Companies page', () => {
|
||||
it('renders company list with tickers', async () => {
|
||||
renderRoute('/companies');
|
||||
await waitFor(() => {
|
||||
expect(screen.getByText('AAPL')).toBeInTheDocument();
|
||||
expect(screen.getByText('MSFT')).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
it('filters companies by search', async () => {
|
||||
renderRoute('/companies');
|
||||
await waitFor(() => expect(screen.getByText('AAPL')).toBeInTheDocument());
|
||||
|
||||
const filter = screen.getByLabelText('Filter table');
|
||||
await userEvent.type(filter, 'micro');
|
||||
|
||||
expect(screen.getByText('MSFT')).toBeInTheDocument();
|
||||
expect(screen.queryByText('AAPL')).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('shows add company form on button click', async () => {
|
||||
renderRoute('/companies');
|
||||
await waitFor(() => expect(screen.getByText('Add Company')).toBeInTheDocument());
|
||||
|
||||
await userEvent.click(screen.getByText('Add Company'));
|
||||
expect(screen.getByLabelText('Ticker')).toBeInTheDocument();
|
||||
expect(screen.getByLabelText('Legal Name')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('submits new company form', async () => {
|
||||
renderRoute('/companies');
|
||||
await waitFor(() => expect(screen.getByText('Add Company')).toBeInTheDocument());
|
||||
|
||||
await userEvent.click(screen.getByText('Add Company'));
|
||||
await userEvent.type(screen.getByLabelText('Ticker'), 'TSLA');
|
||||
await userEvent.type(screen.getByLabelText('Legal Name'), 'Tesla Inc.');
|
||||
await userEvent.click(screen.getByText('Create'));
|
||||
|
||||
// Form should close on success
|
||||
await waitFor(() => {
|
||||
expect(screen.queryByLabelText('Ticker')).not.toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Documents page', () => {
|
||||
it('renders document list', async () => {
|
||||
renderRoute('/documents');
|
||||
await waitFor(() => {
|
||||
expect(screen.getByText('Apple Q4 Earnings Beat')).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Trends page', () => {
|
||||
it('renders trend cards with direction', async () => {
|
||||
renderRoute('/trends');
|
||||
await waitFor(() => {
|
||||
expect(screen.getByText('AAPL')).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Recommendations page', () => {
|
||||
it('renders recommendation list', async () => {
|
||||
renderRoute('/recommendations');
|
||||
await waitFor(() => {
|
||||
expect(screen.getByText('AAPL')).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Orders page', () => {
|
||||
it('renders order list', async () => {
|
||||
renderRoute('/orders');
|
||||
await waitFor(() => {
|
||||
expect(screen.getByText('AAPL')).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Positions page', () => {
|
||||
it('renders positions with PnL', async () => {
|
||||
renderRoute('/positions');
|
||||
await waitFor(() => {
|
||||
expect(screen.getByText('AAPL')).toBeInTheDocument();
|
||||
expect(screen.getByText('$185.50')).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Trading page', () => {
|
||||
it('renders trading mode buttons', async () => {
|
||||
renderRoute('/trading');
|
||||
await waitFor(() => {
|
||||
expect(screen.getByText('paper')).toBeInTheDocument();
|
||||
expect(screen.getByText('live')).toBeInTheDocument();
|
||||
expect(screen.getByText('disabled')).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Ops pages', () => {
|
||||
it('pipeline health renders', async () => {
|
||||
renderRoute('/ops/pipeline');
|
||||
await waitFor(() => {
|
||||
expect(screen.getByText('Pipeline Health')).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
it('ingestion monitor renders', async () => {
|
||||
renderRoute('/ops/ingestion');
|
||||
await waitFor(() => {
|
||||
expect(screen.getByText('Ingestion Monitor')).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
it('model performance renders', async () => {
|
||||
renderRoute('/ops/model');
|
||||
await waitFor(() => {
|
||||
expect(screen.getByText('Model Performance')).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
it('source coverage renders', async () => {
|
||||
renderRoute('/ops/coverage');
|
||||
await waitFor(() => {
|
||||
expect(screen.getByText('Source Coverage')).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Watchlists page', () => {
|
||||
it('renders watchlists page with new button', async () => {
|
||||
renderRoute('/watchlists');
|
||||
await waitFor(() => {
|
||||
expect(screen.getByText('New Watchlist')).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user