diff --git a/src/modules/container-loading/pages/ContainersView.test.ts b/src/modules/container-loading/pages/ContainersView.test.ts index 9675af1d..b61f729e 100644 --- a/src/modules/container-loading/pages/ContainersView.test.ts +++ b/src/modules/container-loading/pages/ContainersView.test.ts @@ -88,7 +88,14 @@ describe('ContainersView', () => { expect(wrapper.text()).not.toContain('报空预警') }) - it('shows one direct empty-return action only when permission and server actions allow it', async () => { + it.each([3, 0])('submits direct empty return with server version %s, including unload without pickup', async (version) => { + const original = await listContainers({ page: 1, size: 20 }, 'OVERSEAS') + vi.mocked(listContainers).mockClear().mockResolvedValue({ ...original, records: original.records.map((row) => ({ + ...row, + terminalDrayage: { ...drayage, version, actualPickupAt: version ? drayage.actualPickupAt : null, + fleetSupplierId: version ? drayage.fleetSupplierId : null, allowedActions: ['RECORD_EMPTY_RETURN'], + emptyReturnWarning: { status: 'PENDING', deadlineAt: drayage.estimatedEmptyReturnAt, overdueHours: 0, overdueDays: 0 } }, + })) }) const wrapper = await mountOverseasRoute() expect(listContainers).toHaveBeenCalledWith(expect.objectContaining({ scope: 'ACTIVE' }), 'OVERSEAS') const buttons = wrapper.findAll('button').filter((item) => item.text().includes('确认还柜')) @@ -105,7 +112,7 @@ describe('ContainersView', () => { confirm.click() await flushPromises() expect(recordTerminalDrayageEmptyReturn).toHaveBeenCalledTimes(1) - expect(recordTerminalDrayageEmptyReturn).toHaveBeenCalledWith('9001', { expectedVersion: 3, actualAt: '2026-09-11T13:00:00', remark: '还柜凭证已核对' }) + expect(recordTerminalDrayageEmptyReturn).toHaveBeenCalledWith('9001', { expectedVersion: version, actualAt: '2026-09-11T13:00:00', remark: '还柜凭证已核对' }) expect(wrapper.text()).toContain('已还柜') expect(listContainers).toHaveBeenCalledTimes(callsBefore + 1) expect(wrapper.findAll('.row-actions button').some((button) => button.text() === '确认还柜')).toBe(false)