fix(trucks): skip active-site check when PATCH leaves site unchanged

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-15 11:53:32 +08:00
co-authored by Claude Sonnet 5.5
parent 5f1d7a6ed4
commit 17c32ecd04
3 changed files with 24 additions and 1 deletions
@@ -60,6 +60,17 @@ describe('TruckManager site link', () => {
expect(labels).toEqual(['No site', 'Site A', 'Site B'])
})
it('keeps the inactive site selectable for a truck already linked to it', () => {
const oldTrucks: Truck[] = [
{ id: 't9', truck_no: 'OLD 9', carrier: null, site_id: 'site-old', active: true },
]
render(<TruckManager trucks={oldTrucks} sites={sites} />)
fireEvent.click(screen.getAllByRole('button', { name: 'Edit' })[0])
const select = screen.getByLabelText('Site') as HTMLSelectElement
const labels = Array.from(select.options).map(o => o.textContent)
expect(labels).toEqual(['No site', 'Site A', 'Site B', 'Old Site'])
})
it('sends site_id when adding a truck', async () => {
render(<TruckManager trucks={trucks} sites={sites} />)
fireEvent.click(screen.getByRole('button', { name: /Add Truck/ }))