Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AWxyMibCuGGtSQSqfajDQ7
54 lines
1.7 KiB
TypeScript
54 lines
1.7 KiB
TypeScript
import { describe, it, expect } from 'vitest'
|
|
import { render, screen } from '@testing-library/react'
|
|
import { IncidentList } from '@/components/incidents/incident-list'
|
|
|
|
const mockIncidents = [
|
|
{
|
|
id: 'inc-001',
|
|
reference_no: 'SCW1-202607-0001',
|
|
incident_type: 'near_miss',
|
|
status: 'reported',
|
|
severity: null,
|
|
reported_at: '2026-07-10T09:00:00Z',
|
|
sites: { name: 'SCW1' },
|
|
zones: { name: 'Dock A' },
|
|
reporter: { name: 'John Doe' },
|
|
},
|
|
{
|
|
id: 'inc-002',
|
|
reference_no: 'SCW1-202607-0002',
|
|
incident_type: 'injury',
|
|
status: 'triaged',
|
|
severity: 3,
|
|
reported_at: '2026-07-10T10:00:00Z',
|
|
sites: { name: 'SCW1' },
|
|
zones: { name: 'Loading Bay' },
|
|
reporter: { name: 'Jane Smith' },
|
|
},
|
|
]
|
|
|
|
describe('IncidentList', () => {
|
|
it('renders all incident rows', () => {
|
|
render(<IncidentList incidents={mockIncidents as any} basePath="/hse" />)
|
|
expect(screen.getByText('SCW1-202607-0001')).toBeTruthy()
|
|
expect(screen.getByText('SCW1-202607-0002')).toBeTruthy()
|
|
})
|
|
|
|
it('shows incident type labels', () => {
|
|
render(<IncidentList incidents={mockIncidents as any} basePath="/hse" />)
|
|
expect(screen.getByText('Near Miss')).toBeTruthy()
|
|
expect(screen.getByText('Injury / Medical')).toBeTruthy()
|
|
})
|
|
|
|
it('shows status badges', () => {
|
|
render(<IncidentList incidents={mockIncidents as any} basePath="/hse" />)
|
|
expect(screen.getByText('REPORTED')).toBeTruthy()
|
|
expect(screen.getByText('TRIAGED')).toBeTruthy()
|
|
})
|
|
|
|
it('renders empty state when no incidents', () => {
|
|
render(<IncidentList incidents={[]} basePath="/hse" />)
|
|
expect(screen.getByText(/no incidents/i)).toBeTruthy()
|
|
})
|
|
})
|