2026-08-19 16:45:51 +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/port-schedules/components/CarrierScheduleQueryPanel.vue'), 'utf8')
|
|
|
|
|
|
|
|
|
|
describe('CarrierScheduleQueryPanel', () => {
|
|
|
|
|
it('uses the existing relation filters and never creates or executes polling tasks', () => {
|
|
|
|
|
expect(source).toContain('listCarrierScheduleQueries({ page: 1, size: 200')
|
|
|
|
|
expect(source).toContain('oceanBookingId: props.oceanBookingId')
|
|
|
|
|
expect(source).toContain('containerBookingId: props.containerBookingId')
|
|
|
|
|
expect(source).not.toContain('createCarrierSchedule')
|
2026-08-21 16:04:24 +08:00
|
|
|
expect(source).not.toContain(['attempt', 'CarrierSchedule'].join(''))
|
2026-08-19 16:45:51 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it('shows source, observation/update times, history, failures and expiry truthfully', () => {
|
|
|
|
|
expect(source).toContain('最新来源')
|
2026-08-20 09:10:36 +08:00
|
|
|
expect(source).toContain('访问方式')
|
2026-08-19 16:45:51 +08:00
|
|
|
expect(source).toContain('观测时间')
|
|
|
|
|
expect(source).toContain('来源更新时间')
|
2026-08-20 18:02:52 +08:00
|
|
|
expect(source).toContain('标准节点历史')
|
|
|
|
|
expect(source).toContain('节点位置')
|
2026-08-21 16:04:24 +08:00
|
|
|
expect(source).toContain('任务操作状态')
|
|
|
|
|
expect(source).toContain('实际发生时间')
|
2026-08-19 16:45:51 +08:00
|
|
|
expect(source).toContain('变更历史')
|
|
|
|
|
expect(source).toContain('query.lastErrorMessage')
|
2026-08-20 09:10:36 +08:00
|
|
|
expect(source).toContain('query.lastErrorCode')
|
2026-08-21 16:04:24 +08:00
|
|
|
expect(source).toContain("queryView?.expired ? '结果已过期' : '结果有效'")
|
2026-08-19 16:45:51 +08:00
|
|
|
})
|
|
|
|
|
|
2026-08-20 09:10:36 +08:00
|
|
|
it('keeps query-history and linked-schedule partial failures independently visible', () => {
|
|
|
|
|
expect(source).toContain('queryDetailError')
|
|
|
|
|
expect(source).toContain('scheduleError')
|
2026-08-20 18:02:52 +08:00
|
|
|
expect(source).toContain('标准节点与变更历史暂不可用')
|
2026-08-20 09:10:36 +08:00
|
|
|
expect(source).toContain('关联船期结果暂不可用')
|
|
|
|
|
})
|
|
|
|
|
|
2026-08-21 16:04:24 +08:00
|
|
|
it('shows all ten canonical nodes and stops only on actual empty return', () => {
|
|
|
|
|
for (const node of ['DEPARTED_WAREHOUSE', 'AT_ORIGIN_PORT', 'LOADED_ON_VESSEL', 'DEPARTED_ORIGIN_PORT', 'IN_TRANSIT', 'ARRIVED_DESTINATION_PORT', 'DISCHARGED_FROM_VESSEL', 'PICKUP_READY', 'PICKED_UP', 'EMPTY_RETURNED']) expect(source).toContain(node)
|
|
|
|
|
expect(source).not.toMatch(new RegExp(`\\b${['ARR', 'IVED'].join('')}:`))
|
|
|
|
|
expect(source).toContain("latestActualNode === 'EMPTY_RETURNED'")
|
|
|
|
|
expect(source).toContain("'已停止 · 已还柜'")
|
2026-08-20 18:02:52 +08:00
|
|
|
expect(source).toContain('任务仅在确认国内出仓后自动建立')
|
2026-08-21 16:04:24 +08:00
|
|
|
expect(source).not.toContain('/' + 'scheduler')
|
|
|
|
|
expect(source).not.toContain('/' + 'attempts')
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it('keeps estimated facts labelled and separate from actual progress', () => {
|
|
|
|
|
expect(source).toContain("item.actualAt ? `实际")
|
|
|
|
|
expect(source).toContain(": item.estimatedAt ? `预计")
|
|
|
|
|
expect(source).toContain('latestActualNode')
|
|
|
|
|
expect(source).toContain('item.actualAt')
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it('uses the frozen manual-node permission and keeps exceptions separate', () => {
|
|
|
|
|
expect(source).toContain("access.can('platform:firstleg:port-schedule-query:manual')")
|
|
|
|
|
expect(source).toContain('appendCarrierScheduleManualNode')
|
|
|
|
|
expect(source).toContain('manualIdempotencyKey')
|
|
|
|
|
expect(source).toContain('异常事实')
|
|
|
|
|
expect(source).toContain('item.providerStatus')
|
|
|
|
|
expect(source).not.toContain('/' + 'manual-results')
|
2026-08-19 16:45:51 +08:00
|
|
|
})
|
|
|
|
|
})
|