test(firstleg): use valid PDF truck fixtures

This commit is contained in:
2026-09-01 14:44:30 +08:00
parent 105660bd09
commit f0ac0c42c9
2 changed files with 31 additions and 3 deletions
@@ -2,7 +2,19 @@ import assert from 'node:assert/strict'
import { readFileSync } from 'node:fs'
import test from 'node:test'
import { activeCustomerIdentity, inspectOceanBookingIdentity, platformWarehouseIdentity, truckAppointmentPayload } from './truck-appointments.mjs'
import { activeCustomerIdentity, inspectOceanBookingIdentity, minimalPdfBytes, platformWarehouseIdentity, truckAppointmentPayload } from './truck-appointments.mjs'
test('PDF upload fixtures contain real PDF magic bytes instead of MIME-only text', () => {
const bytes = minimalPdfBytes('RUN-2-DISPATCH_ORDER')
const content = Buffer.from(bytes).toString('ascii')
assert.equal(content.slice(0, 5), '%PDF-')
assert.match(content, /%%EOF\n$/)
const source = readFileSync(new URL('truck-appointments.mjs', import.meta.url), 'utf8')
assert.match(source, /new Blob\(\[minimalPdfBytes\(`\$\{context\.marker\}-BILL_OF_LADING`\)\], \{ type: 'application\/pdf' \}\)/)
assert.match(source, /new Blob\(\[minimalPdfBytes\(`\$\{context\.marker\}-DISPATCH_ORDER`\)\], \{ type: 'application\/pdf' \}\)/)
assert.doesNotMatch(source, /new Blob\(\[\s*`\$\{context\.marker\}-(?:BILL_OF_LADING|DISPATCH_ORDER)`\s*\], \{ type: 'application\/pdf' \}\)/)
})
test('booking prerequisite resolves an ACTIVE platform customer without fixture state', () => {
assert.deepEqual(activeCustomerIdentity({ id: '21', tenantName: '现有客户' }),