- 物料默认单位由 pcs 改为「个」,新建/编辑表单与后端 Create 保持一致 - 单位下拉增加未选择时的默认提示 - init.sql 补充 30 个常用计量单位种子数据 - init.sql 新增 material_import_logs 表,为批量导入提供落库 - 新增物料批量导入实施计划文档,相关测试期望值同步更新
52 lines
1.3 KiB
JavaScript
52 lines
1.3 KiB
JavaScript
import { describe, expect, it } from 'vitest'
|
|
import { createMaterialForm, toMaterialPayload } from './materialForm'
|
|
|
|
const categories = [
|
|
{ id: 1, code: 'A01', name: '标准件', parent_id: null },
|
|
{ id: 12, code: 'A01-01', name: '标准件·通用型', parent_id: 1 }
|
|
]
|
|
|
|
describe('material master-data form', () => {
|
|
it('contains only material master-data fields', () => {
|
|
expect(createMaterialForm()).toEqual({
|
|
material_code: '',
|
|
name: '',
|
|
spec: '',
|
|
category: '',
|
|
unit: '个',
|
|
material_image: '',
|
|
major_category_id: null,
|
|
category_id: null,
|
|
base_unit_id: null
|
|
})
|
|
})
|
|
|
|
it('restores category selections and submits their persisted ids', () => {
|
|
const form = createMaterialForm({
|
|
material_code: 'MAT-001',
|
|
name: '轴承',
|
|
spec: '6205',
|
|
category: 'A01-01',
|
|
category_id: 12,
|
|
base_unit_id: 3,
|
|
unit: '件',
|
|
material_image: '',
|
|
total_on_hand: 99,
|
|
warning_stock: 10
|
|
}, categories)
|
|
|
|
expect(form.major_category_id).toBe(1)
|
|
expect(form.category_id).toBe(12)
|
|
expect(toMaterialPayload(form)).toEqual({
|
|
material_code: 'MAT-001',
|
|
name: '轴承',
|
|
spec: '6205',
|
|
category: 'A01-01',
|
|
category_id: 12,
|
|
base_unit_id: 3,
|
|
unit: '件',
|
|
material_image: ''
|
|
})
|
|
})
|
|
})
|