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:
@@ -128,6 +128,18 @@ describe('PATCH /api/admin/trucks', () => {
|
||||
expect((await PATCH(req('PATCH', { id: 't1', site_id: SITE }))).status).toBe(422)
|
||||
expect(setSpy).not.toHaveBeenCalled()
|
||||
})
|
||||
it('skips the active-site check when the site is unchanged', async () => {
|
||||
selectQueue.push([{ id: 't1', siteId: SITE }])
|
||||
const res = await PATCH(req('PATCH', { id: 't1', truck_no: 'NEW 1', site_id: SITE }))
|
||||
expect(res.status).toBe(200)
|
||||
expect(setSpy).toHaveBeenCalledWith({ truckNo: 'NEW 1', siteId: SITE })
|
||||
})
|
||||
it('422 when moving a site-less truck to an inactive site', async () => {
|
||||
selectQueue.push([{ id: 't1', siteId: null }], [])
|
||||
const res = await PATCH(req('PATCH', { id: 't1', site_id: SITE }))
|
||||
expect(res.status).toBe(422)
|
||||
expect(setSpy).not.toHaveBeenCalled()
|
||||
})
|
||||
it('409 for a duplicate truck number', async () => {
|
||||
selectQueue.push([{ id: 't1' }])
|
||||
txError.code = '23505'
|
||||
|
||||
Reference in New Issue
Block a user