优化优化

This commit is contained in:
2026-08-11 18:06:35 +08:00
parent 8a8c5a3faa
commit 03e1cd0c80
40 changed files with 2092 additions and 354 deletions
@@ -4,30 +4,29 @@ import { describe, expect, it } from 'vitest'
const source = readFileSync(resolve(process.cwd(), 'src/modules/ocean-bookings/pages/OceanBookingDetailView.vue'), 'utf8')
describe('OceanBookingDetailView contract', () => {
it('uses the backend draft fields and all required parties', () => {
for (const field of ['SHIPPER', 'CONSIGNEE', 'NOTIFY_PARTY', 'partyName', 'departurePortName', 'destinationPortName', 'vesselName', 'voyageNo', 'containerRequirements']) {
expect(source).toContain(field)
}
expect(source).not.toContain('goodsDescription')
expect(source).not.toContain('form.data.soNo')
describe('OceanBookingDetailView interaction contract', () => {
it('selects business objects and automatically keeps their ids and names together', () => {
expect(source).toContain('placeholder="请选择客户"')
expect(source).toContain('placeholder="请选择船公司"')
expect(source).toContain('placeholder="请选择订舱代理"')
expect(source).toContain("selectPartner('shippingCompany'")
expect(source).toContain("selectPartner('bookingAgent'")
expect(source).not.toContain('label="客户 ID"')
expect(source).not.toContain('label="船公司 ID"')
expect(source).not.toContain('label="订舱代理 ID"')
})
it('reads the real version and protects create/edit permissions', () => {
expect(source).toContain('form.expectedVersion = value.version')
expect(source).toContain('expectedVersion: 0')
expect(source).toContain("platform:firstleg:ocean-booking:create")
expect(source).toContain("platform:firstleg:ocean-booking:edit")
expect(source).toContain(':disabled="!isNew"')
expect(source).toContain(':disabled="!editable"')
it('hides unavailable customers instead of filling the selector with disabled options', () => {
expect(source).toContain("customer.status === 'ACTIVE' || String(customer.id) === String(form.data.customerId)")
expect(source).toContain('v-for="customer in selectableCustomers"')
expect(source).not.toContain(':disabled="customer.status !== \'ACTIVE\'"')
})
it('maps each status action to its server permission and uses a change-specific request', () => {
for (const permission of ['submit', 'confirm', 'release', 'cancel', 'change']) {
expect(source).toContain(`platform:firstleg:ocean-booking:${permission}`)
}
expect(source).toContain('requestOceanBookingChange')
expect(source).toContain("changeForm.vesselName = detail.value?.vesselName")
expect(source).toContain('expectedVersion: detail.value.version')
it('provides guidance for every free-text booking field', () => {
for (const placeholder of [
'请输入提单号(可选)', '请输入船名', '请输入航次', '例如:CNNGB', '例如:宁波港',
'例如:USLAX', '例如:洛杉矶港', '请输入最终交货地点', '例如:CY-CY',
'例如:PREPAID', '请输入订舱备注(可选)',
]) expect(source).toContain(`placeholder="${placeholder}"`)
})
})