Files
admin-web/src/modules/trucking/pages/TruckAppointmentCreateView.test.ts
T

35 lines
1.7 KiB
TypeScript
Raw Normal View History

2026-08-18 09:09:34 +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/pages/TruckAppointmentCreateView.vue'), 'utf8')
describe('TruckAppointmentCreateView booking-bound creation contract', () => {
it('starts with required booking and container choices empty until the user selects them', () => {
expect(source).toContain('carrierId: null')
expect(source).not.toContain('customerId')
2026-08-18 09:09:34 +08:00
expect(source).toContain('oceanBookingId: null, containerBookingId: null, loadingPlanId: null')
expect(source).toContain('plannedLoadingAt: null')
expect(source).toContain("payableAmount: '0.00', currency: 'RMB'")
expect(source).not.toContain('receivableAmount')
2026-08-18 09:09:34 +08:00
expect(source).toContain('createTruckAppointment({ ...form })')
})
it('keeps the form visible and exposes the real backend error details', () => {
expect(source).toContain("getApiErrorDetails(err, '创建失败,请稍后重试')")
expect(source).toContain('<ApiErrorMeta :details="error" />')
expect(source).toContain('<TruckAppointmentForm v-model="form"')
})
2026-08-20 09:10:36 +08:00
it('suppresses duplicate submits while the first create request is pending', () => {
expect(source).toContain('if (saving.value) return')
})
2026-08-20 09:10:36 +08:00
it('places the return action beside the relation note instead of in a separate header row', () => {
expect(source).toContain('<template #relation-note-actions>')
expect(source).toContain('<ArrowLeft :size="16" />返回列表')
expect(source).not.toContain('<template #header>')
expect(source).not.toContain('class="editor-actions"')
})
2026-08-18 09:09:34 +08:00
})