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]>
33 lines
1.3 KiB
TypeScript
33 lines
1.3 KiB
TypeScript
import { describe, it, expect } from 'vitest';
|
|
import { render, screen } from '@testing-library/react';
|
|
import { StateBadge } from '@/components/StateBadge';
|
|
import type { IncidentState } from '@/lib/types';
|
|
|
|
describe('StateBadge', () => {
|
|
const cases: { state: IncidentState; label: string; cssClass: string }[] = [
|
|
{ state: 'open', label: 'Aberto', cssClass: 'text-bg-danger' },
|
|
{ state: 'investigating', label: 'Em investigação', cssClass: 'text-bg-warning' },
|
|
{ state: 'resolved', label: 'Resolvido', cssClass: 'text-bg-success' },
|
|
{ state: 'ignored', label: 'Ignorado', cssClass: 'text-bg-secondary' },
|
|
];
|
|
|
|
cases.forEach(({ state, label, cssClass }) => {
|
|
it(`renders "${label}" label for state="${state}"`, () => {
|
|
render(<StateBadge state={state} />);
|
|
expect(screen.getByText(label)).toBeInTheDocument();
|
|
});
|
|
|
|
it(`applies "${cssClass}" class for state="${state}"`, () => {
|
|
render(<StateBadge state={state} />);
|
|
const badge = screen.getByText(label);
|
|
expect(badge.className).toContain(cssClass);
|
|
expect(badge.className).toContain('badge');
|
|
});
|
|
});
|
|
|
|
it('renders as a span element', () => {
|
|
render(<StateBadge state="open" />);
|
|
expect(screen.getByText('Aberto').tagName).toBe('SPAN');
|
|
});
|
|
});
|