import { afterEach, beforeEach, expect, it, vi } from 'vitest' import { flushPromises, shallowMount } from '@vue/test-utils' import TripAssignmentPanel from './TripAssignmentPanel.vue' import { listVehicles } from '../api/overseasMasterData' import { listDrivers } from '../api/drivers' import { assignTrip, getTripResourceOccupancy } from '../api/trips' import type { TripDetail } from '../tripTypes' import type { VehicleDetail } from '../types' import type { DriverDetail } from '../driverTypes' vi.mock('element-plus', () => ({ ElMessage: { warning: vi.fn(), success: vi.fn() } })) vi.mock('../api/overseasMasterData', () => ({ listVehicles: vi.fn() })) vi.mock('../api/drivers', () => ({ listDrivers: vi.fn() })) vi.mock('../api/trips', () => ({ assignTrip: vi.fn(), getTripResourceOccupancy: vi.fn() })) const vehicle: VehicleDetail = { id: '9007199254740999', plateNumber: 'TEST-FREE', model: '26ft', maxPalletSpaces: 12, maxLoadKg: 8000, maxVolumeCbm: 45, fuelConsumptionPer100Km: 20, mileageKm: 0, driverOrDispatchCompany: null, phone: null, region: 'OVERSEAS', ownership: 'OWNED', status: 'IN_SERVICE', remark: null, recordVersion: 0, updatedBy: '1', updatedAt: '' } const driver: DriverDetail = { id: '9007199254740998', driverNo: 'DR-TEST', details: { name: '验收司机', phone: '000', ownership: 'OWNED', region: 'OVERSEAS', licenseNumber: null, licenseType: null, licenseIssuedOn: null, licenseExpiresOn: '2030-12-31', licenseZone: 'UTC', remark: null, profile: null }, active: true, reviewStatus: 'APPROVED', licenseFileId: '1', recordVersion: 0, updatedBy: '1', updatedAt: '', qualification: { canDispatch: true, expiringSoon: false, reason: 'ELIGIBLE', licenseExpiresOn: '2030-12-31' }, licenseState: 'VALID', warehouseCode: null, warehouseName: null } const trip: TripDetail = { trip: { tripNo: 'TR-CURRENT', status: 'PLANNED', warehouseId: '1', warehouseCode: 'WH', warehouseName: '仓库', vehicleId: null, vehiclePlate: null, driverId: null, driverName: null, driverPhone: null, maxPalletSpaces: null, maxLoadKg: null, maxVolumeCbm: null, plannedDepartureAt: '2026-10-18T01:00:00Z', expectedDriverEndAt: '2026-10-18T09:00:00Z', departedAt: null, completedAt: null, stops: [], remark: null, recordVersion: 1, updatedAt: '', vehicleRelease: null, driverRelease: null }, driverQualification: null, dispatches: [], loadingReview: { status: 'PENDING', reason: null, reviewerId: null, reviewedAt: null, recordVersion: null }, previousDispatches: [], appointmentHistoryUnavailableReason: null } function mount() { return shallowMount(TripAssignmentPanel, { props: { detail: trip }, global: { stubs: { ElForm: { template: '
' }, ElFormItem: { template: '