fix(bookings): display saved port codes when names are empty
This commit is contained in:
@@ -15,6 +15,21 @@ const detailResponse = (version = 0, status = 'DRAFT') => ({
|
||||
})
|
||||
|
||||
describe('ocean bookings api', () => {
|
||||
it.each([
|
||||
['宁波', '洛杉矶', 'CNNGB', 'USLAX', '宁波', '洛杉矶'],
|
||||
[null, null, 'CNNGB', 'USLAX', 'CNNGB', 'USLAX'],
|
||||
['', ' ', 'CNNGB', 'USLAX', 'CNNGB', 'USLAX'],
|
||||
['宁波', '洛杉矶', null, null, '宁波', '洛杉矶'],
|
||||
[null, '', null, ' ', null, null],
|
||||
])('列表港口名称 %s / %s 为空时展示已保存代码', async (departurePortName, destinationPortName, departurePortCode, destinationPortCode, pol, pod) => {
|
||||
vi.spyOn(http, 'get').mockResolvedValue({ code: '200', data: {
|
||||
records: [{ ...detailResponse().oceanBooking, departurePortName, destinationPortName, departurePortCode, destinationPortCode }],
|
||||
page: 1, size: 20, total: 1, pages: 1,
|
||||
} })
|
||||
const result = await listOceanBookings({ page: 1, size: 20 })
|
||||
expect(result.records[0]).toMatchObject({ pol, pod, departurePortName, destinationPortName, departurePortCode, destinationPortCode })
|
||||
})
|
||||
|
||||
it('预计到港使用窄命令并规范化详情回显与列表到港字段', async () => {
|
||||
const payload = { expectedVersion: 3, estimatedArrivalAt: '2026-10-25T10:00:00' }
|
||||
const raw = detailResponse(4, 'RELEASED')
|
||||
|
||||
@@ -27,8 +27,8 @@ function booking(raw: OceanBookingResource): OceanBookingResource {
|
||||
actualPackageCount: raw.actualPackageCount == null ? null : Number(raw.actualPackageCount),
|
||||
actualGrossWeightKg: raw.actualGrossWeightKg == null ? null : Number(raw.actualGrossWeightKg),
|
||||
actualVolumeCbm: raw.actualVolumeCbm == null ? null : Number(raw.actualVolumeCbm),
|
||||
pol: raw.pol ?? raw.departurePortName ?? null,
|
||||
pod: raw.pod ?? raw.destinationPortName ?? null,
|
||||
pol: raw.departurePortName?.trim() || raw.departurePortCode?.trim() || null,
|
||||
pod: raw.destinationPortName?.trim() || raw.destinationPortCode?.trim() || null,
|
||||
carrierName: raw.carrierName ?? raw.shippingCompanyName ?? null,
|
||||
bookingAgent: raw.bookingAgent ?? raw.bookingAgentName ?? null,
|
||||
etd: raw.etd ?? raw.estimatedSailingAt ?? null,
|
||||
|
||||
Reference in New Issue
Block a user