fix(fleet): normalize nullable maintenance fields before editing
This commit is contained in:
@@ -29,6 +29,15 @@ function mount(component: object, props: Record<string, unknown>): VueWrapper {
|
||||
}
|
||||
beforeEach(() => { vi.clearAllMocks(); access.write = true; vi.mocked(api.listVehicleCare).mockResolvedValue({ records: [structuredClone(row)], page: 1, size: 10, total: 1, pages: 1 }) })
|
||||
afterEach(() => wrappers.splice(0).forEach(wrapper => wrapper.unmount()))
|
||||
it('saving an unchanged record does not create a correction due to JSON property order', async () => {
|
||||
const record = structuredClone(row)
|
||||
record.details = Object.fromEntries(Object.entries(record.details).reverse()) as typeof record.details
|
||||
const wrapper = mount(VehicleCareEditor, { modelValue: false, vehicleId: '71', plate: 'VEH-A', recordType: 'FUEL', record })
|
||||
await wrapper.setProps({ modelValue: true })
|
||||
wrapper.findComponent({ name: 'AppDialog' }).vm.$emit('confirm'); await flushPromises()
|
||||
expect(api.updateVehicleCare).not.toHaveBeenCalled()
|
||||
expect(wrapper.emitted('saved')).toHaveLength(1)
|
||||
})
|
||||
it('loads care only after the detail tab is selected', async () => {
|
||||
vi.mocked(getVehicle).mockResolvedValue({ id: '71', plateNumber: 'VEH-A', model: 'Truck', fuelConsumptionPer100Km: 10, mileageKm: 1000, region: 'OVERSEAS', ownership: 'OWNED', status: 'IN_SERVICE', recordVersion: 0 } as Awaited<ReturnType<typeof getVehicle>>)
|
||||
const wrapper = mount(VehicleDetailView, {}); await flushPromises()
|
||||
|
||||
@@ -38,7 +38,7 @@ watch([open, identity], ([value, target], [, previousTarget]) => {
|
||||
lastServiceOdometer: null, nextServiceOdometer: null, fuelQuantity: null, fuelUnit: props.recordType === 'FUEL' ? 'L' : null,
|
||||
verificationStatus: meterRecord.value ? 'PENDING' : null, remark: null, incident: meterRecord.value ? null
|
||||
: { description: '', item: null, place: null, handler: null, processingStatus: 'PENDING', exceptionType: null, reportedCost: null, currency: null } })
|
||||
lastSaved = props.record ? JSON.stringify(props.record.details) : ''
|
||||
lastSaved = props.record ? JSON.stringify(form) : ''
|
||||
})
|
||||
function selectFiles(event: Event) {
|
||||
const element = event.target as HTMLInputElement
|
||||
|
||||
Reference in New Issue
Block a user