From cdcf3e0f4ff61dad10e7835605929cdeb9318892 Mon Sep 17 00:00:00 2001 From: ouyangxq <775153912@qq.com> Date: Tue, 1 Sep 2026 10:17:41 +0800 Subject: [PATCH] test(firstleg): parse platform warehouse scope explicitly --- .../truck-appointments-contract.test.mjs | 11 ++++++++++- scripts/admin-test-env-modules/truck-appointments.mjs | 8 ++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/scripts/admin-test-env-modules/truck-appointments-contract.test.mjs b/scripts/admin-test-env-modules/truck-appointments-contract.test.mjs index 7b5ef104d..718d26d41 100644 --- a/scripts/admin-test-env-modules/truck-appointments-contract.test.mjs +++ b/scripts/admin-test-env-modules/truck-appointments-contract.test.mjs @@ -2,7 +2,16 @@ import assert from 'node:assert/strict' import { readFileSync } from 'node:fs' import test from 'node:test' -import { inspectOceanBookingIdentity, truckAppointmentPayload } from './truck-appointments.mjs' +import { inspectOceanBookingIdentity, platformWarehouseIdentity, truckAppointmentPayload } from './truck-appointments.mjs' + +test('platform warehouse scope is fixed to zero without requiring response tenantId', () => { + assert.deepEqual(platformWarehouseIdentity({ warehouseId: '41', warehouseName: '宁波仓' }), + { warehouseId: '41', platformTenantId: '0' }) + assert.deepEqual(platformWarehouseIdentity({ id: 42, warehouseName: '义乌仓' }), + { warehouseId: '42', platformTenantId: '0' }) + const source = readFileSync(new URL('truck-appointments.mjs', import.meta.url), 'utf8') + assert.doesNotMatch(source, /item\?\.tenantId|item\.tenantId/) +}) test('booking identity is marker scoped and contains no customer snapshot', () => { const result = inspectOceanBookingIdentity('RUN-2', { id: '91', marker: 'RUN-2', warehouseId: '41' }) diff --git a/scripts/admin-test-env-modules/truck-appointments.mjs b/scripts/admin-test-env-modules/truck-appointments.mjs index 49d7d8368..900ac23a6 100644 --- a/scripts/admin-test-env-modules/truck-appointments.mjs +++ b/scripts/admin-test-env-modules/truck-appointments.mjs @@ -14,6 +14,10 @@ function data(response) { return codeOf(response) === '200' ? response.body.data function failure(response) { return response?.http === 0 || response?.http >= 400 || (response?.http === 200 && codeOf(response) !== '200') } function records(value) { return Array.isArray(value) ? value : value?.records || [] } +export function platformWarehouseIdentity(item) { + return { warehouseId: id(item?.warehouseId || item?.id || item?.warehouse?.id), platformTenantId: '0' } +} + async function request(context, method, path, body, headers = {}) { try { const response = await fetch(`${context.options.gateway}${path}`, { @@ -67,7 +71,7 @@ async function bookingMaster(context, suffix) { const customerName = String(context.options?.customerName || `全量验收下单客户-${suffix}`).trim() const warehousesResponse = await request(context, 'GET', '/api/platform/v1/warehouse-admin?tenantId=0&status=ACTIVE&page=1&size=100') for (const item of records(data(warehousesResponse))) { - const warehouseId = id(item?.id || item?.warehouse?.id) + const { warehouseId } = platformWarehouseIdentity(item) if (!warehouseId) continue const channelsResponse = await request(context, 'GET', `${BOOKINGS}/channels?originWarehouseId=${warehouseId}`) const channel = (data(channelsResponse) || [])[0] @@ -75,7 +79,7 @@ async function bookingMaster(context, suffix) { channelCode: channel.channelCode, channelName: channel.channelName } } context.addStep(MODULE, '解析具备有效海运渠道的平台仓库', warehousesResponse, false, - `tenantId=${tenantId || 'missing'}`, OPTIONS) + `platformTenantId=0, customerId=${tenantId || 'missing'}`, OPTIONS) return null }