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')
|
|
|
|
|
expect(source).toContain('listPlatformPartners')
|
|
|
|
|
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' })")
|
|
|
|
|
expect(source).toContain('customer.legalName?.trim() || customer.tenantName')
|
|
|
|
|
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')
|
|
|
|
|
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', () => {
|
|
|
|
|
expect(source).toContain("item.status === 'ACTIVE' || String(item.id) === String(draft.customerId)")
|
|
|
|
|
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="请输入拖车预约备注(可选)"')
|
|
|
|
|
})
|
|
|
|
|
})
|