2026-08-08 15:15:04 +08:00
|
|
|
import { readFileSync } from 'node:fs'
|
|
|
|
|
import { resolve } from 'node:path'
|
|
|
|
|
import { describe, expect, it } from 'vitest'
|
|
|
|
|
|
|
|
|
|
const source = readFileSync(resolve(process.cwd(), 'src/modules/ocean-bookings/pages/OceanBookingDetailView.vue'), 'utf8')
|
|
|
|
|
|
2026-08-10 09:12:06 +08:00
|
|
|
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']) {
|
2026-08-08 15:15:04 +08:00
|
|
|
expect(source).toContain(field)
|
|
|
|
|
}
|
2026-08-10 09:12:06 +08:00
|
|
|
expect(source).not.toContain('goodsDescription')
|
|
|
|
|
expect(source).not.toContain('form.data.soNo')
|
2026-08-08 15:15:04 +08:00
|
|
|
})
|
|
|
|
|
|
2026-08-10 09:12:06 +08:00
|
|
|
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")
|
2026-08-08 15:15:04 +08:00
|
|
|
expect(source).toContain(':disabled="!isNew"')
|
|
|
|
|
expect(source).toContain(':disabled="!editable"')
|
2026-08-10 09:12:06 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
|
|
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')
|
2026-08-08 15:15:04 +08:00
|
|
|
})
|
|
|
|
|
})
|