fix(fleet): leave unknown vehicle fuel consumption empty

This commit is contained in:
2026-10-03 19:41:55 +08:00
parent 049f895b44
commit 60dd86ab88
2 changed files with 21 additions and 3 deletions
@@ -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()
})