优化
This commit is contained in:
@@ -26,7 +26,7 @@ vi.mock('@/modules/suppliers/api/platformSuppliers', () => ({
|
||||
}))
|
||||
|
||||
function supplier(id: string, name: string): Supplier {
|
||||
return { id, tenantId: '0', name, category: 'BOOKING', carrierCodes: ['MATSON', 'SML'], region: '宁波', legalRepresentative: '法人', contactName: '联系人', phone: '13800000000', email: null, address: null, businessLicenseNo: null, licenseFileId: null, status: 'ACTIVE', settlementPeriod: 'MONTHLY_30', remark: null, createdBy: null, createdAt: '', updatedBy: null, updatedAt: '', deleted: false, version: 1 }
|
||||
return { id, tenantId: '0', name, category: 'BOOKING', truckingScope: null, carrierCodes: ['MATSON', 'SML'], region: '宁波', legalRepresentative: '法人', contactName: '联系人', phone: '13800000000', email: null, address: null, businessLicenseNo: null, licenseFileId: null, status: 'ACTIVE', settlementPeriod: 'MONTHLY_30', remark: null, createdBy: null, createdAt: '', updatedBy: null, updatedAt: '', deleted: false, version: 1 }
|
||||
}
|
||||
|
||||
function deferred<T>() {
|
||||
@@ -152,4 +152,24 @@ describe('supplier route reuse', () => {
|
||||
expect(mocks.listSuppliers).toHaveBeenCalledTimes(2)
|
||||
expect(mocks.getSupplierStats).toHaveBeenCalledTimes(2)
|
||||
})
|
||||
it('requires one trucking type, saves overseas and clears the type after changing category', async () => {
|
||||
mocks.getSupplier.mockResolvedValue({ ...supplier('A', '车队'), category: 'TRUCKING', carrierCodes: [], truckingScope: null })
|
||||
const wrapper = mount(SupplierFormView, { global: { plugins: [ElementPlus], stubs } })
|
||||
await flushPromises()
|
||||
const save = wrapper.findAll('button').find((button) => button.text().includes('保存'))!
|
||||
await save.trigger('click'); await flushPromises()
|
||||
expect(mocks.updateSupplier).not.toHaveBeenCalled()
|
||||
expect(wrapper.findAllComponents({ name: 'ElFormItem' }).find(item => item.props('prop') === 'truckingScope')?.props('error')).toBe('请选择国内拖车或海外车队')
|
||||
const radios = wrapper.findComponent({ name: 'ElRadioGroup' })
|
||||
expect(radios.text()).toContain('国内拖车')
|
||||
expect(radios.text()).toContain('海外车队')
|
||||
radios.vm.$emit('update:modelValue', 'OVERSEAS')
|
||||
await flushPromises(); await save.trigger('click'); await flushPromises()
|
||||
expect(mocks.updateSupplier).toHaveBeenLastCalledWith('A', expect.objectContaining({ category: 'TRUCKING', truckingScope: 'OVERSEAS' }))
|
||||
wrapper.findAllComponents({ name: 'ElSelect' })[0]!.vm.$emit('update:modelValue', 'CUSTOMS')
|
||||
await flushPromises(); await save.trigger('click'); await flushPromises()
|
||||
expect(wrapper.findComponent({ name: 'ElRadioGroup' }).exists()).toBe(false)
|
||||
expect(mocks.updateSupplier).toHaveBeenLastCalledWith('A', expect.objectContaining({ category: 'CUSTOMS', truckingScope: null }))
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user