feat(report): show all trucks regardless of site

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-15 13:52:46 +08:00
co-authored by Claude Sonnet 5.5
parent f3c62d9225
commit 701fefd286
2 changed files with 14 additions and 20 deletions
@@ -39,26 +39,26 @@ const selectWith = (text: string) =>
const truckNos = () =>
Array.from(selectWith(en.ReportForm.truckPlaceholder).options).map(o => o.textContent)
describe('ReportForm truck filter', () => {
it('defaults the site to the preselected truck site and filters trucks', () => {
describe('ReportForm truck list', () => {
const all = [en.ReportForm.truckPlaceholder, 'AAA 1', 'BBB 2', 'FREE 3']
it('shows every truck regardless of site', () => {
renderForm()
expect(selectWith(en.ReportForm.sitePlaceholder).value).toBe('site-a')
expect(truckNos()).toEqual([en.ReportForm.truckPlaceholder, 'AAA 1', 'FREE 3'])
expect(truckNos()).toEqual(all)
})
it('changing the site refilters and clears a truck that no longer fits', () => {
it('keeps the chosen truck when the site changes', () => {
renderForm()
expect(selectWith(en.ReportForm.truckPlaceholder).value).toBe('t1')
fireEvent.change(selectWith(en.ReportForm.sitePlaceholder), { target: { value: 'site-b' } })
expect(truckNos()).toEqual([en.ReportForm.truckPlaceholder, 'BBB 2', 'FREE 3'])
expect(selectWith(en.ReportForm.truckPlaceholder).value).toBe('')
expect(truckNos()).toEqual(all)
expect(selectWith(en.ReportForm.truckPlaceholder).value).toBe('t1')
})
it('uses the QR zone site when a zone token is present', () => {
it('shows every truck with a QR zone token', () => {
renderForm({ zoneToken: 'tok-b', zoneName: 'Yard', siteName: 'Site B', initialTruckId: null })
fireEvent.change(screen.getAllByRole('combobox').find(s => within(s).queryByText(en.IncidentType.transport))!, {
target: { value: 'transport' },
})
expect(truckNos()).toEqual([en.ReportForm.truckPlaceholder, 'BBB 2', 'FREE 3'])
expect(truckNos()).toEqual(all)
})
})