fix: align appointment viewing and fleet follow-up navigation
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
import { expect, it } from 'vitest'
|
||||
import { inquiryReturnTarget, inquirySourceQuery, inquiryOrderTarget } from './inquiryNavigation'
|
||||
import type { CapacityInquiry } from './capacityOfferTypes'
|
||||
|
||||
it('returns only to a fixed internal inquiry route and rejects malformed or repeated values', () => {
|
||||
expect(inquiryReturnTarget(inquirySourceQuery({ offerNo: 'FO-1', bookingNo: 'FB-2' }))).toEqual({ name: 'overseas-master-data-capacity-offer-detail', params: { offerNo: 'FO-1' }, query: { inquiry: 'FB-2' } })
|
||||
for (const value of ['https://example.com', '../FB-2', ['FB-2'], '', null]) expect(inquiryReturnTarget({ fleetSource: 'inquiry', fleetOfferNo: 'FO-1', fleetBookingNo: value })).toBeNull()
|
||||
expect(inquiryReturnTarget({ returnTo: 'https://example.com' })).toBeNull()
|
||||
})
|
||||
it.each(['US_TRUCK', 'LOCAL_LOOSEBOARD'] as const)('opens %s using only its list permission and the business number', businessType => {
|
||||
const row = { businessType, businessOrderNo: 'ORDER-1', offerNo: 'FO-1', bookingNo: 'FB-2' } as CapacityInquiry
|
||||
const domain = businessType === 'US_TRUCK' ? 'truck' : 'looseboard'
|
||||
expect(inquiryOrderTarget(row, permission => permission === `platform:overseas-business:${domain}:list`)).toMatchObject({ query: { orderNo: 'ORDER-1', fleetBookingNo: 'FB-2' } })
|
||||
expect(inquiryOrderTarget(row, permission => permission.endsWith(':edit'))).toBeNull()
|
||||
expect(inquiryOrderTarget({ ...row, businessOrderNo: null }, () => true)).toBeNull()
|
||||
})
|
||||
Reference in New Issue
Block a user