优化
This commit is contained in:
@@ -20,19 +20,37 @@ it.each([false, true])('confirms the %s photo stage with its own evidence and cu
|
||||
const wrapper = mount(TransportExecutionPanel, { ...options, props: { dispatchNo: 'PC1', pickupApproved: true } }); await flushPromises()
|
||||
expect(wrapper.text()).toContain(arriving ? '派送中' : '装货中')
|
||||
expect(wrapper.findAll('button').some(button => button.text() === '确认发车')).toBe(false)
|
||||
await wrapper.findAll('button').find(button => button.text() === (arriving ? '上传到仓照片' : '上传取货照片'))!.trigger('click'); await flushPromises()
|
||||
await wrapper.findAll('button').find(button => button.text() === (arriving ? '上传到仓照片' : '上传装货照片'))!.trigger('click'); await flushPromises()
|
||||
if (!arriving) {
|
||||
const quantity = wrapper.get('input[role="spinbutton"]')
|
||||
expect((quantity.element as HTMLInputElement).value).toBe('')
|
||||
await quantity.setValue('3'); await quantity.trigger('change'); await flushPromises()
|
||||
}
|
||||
const input = wrapper.get('input[type="file"]')
|
||||
Object.defineProperty(input.element, 'files', { value: [new File(['photo'], '现场.jpg', { type: 'image/jpeg' })], configurable: true })
|
||||
await input.trigger('change'); await flushPromises()
|
||||
await wrapper.findAll('button').find(button => button.text() === (arriving ? '确认到仓' : '确认取货'))!.trigger('click'); await flushPromises()
|
||||
expect(commandTransport).toHaveBeenCalledWith('PC1', `pickup/C1/WT1/${arriving ? 'arrive' : 'picked'}`, expect.objectContaining({ recordVersion: 4, evidenceFileIds: ['88'], ...(arriving ? { reason: '上传到仓照片,确认取货派送完成' } : { actualPackages: 5 }) }))
|
||||
expect(commandTransport).toHaveBeenCalledWith('PC1', `pickup/C1/WT1/${arriving ? 'arrive' : 'picked'}`, expect.objectContaining({ recordVersion: 4, evidenceFileIds: ['88'], ...(arriving ? { reason: '上传到仓照片,确认取货派送完成' } : { actualPackages: 3 }) }))
|
||||
if (arriving) expect(commandTransport.mock.calls[0]![2]).not.toHaveProperty('actualPackages')
|
||||
expect(wrapper.emitted('saved')).toHaveLength(1); wrapper.unmount()
|
||||
})
|
||||
it('keeps photo confirmation unavailable until both reviews are approved', async () => {
|
||||
const wrapper = mount(TransportExecutionPanel, { ...options, props: { dispatchNo: 'PC1', pickupApproved: false } }); await flushPromises()
|
||||
expect(wrapper.findAll('button').some(button => button.text() === '上传取货照片')).toBe(false)
|
||||
expect(wrapper.findAll('button').some(button => button.text() === '上传装货照片')).toBe(false)
|
||||
expect(commandTransport).not.toHaveBeenCalled(); wrapper.unmount()
|
||||
})
|
||||
it('requires an explicitly entered pickup quantity even after a photo has uploaded', async () => {
|
||||
const wrapper = mount(TransportExecutionPanel, { ...options, props: { dispatchNo: 'PC1', pickupApproved: true } }); await flushPromises()
|
||||
await wrapper.findAll('button').find(button => button.text() === '上传装货照片')!.trigger('click'); await flushPromises()
|
||||
const input = wrapper.get('input[type="file"]')
|
||||
Object.defineProperty(input.element, 'files', { value: [new File(['photo'], '现场.jpg', { type: 'image/jpeg' })], configurable: true })
|
||||
await input.trigger('change'); await flushPromises()
|
||||
const confirm = wrapper.findAll('button').find(button => button.text() === '确认取货')!
|
||||
expect(confirm.attributes('disabled')).toBeDefined()
|
||||
await confirm.trigger('click')
|
||||
expect(commandTransport).not.toHaveBeenCalled()
|
||||
wrapper.unmount()
|
||||
})
|
||||
it.each([false, true])('renders read-only transport facts without resource editing or execution controls (%s)', async arriving => {
|
||||
const value = facts(arriving)
|
||||
value.execution.trip.vehicleId = null
|
||||
@@ -47,3 +65,20 @@ it.each([false, true])('renders read-only transport facts without resource editi
|
||||
expect(commandTransport).not.toHaveBeenCalled()
|
||||
wrapper.unmount()
|
||||
})
|
||||
it('keeps pickup addresses and contacts on their own transfer rows', async () => {
|
||||
const value = facts()
|
||||
value.pickups[0] = { ...value.pickups[0]!, pickupAddress: '100 Test Pickup Avenue', contactName: '取货联系人甲', contactPhone: '0000000001' }
|
||||
value.pickups.push({ ...value.pickups[0]!, transferNo: 'WT2', customerId: 'C2', pickupAddress: '200 Test Pickup Road', contactName: '取货联系人乙', contactPhone: '0000000002' })
|
||||
vi.mocked(getTransport).mockResolvedValue(value)
|
||||
const wrapper = mount(TransportExecutionPanel, { ...options, props: { dispatchNo: 'PC1', readonly: true } }); await flushPromises()
|
||||
const rows = wrapper.get('[aria-label="取货明细"]').findAll('tbody tr')
|
||||
expect(rows[0]!.text()).toContain('100 Test Pickup Avenue')
|
||||
expect(rows[0]!.text()).toContain('取货联系人甲')
|
||||
expect(rows[0]!.text()).toContain('0000000001')
|
||||
expect(rows[0]!.text()).not.toContain('200 Test Pickup Road')
|
||||
expect(rows[1]!.text()).toContain('200 Test Pickup Road')
|
||||
expect(rows[1]!.text()).toContain('取货联系人乙')
|
||||
expect(rows[1]!.text()).toContain('0000000002')
|
||||
expect(wrapper.findAll('button')).toHaveLength(0)
|
||||
wrapper.unmount()
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user