2026-08-11 18:06:35 +08:00
|
|
|
import { describe, expect, it } from 'vitest'
|
|
|
|
|
import { readFileSync } from 'node:fs'
|
|
|
|
|
import { resolve } from 'node:path'
|
|
|
|
|
|
|
|
|
|
const source = readFileSync(resolve(process.cwd(), 'src/modules/trucking/components/TruckAppointmentForm.vue'), 'utf8')
|
|
|
|
|
|
|
|
|
|
describe('TruckAppointmentForm interaction contract', () => {
|
|
|
|
|
it('uses searchable business selectors for shared resources', () => {
|
|
|
|
|
expect(source).toContain('listPlatformTenants')
|
2026-08-15 11:06:04 +08:00
|
|
|
expect(source).toContain('listSuppliers')
|
2026-08-11 18:06:35 +08:00
|
|
|
expect(source).toContain('listContainers')
|
|
|
|
|
expect(source).toContain('listOceanBookings')
|
|
|
|
|
expect(source).toContain('listAllPlatformWarehouses')
|
|
|
|
|
expect(source).not.toContain('label="承运商 ID"')
|
|
|
|
|
expect(source).not.toContain('label="客户关联 ID"')
|
2026-08-14 13:03:11 +08:00
|
|
|
expect(source).toContain("listPlatformTenants({ page: 1, size: 200, status: 'ACTIVE' })")
|
2026-08-15 11:06:04 +08:00
|
|
|
expect(source).toContain("listSuppliers({ page: 1, size: 200, category: 'TRUCKING', status: 'ACTIVE' })")
|
2026-08-14 14:27:03 +08:00
|
|
|
expect(source).toContain('function customerLabel(customer: PlatformTenantResource) { return customer.tenantName }')
|
2026-08-14 13:03:11 +08:00
|
|
|
expect(source).not.toContain('customer.tenantCode')
|
2026-08-11 18:06:35 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it('synchronizes ids and names and recovers failed option loading', () => {
|
|
|
|
|
expect(source).toContain('selectCarrier')
|
2026-08-15 11:06:04 +08:00
|
|
|
expect(source).toContain("item.category === 'TRUCKING' && item.status === 'ACTIVE'")
|
|
|
|
|
expect(source).toContain('请选择有效的合作中拖车供应商')
|
2026-08-11 18:06:35 +08:00
|
|
|
expect(source).toContain('draft.carrierName')
|
|
|
|
|
expect(source).toContain('selectCustomer')
|
|
|
|
|
expect(source).toContain('draft.customerName')
|
|
|
|
|
expect(source).toContain('selectContainer')
|
|
|
|
|
expect(source).toContain('draft.loadingPlanId = item.planId')
|
|
|
|
|
expect(source).toContain('重新加载选项')
|
|
|
|
|
})
|
|
|
|
|
|
2026-08-12 09:25:55 +08:00
|
|
|
it('hides inactive options while preserving resources already bound to an appointment', () => {
|
2026-08-15 11:06:04 +08:00
|
|
|
expect(source).toContain("item.status === 'ACTIVE'")
|
2026-08-12 09:25:55 +08:00
|
|
|
expect(source).toContain("item.status === 'ACTIVE' || String(item.id) === String(draft.warehouseId)")
|
|
|
|
|
expect(source).toContain('v-for="item in selectableCustomers"')
|
|
|
|
|
expect(source).toContain('v-for="item in selectableWarehouses"')
|
|
|
|
|
expect(source).not.toContain(':disabled="item.status !== \'ACTIVE\'')
|
|
|
|
|
})
|
|
|
|
|
|
2026-08-11 18:06:35 +08:00
|
|
|
it('gives editable fields clear placeholders', () => {
|
|
|
|
|
expect(source).toContain('placeholder="请输入司机姓名"')
|
|
|
|
|
expect(source).toContain('placeholder="请选择预计装箱时间"')
|
|
|
|
|
expect(source).toContain('placeholder="请输入目的门店地址"')
|
|
|
|
|
expect(source).toContain('placeholder="请输入拖车预约备注(可选)"')
|
|
|
|
|
})
|
2026-08-15 17:04:00 +08:00
|
|
|
|
|
|
|
|
it('labels the generated cabinet reference and physical container number separately', () => {
|
|
|
|
|
expect(source).toContain('柜次号:${item.cabinetNo')
|
|
|
|
|
expect(source).toContain('集装箱号:${item.containerNo')
|
|
|
|
|
})
|
2026-08-11 18:06:35 +08:00
|
|
|
})
|