50 lines
3.0 KiB
TypeScript
50 lines
3.0 KiB
TypeScript
import { readFileSync } from 'node:fs'
|
|
import { resolve } from 'node:path'
|
|
import { describe, expect, it } from 'vitest'
|
|
|
|
const apiSource = readFileSync(resolve(process.cwd(), 'src/modules/overseas-warehouse/api/lastMileOrders.ts'), 'utf8')
|
|
const pageSource = readFileSync(resolve(process.cwd(), 'src/modules/overseas-warehouse/pages/LastMileOrdersView.vue'), 'utf8')
|
|
|
|
describe('container inbound plan preview contract', () => {
|
|
it('uses the backend preview endpoint with the stable container booking id', () => {
|
|
expect(apiSource).toContain("'/platform/v1/last-leg/inbound-plans/container-preview'")
|
|
expect(apiSource).toContain('{ params: { sourceContainerBookingId } }')
|
|
})
|
|
|
|
it('renders backend groups, pallet totals, readiness and blockers without local grouping or sorting', () => {
|
|
expect(pageSource).toContain('containerPreview.pendingPalletCount')
|
|
expect(pageSource).toContain('containerPreview.sourcePalletCount')
|
|
expect(pageSource).toContain('containerPreview.supplementPalletCount')
|
|
expect(pageSource).toContain('v-for="group in containerPreview.groups"')
|
|
expect(pageSource).toContain('readinessText(row.readiness)')
|
|
expect(pageSource).toContain("RESOURCE_PENDING' ? '将自动补齐'")
|
|
expect(pageSource).toContain('blockerText(row.blockers)')
|
|
expect(pageSource).not.toContain('containerPreview.groups.sort(')
|
|
})
|
|
|
|
it('requests one preview per selection and submits one atomic snapshot command', () => {
|
|
expect(pageSource.match(/await getContainerInboundPlanPreview\(sourceContainerBookingId\)/g)).toHaveLength(1)
|
|
expect(pageSource).toContain('containerPreviewLoadingBookingId === sourceContainerBookingId')
|
|
expect(pageSource).toContain('request !== containerPreviewRequest || selectedContainerBookingId.value !== sourceContainerBookingId || !containerConvertOpen.value')
|
|
expect(pageSource).toContain('containerPreviewRequest += 1')
|
|
expect(pageSource.match(/await convertLastMileContainerToInboundPlans\(\{/g)).toHaveLength(1)
|
|
expect(pageSource).toContain('snapshotVersion: preview.snapshotVersion')
|
|
expect(pageSource).toContain('snapshotHash: preview.snapshotHash')
|
|
expect(pageSource).toContain('containerConversionIdempotencyKey')
|
|
expect(pageSource).toContain(':confirm-disabled="containerConfirmDisabled"')
|
|
})
|
|
|
|
it('shows returned plan numbers and real pallet numbers then refreshes the page and preview', () => {
|
|
expect(pageSource).toContain('containerConversionResult.plans')
|
|
expect(pageSource).toContain('plan.pallets')
|
|
expect(pageSource).toContain('pallet.palletNo')
|
|
expect(pageSource).toContain('Promise.all([load(), loadContainerPreview(bookingId, true)])')
|
|
})
|
|
|
|
it('translates known blockers and never exposes unknown internal blocker codes', () => {
|
|
expect(pageSource).toContain("PALLET_COUNT_NOT_READY: '计划托数暂未就绪'")
|
|
expect(pageSource).toContain("labels[code] || '计划数据暂未就绪,请刷新或联系管理员'")
|
|
expect(pageSource).not.toContain('labels[code] || code')
|
|
})
|
|
})
|