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:
2026-07-13 10:50:13 +08:00
co-authored by Claude Sonnet 4.6
parent ebeab27e5e
commit 6c1ad71643
2 changed files with 28 additions and 1 deletions
+24
View File
@@ -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', () => {