test(phase4): provision overseas lifecycle fixtures
This commit is contained in:
@@ -141,7 +141,12 @@ export async function run(context) {
|
||||
coverageGap(context, '换标创建与状态生命周期',
|
||||
'当前 Admin 换标新增/审核仍使用不可提交的契约提示弹框,前端未真实接入写 API;验收模块不越过页面范围直接创建换标单', 'frontend-scope')
|
||||
|
||||
const warehouse = await findWarehouse(context, records(tenantsResult.data), customerId)
|
||||
let warehouse = await findWarehouse(context, records(tenantsResult.data), customerId)
|
||||
let ownedWarehouse = false
|
||||
if (!warehouse) {
|
||||
warehouse = await createWarehouseFixture(context, customerId)
|
||||
ownedWarehouse = Boolean(warehouse)
|
||||
}
|
||||
if (!warehouse) return
|
||||
const warehouseId = id(warehouse.id)
|
||||
context.createdResources.phase4OverseasWarehouse.customerId = customerId
|
||||
@@ -160,8 +165,45 @@ export async function run(context) {
|
||||
`listId=${id(pallet.id)}, detailId=${id(detail.data?.id) || 'missing'}; ${trace(detail.response)}`, OPTIONS)
|
||||
}
|
||||
|
||||
await verifyPalletLifecycle(context, warehouseId)
|
||||
context.context.phase4OverseasWarehouse = { customerId, warehouseId, palletId: context.createdResources.phase4OverseasWarehouse.palletId }
|
||||
try {
|
||||
await verifyPalletLifecycle(context, warehouseId)
|
||||
context.context.phase4OverseasWarehouse = { customerId, warehouseId, palletId: context.createdResources.phase4OverseasWarehouse.palletId }
|
||||
} finally {
|
||||
if (ownedWarehouse) await retireWarehouseFixture(context, customerId, warehouseId)
|
||||
}
|
||||
}
|
||||
|
||||
async function createWarehouseFixture(context, customerId) {
|
||||
const suffix = String(context.marker || '').replace(/[^A-Za-z0-9]/g, '').slice(-20).toUpperCase()
|
||||
const payload = {
|
||||
customerId, warehouseCode: `P4W-${suffix}`.slice(0, 50), warehouseName: `${context.marker} 海外仓`,
|
||||
warehouseType: 'OVERSEAS', countryCode: 'US', timezone: 'America/Los_Angeles',
|
||||
contactName: 'Phase4 QA', contactPhone: '+1-213-555-0188', contactEmail: null,
|
||||
status: 'ACTIVE', remark: `${context.marker}-warehouse-fixture`,
|
||||
address: { addressType: 'WAREHOUSE', countryCode: 'US', stateProvince: 'California', city: 'Los Angeles',
|
||||
district: 'Commerce', postalCode: '90040', addressLine1: '501 Phase Four Warehouse Avenue',
|
||||
addressLine2: null, latitude: null, longitude: null },
|
||||
capabilities: [{ capabilityCode: 'STORAGE', capabilityName: 'Storage', enabled: true,
|
||||
cutoffTime: null, description: `${context.marker} acceptance` }],
|
||||
}
|
||||
const created = await overseasMutation(context, 'POST', '创建本轮客户海外仓', '/api/platform/v1/warehouse-admin', payload)
|
||||
const warehouseId = id(created.data)
|
||||
context.assert(MODULE, '客户海外仓创建返回长ID', created.response, longId(warehouseId),
|
||||
`warehouseId=${warehouseId || 'missing'}, customerId=${customerId}; ${trace(created.response)}`, OPTIONS)
|
||||
if (!warehouseId) return null
|
||||
const detail = await overseasGet(context, '查询本轮客户海外仓详情', query(`/api/platform/v1/warehouse-admin/${encodeURIComponent(warehouseId)}`, { customerId }))
|
||||
context.assert(MODULE, '本轮客户海外仓归属和状态正确', detail.response,
|
||||
id(detail.data?.warehouse?.id || detail.data?.id) === warehouseId
|
||||
&& id(detail.data?.warehouse?.customerId || detail.data?.customerId) === customerId
|
||||
&& (detail.data?.warehouse?.status || detail.data?.status) === 'ACTIVE',
|
||||
`warehouseId=${warehouseId}, customerId=${id(detail.data?.warehouse?.customerId || detail.data?.customerId) || 'missing'}; ${trace(detail.response)}`, OPTIONS)
|
||||
return { id: warehouseId, customerId, warehouseCode: payload.warehouseCode, warehouseName: payload.warehouseName, status: 'ACTIVE' }
|
||||
}
|
||||
|
||||
async function retireWarehouseFixture(context, customerId, warehouseId) {
|
||||
const retired = await context.requestOverseas('PATCH', query(`/api/platform/v1/warehouse-admin/${encodeURIComponent(warehouseId)}/status`, { customerId, status: 'INACTIVE' }))
|
||||
context.addStep(MODULE, '本轮客户海外仓已停用收口', retired,
|
||||
retired?.http === 200 && String(retired?.body?.code) === '200', trace(retired), OPTIONS)
|
||||
}
|
||||
|
||||
async function verifyPalletLifecycle(context, warehouseId) {
|
||||
@@ -237,6 +279,5 @@ async function findWarehouse(context, tenants, preferredCustomerId) {
|
||||
return warehouse
|
||||
}
|
||||
}
|
||||
coverageGap(context, '公共托盘真实仓库前置', `ACTIVE 客户列表未找到可用海外仓;${trace(lastResponse)}`, 'missing-readonly-warehouse')
|
||||
return null
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user