fix: some
All checks were successful
构建并部署前端到测试环境 / deploy (push) Successful in 55s

This commit is contained in:
luo
2026-10-13 17:43:38 +08:00
parent c31183205d
commit 16effb69f3
8 changed files with 94 additions and 43 deletions

View File

@@ -202,13 +202,17 @@ test('order payment record status is independent from order status and channels
test('exchange phone conflicts support HTTP error and business response without inventing a missing number', async () => {
const module = await loadModule('src/utils/business/exchangeError.ts')
const failure = { code: 1202, data: { phone: '13800000000' } }
assert.match(module.getExchangePhoneConflictMessage(failure), /13800000000/)
const failure = {
code: 1202,
data: { phone: '13800000000' },
msg: '新资产已绑定手机号,请先在后台解除该资产的手机号绑定,再重新提交换货申请'
}
assert.equal(module.getExchangePhoneConflictMessage(failure), failure.msg)
assert.equal(
module.getExchangePhoneConflictMessage({ response: { data: failure } }),
module.getExchangePhoneConflictMessage(failure)
)
assert.match(module.getExchangePhoneConflictMessage({ code: 1202 }), /请先到/)
assert.match(module.getExchangePhoneConflictMessage({ code: 1202 }), /换货申请未完成/)
assert.doesNotMatch(module.getExchangePhoneConflictMessage({ code: 1202 }), /undefined|null/)
assert.equal(module.getExchangePhoneConflictMessage({ code: 1206 }), undefined)
assert.equal(
@@ -238,12 +242,9 @@ test('exchange association handoff carries only the new asset and its bound phon
phone: '19232713115'
}
)
assert.deepEqual(
assert.equal(
getExchangePhoneAssociationQuery({ response: { data: { code: 1202 } } }, newAsset),
{
asset_identifier: '89860624590014594318',
phone: '19232713115'
}
undefined
)
assert.equal(getExchangePhoneAssociationQuery({ code: 1206 }, newAsset), undefined)
assert.equal(
@@ -266,6 +267,31 @@ test('exchange association handoff carries only the new asset and its bound phon
)
})
test('1202 with data null keeps the original msg and cannot navigate to unbind despite asset phone history', async () => {
const { getExchangePhoneConflictMessage, getExchangePhoneAssociationQuery } = await loadModule(
'src/utils/business/exchangeError.ts'
)
const failure = {
code: 1202,
data: null,
msg: '该资产已完成过换货,如需再次换货请使用换货后的新资产'
}
const newAsset = { asset_identifier: '89860624590014594318', associated_phones: ['19232713115'] }
for (const value of [failure, { response: { data: failure } }]) {
assert.equal(getExchangePhoneConflictMessage(value), failure.msg)
assert.equal(getExchangePhoneAssociationQuery(value, newAsset), undefined)
}
for (const phone of ['', ' ', null, 19232713115]) {
assert.equal(
getExchangePhoneAssociationQuery({ ...failure, data: { phone } }, newAsset),
undefined
)
}
const page = await readFile('src/views/asset-management/exchange-management/index.vue', 'utf8')
assert.match(page, /if \(!canManageAssociations\)/)
assert.match(page, /ElMessageBox.alert\(conflictMessage, '换货提示'/)
})
test('association preselection excludes old assets, different phones and invalid historical rows', async () => {
const {
getPhoneAssetAssociationTarget,