Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AWxyMibCuGGtSQSqfajDQ7
53 lines
1.6 KiB
TypeScript
53 lines
1.6 KiB
TypeScript
import { describe, it, expect } from 'vitest'
|
|
import { render, screen } from '@testing-library/react'
|
|
import { IncidentDetail } from '@/components/incidents/incident-detail'
|
|
|
|
const mockIncident = {
|
|
id: 'inc-001',
|
|
reference_no: 'SCW1-202607-0001',
|
|
incident_type: 'near_miss',
|
|
description: 'Forklift nearly hit a pedestrian in Dock A aisle near the charging station.',
|
|
status: 'reported',
|
|
severity: null,
|
|
injury_involved: false,
|
|
asset_involved: false,
|
|
medical_status: null,
|
|
lost_days: null,
|
|
reported_at: '2026-07-10T09:00:00Z',
|
|
closed_at: null,
|
|
sites: { id: 'site-001', name: 'SCW1' },
|
|
zones: { id: 'zone-001', name: 'Dock A' },
|
|
reporter: { id: 'user-001', name: 'John Doe', email: 'john@example.com' },
|
|
evidence_files: [
|
|
{
|
|
id: 'ev-001',
|
|
stage: 'report',
|
|
file_url: 'https://example.com/photo.jpg',
|
|
file_type: 'image/jpeg',
|
|
uploaded_at: '2026-07-10T09:01:00Z',
|
|
},
|
|
],
|
|
}
|
|
|
|
describe('IncidentDetail', () => {
|
|
it('renders reference number', () => {
|
|
render(<IncidentDetail incident={mockIncident as any} />)
|
|
expect(screen.getByText('SCW1-202607-0001')).toBeTruthy()
|
|
})
|
|
|
|
it('renders description', () => {
|
|
render(<IncidentDetail incident={mockIncident as any} />)
|
|
expect(screen.getByText(/Forklift nearly hit/)).toBeTruthy()
|
|
})
|
|
|
|
it('renders reported by', () => {
|
|
render(<IncidentDetail incident={mockIncident as any} />)
|
|
expect(screen.getByText(/John Doe/)).toBeTruthy()
|
|
})
|
|
|
|
it('renders evidence count', () => {
|
|
render(<IncidentDetail incident={mockIncident as any} />)
|
|
expect(screen.getByText(/1 file/i)).toBeTruthy()
|
|
})
|
|
})
|