fix(fleet): leave unknown vehicle fuel consumption empty
This commit is contained in:
@@ -52,3 +52,21 @@ it('keeps loading until the currently selected query finishes', async () => {
|
||||
expect(wrapper.findComponent({ name: 'DataTable' }).props('loading')).toBe(false)
|
||||
expect(api.listVehicles).toHaveBeenCalledTimes(2)
|
||||
})
|
||||
|
||||
it('opens a new vehicle with unknown fuel consumption blank instead of clamping it to 0.01', async () => {
|
||||
vi.mocked(api.listVehicles).mockResolvedValue({ records: [], total: 0, page: 1, size: 20, pages: 0 })
|
||||
const wrapper = shallowMount(VehiclesView, { global: { stubs: {
|
||||
AdminPage: layout, ListPageLayout: layout, QueryToolbar: true, LoadErrorState: true,
|
||||
DataTable: { ...table, template: '<div><slot name="toolbar-actions"/></div>' },
|
||||
AppDialog: { name: 'AppDialog', props: ['modelValue'], emits: ['confirm'], template: '<div v-if="modelValue"><slot/><button @click="$emit(\'confirm\')">保存</button></div>' },
|
||||
ElButton: { template: '<button><slot/></button>' }, ElForm: layout, ElFormItem: layout,
|
||||
ElInputNumber: { name: 'ElInputNumber', props: ['modelValue'], template: '<input :value="modelValue" />' }, ElInput: true, ElSelect: true, ElOption: true, ElTag: true,
|
||||
} } })
|
||||
wrappers.push(wrapper); await flushPromises()
|
||||
await wrapper.findAll('button').find(button => button.text() === '添加车辆')!.trigger('click')
|
||||
await flushPromises()
|
||||
expect(wrapper.findAllComponents({ name: 'ElInputNumber' })[0]!.get('input').element.value).toBe('')
|
||||
await wrapper.findAll('button').find(button => button.text() === '保存')!.trigger('click')
|
||||
await flushPromises()
|
||||
expect(api.createVehicle).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user