test(acceptance): reuse fixed customers and align native fulfillment flows

This commit is contained in:
2026-10-23 04:48:02 +08:00
parent b92f7fe991
commit 139f6b1932
51 changed files with 1076 additions and 228 deletions
@@ -44,11 +44,20 @@ export function normalizeFixedCustomerId(value) {
return text
}
export function requireFixedSecondaryCustomer(options) {
const secondary = options.fixedSecondaryCustomer
if (!secondary?.customerId || !secondary.username || !secondary.password)
throw new Error('固定客户模式未配置第二个客户,跨客户场景阻断;禁止自动建客或用同一客户替代隔离验证')
if (normalizeFixedCustomerId(secondary.customerId) === normalizeFixedCustomerId(options.fixedCustomerId))
throw new Error('第二个固定客户必须不同于主客户,禁止替代隔离验证')
return secondary
}
async function reuseFixedCustomer(context, publishEnvironment, requireDistinctCustomer) {
if (requireDistinctCustomer) throw new Error('固定客户模式未配置第二个客户,跨客户场景阻断;禁止自动建客或用同一客户替代隔离验证')
const tenantId = normalizeFixedCustomerId(context.options.fixedCustomerId)
const username = context.options.merchantUsername || process.env.MERCHANT_TEST_USERNAME
const password = context.options.merchantPassword || process.env.MERCHANT_TEST_PASSWORD
const secondary = requireDistinctCustomer ? requireFixedSecondaryCustomer(context.options) : null
const tenantId = normalizeFixedCustomerId(secondary?.customerId || context.options.fixedCustomerId)
const username = secondary ? secondary.username : context.options.merchantUsername || process.env.MERCHANT_TEST_USERNAME
const password = secondary ? secondary.password : context.options.merchantPassword || process.env.MERCHANT_TEST_PASSWORD
if (!username || !password) throw new Error('请配置固定客户的 MERCHANT_TEST_USERNAME / MERCHANT_TEST_PASSWORD;不会新建客户或重置密码')
const loginResponse = await context.request('POST', '/api/auth/login', {loginId:username,password}, '')
const login = context.apiSuccess(MODULE, '登录已配置的固定客户账号', loginResponse)