import assert from 'node:assert/strict' import { existsSync, readFileSync } from 'node:fs' import { dirname, resolve } from 'node:path' import test from 'node:test' import { fileURLToPath } from 'node:url' const scriptsDir = dirname(fileURLToPath(import.meta.url)) const backendScript = readFileSync(resolve(scriptsDir, 'backend-full-regression.ps1'), 'utf8') const adminAcceptance = readFileSync(resolve(scriptsDir, 'admin-test-env-acceptance.mjs'), 'utf8') test('backend full regression includes file reactor and critical file/container coverage', () => { assert.match(backendScript, /-pl["',\s\S]*order,firstleg,iam,gateway,file/) for (const required of [ 'file/src/test/java/com/baiyue/file/controller/QualificationFileContractTest.java', 'file/src/test/java/com/baiyue/file/controller/InternalBusinessFileControllerTest.java', 'file/src/test/java/com/baiyue/file/service/InternalBusinessFileServiceTest.java', 'firstleg/src/test/java/com/baiyue/firstleg/controller/ContainerControllerContractTest.java', 'firstleg/src/test/java/com/baiyue/firstleg/controller/LoadingListControllerContractTest.java', 'firstleg/src/test/java/com/baiyue/firstleg/repository/ContainerOverviewSqlContractTest.java', 'firstleg/src/test/java/com/baiyue/firstleg/service/ContainerOverviewServiceTest.java', 'firstleg/src/test/java/com/baiyue/firstleg/service/LoadingListServiceTest.java', ]) assert.match(backendScript, new RegExp(required.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'))) }) test('test-environment full acceptance registers container overview module', () => { const modulePath = resolve(scriptsDir, 'admin-test-env-modules', 'phase3-container-overview.mjs') if (!adminAcceptance.includes('phase3-container-overview') || !existsSync(modulePath)) { assert.fail('default acceptance module phase3-container-overview is not registered yet') } }) test('test-environment full acceptance executes warehouse-scoped booking channel isolation', () => { const loadingModulePath = resolve(scriptsDir, 'admin-test-env-modules', 'phase3-container-loading.mjs') const fixturePath = resolve(scriptsDir, 'admin-test-env-modules', 'ocean-booking-fixture.mjs') assert.match(adminAcceptance, /CONFIGURED_MODULES\s*=\s*\[[^\]]*'phase3-container-loading'/s) assert.ok(existsSync(loadingModulePath), 'phase3-container-loading module is missing') assert.ok(existsSync(fixturePath), 'shared ocean booking fixture is missing') const loadingModule = readFileSync(loadingModulePath, 'utf8') const fixture = readFileSync(fixturePath, 'utf8') assert.match(loadingModule, /publishPlatformLogisticsChannels\(context, warehouseId, MODULE\)/) assert.match(loadingModule, /selectPlatformChannelIsolationPair/) assert.match(loadingModule, /BLOCKED_FIXTURE/) assert.match(fixture, /\/api\/platform\/v1\/ocean-bookings\/channels/) assert.match(fixture, /createdResources\.platformLogisticsChannels/) }) test('test-environment full acceptance keeps assigned and unassigned customer booking chains', () => { const loadingIndex = adminAcceptance.indexOf("'phase3-container-loading'") const bookingIndex = adminAcceptance.indexOf("'ocean-bookings'") assert.ok(loadingIndex >= 0 && bookingIndex > loadingIndex, 'ocean-bookings must run after the assigned-customer container fixture') const bookingModule = readFileSync(resolve(scriptsDir, 'admin-test-env-modules', 'ocean-bookings.mjs'), 'utf8') assert.match(bookingModule, /oceanBookingDraftWithoutCustomer/) assert.match(bookingModule, /createdResources\.oceanBookingUnassignedCustomer/) assert.match(bookingModule, /customerId == null[\s\S]*customerName == null/) assert.match(bookingModule, /status === 'CONFIRMED'[\s\S]*containerAllocations\?\.length === 0/) assert.match(bookingModule, /keyword=\$\{encodeURIComponent\(bookingNo\)\}/) assert.doesNotMatch(bookingModule, /keyword=\$\{encodeURIComponent\(context\.marker\)\}/) assert.match(bookingModule, /指定客户订舱持久化本轮客户范围快照/) assert.match(bookingModule, /phase3Loading[\s\S]*phase3ContainerLoading/) }) test('test-environment loading chains bind the latest container version before opening PDA', () => { const containerLoading = readFileSync( resolve(scriptsDir, 'admin-test-env-modules', 'phase3-container-loading.mjs'), 'utf8') const bridgeLoading = readFileSync( resolve(scriptsDir, 'admin-test-env-modules', 'phase3-loading.mjs'), 'utf8') assert.match(containerLoading, /version: Number\(linkedContainer\.version\), reason: context\.marker/) const bridgeIndex = bridgeLoading.indexOf('原子关联入库预装与柜次装柜计划') const rejectedPushIndex = bridgeLoading.indexOf('无真实柜号拒绝推送柜次计划') const transportIndex = bridgeLoading.indexOf('绑定真实柜号后开放三期 PDA 推送门禁') const releaseIndex = bridgeLoading.indexOf('三期订舱补齐五项运输字段并放舱') const successfulPushIndex = bridgeLoading.indexOf('真实柜号与 RELEASED 订舱就绪后推送并生成 PDA 任务') const pdaIndex = bridgeLoading.indexOf('读取柜次级 PDA 唯一事实任务') assert.ok(bridgeIndex >= 0 && rejectedPushIndex > bridgeIndex && transportIndex > rejectedPushIndex && releaseIndex > transportIndex && successfulPushIndex > releaseIndex && pdaIndex > successfulPushIndex) assert.match(bridgeLoading, /const missingContainerPushRejected = failure\(missingContainerPushResponse\)[\s\S]*if \(!missingContainerPushRejected\) return/) assert.match(bridgeLoading, /const missingContainerTaskAbsent =[\s\S]*if \(!missingContainerTaskAbsent\) return/) assert.match(bridgeLoading, /version: transportVersion/) assert.match(bridgeLoading, /bookingReleased\?\.oceanBooking\?\.status === 'RELEASED'/) const containerRejectedPushIndex = containerLoading.indexOf('无真实柜号拒绝推送预装计划') const containerTransportIndex = containerLoading.indexOf('在放舱前绑定本轮真实箱号') const containerReleaseIndex = containerLoading.indexOf('订舱五项运输字段放舱并满足 PDA 订舱门禁') const containerSuccessfulPushIndex = containerLoading.indexOf('柜号与 RELEASED 订舱就绪后推送预装计划') const containerPdaIndex = containerLoading.indexOf('查询本轮柜次 PDA 拣货任务') assert.ok(containerRejectedPushIndex >= 0 && containerTransportIndex > containerRejectedPushIndex && containerReleaseIndex > containerTransportIndex && containerSuccessfulPushIndex > containerReleaseIndex && containerPdaIndex > containerSuccessfulPushIndex) })