Complete test coverage implementation for errors.bitreport.pt: admin-ui (98 tests): - test/components/: AppShell, DataAlert, IncidentNotes, KpiCard, SeverityBadge, StateBadge - test/lib/: format, demo-incidents, incidents-data, incidents-data-api, stats-data, stats-data-api - vitest.config.ts with jsdom + v8 coverage + @vitejs/plugin-react api route tests (54 tests): - src/routes/admin/auth.test.ts (15 tests) - src/routes/admin/incidents.test.ts (11 tests) - src/routes/admin/stats.test.ts (18 tests) - src/routes/public/errorMonitoringStats.test.ts (10 tests) collector-worker db/scheduler tests (22 tests): - src/db/collectorRunWriter.test.ts (10 tests) - src/db/loadActiveSources.test.ts (6 tests) - src/scheduler/runHttpSourceOnce.test.ts (6 tests) ingest-api service tests (13 tests): - src/buildApp.test.ts, plugins/prometheus.test.ts - services/ingestAuth.test.ts, services/processIngestBatch.utils.test.ts Total: 187 additional tests (255 total across all modules). All pass. Paperclip-Issue: BIT-15744 Co-Authored-By: Paperclip <[email protected]>
42 lines
1.6 KiB
TypeScript
42 lines
1.6 KiB
TypeScript
import { describe, it, expect } from 'vitest';
|
|
import { render, screen } from '@testing-library/react';
|
|
import { DataAlert } from '@/components/DataAlert';
|
|
|
|
describe('DataAlert', () => {
|
|
it('renders the title', () => {
|
|
render(<DataAlert variant="warning" title="Aviso" body="Algo correu mal." />);
|
|
expect(screen.getByText('Aviso')).toBeInTheDocument();
|
|
});
|
|
|
|
it('renders the body text', () => {
|
|
render(<DataAlert variant="info" title="Info" body="Nenhuma informação disponível." />);
|
|
expect(screen.getByText('Nenhuma informação disponível.')).toBeInTheDocument();
|
|
});
|
|
|
|
it('applies the correct alert variant class', () => {
|
|
const { container } = render(<DataAlert variant="danger" title="Erro" body="Falha." />);
|
|
expect(container.querySelector('.alert-danger')).not.toBeNull();
|
|
});
|
|
|
|
it('applies alert-warning class for warning variant', () => {
|
|
const { container } = render(<DataAlert variant="warning" title="X" body="Y" />);
|
|
expect(container.querySelector('.alert-warning')).not.toBeNull();
|
|
});
|
|
|
|
it('applies alert-info class for info variant', () => {
|
|
const { container } = render(<DataAlert variant="info" title="X" body="Y" />);
|
|
expect(container.querySelector('.alert-info')).not.toBeNull();
|
|
});
|
|
|
|
it('has role="status" for accessibility', () => {
|
|
render(<DataAlert variant="warning" title="Status" body="OK" />);
|
|
expect(screen.getByRole('status')).toBeInTheDocument();
|
|
});
|
|
|
|
it('renders title in a strong element', () => {
|
|
render(<DataAlert variant="info" title="My Title" body="body text" />);
|
|
const strong = screen.getByText('My Title');
|
|
expect(strong.tagName).toBe('STRONG');
|
|
});
|
|
});
|