feat: validate transport incident requires truck_id
Add 'transport' to INCIDENT_TYPES; add truck_id field to IncidentInput; reject transport submissions missing truck_id. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CPf5Rc8QPx6V8KLEEgfKEQ
This commit is contained in:
@@ -42,6 +42,30 @@ describe('validateIncidentInput', () => {
|
||||
expect(result.ok).toBe(false)
|
||||
expect(result.errors).toContain('incident_type is invalid')
|
||||
})
|
||||
|
||||
it('accepts transport type when truck_id is present', () => {
|
||||
const r = validateIncidentInput({
|
||||
zone_token: 'z',
|
||||
incident_type: 'transport',
|
||||
description: 'Truck clipped the dock frame reversing into bay 3.',
|
||||
injury_involved: false,
|
||||
asset_involved: false,
|
||||
truck_id: 'truck-uuid',
|
||||
} as any)
|
||||
expect(r.ok).toBe(true)
|
||||
})
|
||||
|
||||
it('rejects transport type without a truck_id', () => {
|
||||
const r = validateIncidentInput({
|
||||
zone_token: 'z',
|
||||
incident_type: 'transport',
|
||||
description: 'Truck clipped the dock frame reversing into bay 3.',
|
||||
injury_involved: false,
|
||||
asset_involved: false,
|
||||
} as any)
|
||||
expect(r.ok).toBe(false)
|
||||
expect(r.errors).toContain('truck_id is required for transport incidents')
|
||||
})
|
||||
})
|
||||
|
||||
describe('validateTypeDetails', () => {
|
||||
|
||||
Reference in New Issue
Block a user