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]>
43 lines
1.6 KiB
TypeScript
43 lines
1.6 KiB
TypeScript
import { describe, it, expect } from 'vitest';
|
|
import { render, screen } from '@testing-library/react';
|
|
import { KpiCard } from '@/components/KpiCard';
|
|
|
|
describe('KpiCard', () => {
|
|
it('renders the label text', () => {
|
|
render(<KpiCard label="Total Errors" value={42} variant="danger" />);
|
|
expect(screen.getByText('Total Errors')).toBeInTheDocument();
|
|
});
|
|
|
|
it('renders the numeric value', () => {
|
|
render(<KpiCard label="Open Incidents" value={7} variant="primary" />);
|
|
expect(screen.getByText('7')).toBeInTheDocument();
|
|
});
|
|
|
|
it('applies the correct border variant class', () => {
|
|
const { container } = render(<KpiCard label="Resolved" value={100} variant="success" />);
|
|
expect(container.querySelector('.border-success')).not.toBeNull();
|
|
});
|
|
|
|
it('applies the correct text variant class', () => {
|
|
render(<KpiCard label="Critical" value={3} variant="dark" />);
|
|
const valueEl = screen.getByText('3');
|
|
expect(valueEl.className).toContain('text-dark');
|
|
});
|
|
|
|
it('renders value zero', () => {
|
|
render(<KpiCard label="No errors" value={0} variant="secondary" />);
|
|
expect(screen.getByText('0')).toBeInTheDocument();
|
|
});
|
|
|
|
it('renders large numbers', () => {
|
|
render(<KpiCard label="All time" value={99999} variant="warning" />);
|
|
expect(screen.getByText('99999')).toBeInTheDocument();
|
|
});
|
|
|
|
it('applies card and col wrapper classes', () => {
|
|
const { container } = render(<KpiCard label="test" value={1} variant="primary" />);
|
|
expect(container.querySelector('.card')).not.toBeNull();
|
|
expect(container.querySelector('.card-body')).not.toBeNull();
|
|
});
|
|
});
|