This commit is contained in:
@@ -226,6 +226,91 @@ test('exchange phone conflicts support HTTP error and business response without
|
||||
})
|
||||
})
|
||||
|
||||
test('exchange association handoff carries only the new asset and its bound phone as strings', async () => {
|
||||
const { getExchangePhoneAssociationQuery } = await loadModule(
|
||||
'src/utils/business/exchangeError.ts'
|
||||
)
|
||||
const newAsset = { asset_identifier: '89860624590014594318', associated_phones: ['19232713115'] }
|
||||
assert.deepEqual(
|
||||
getExchangePhoneAssociationQuery({ code: 1202, data: { phone: '19232713115' } }, newAsset),
|
||||
{
|
||||
asset_identifier: '89860624590014594318',
|
||||
phone: '19232713115'
|
||||
}
|
||||
)
|
||||
assert.deepEqual(
|
||||
getExchangePhoneAssociationQuery({ response: { data: { code: 1202 } } }, newAsset),
|
||||
{
|
||||
asset_identifier: '89860624590014594318',
|
||||
phone: '19232713115'
|
||||
}
|
||||
)
|
||||
assert.equal(getExchangePhoneAssociationQuery({ code: 1206 }, newAsset), undefined)
|
||||
assert.equal(
|
||||
getExchangePhoneAssociationQuery({ code: 1202, data: { phone: '19232713115' } }, {}),
|
||||
undefined
|
||||
)
|
||||
assert.equal(
|
||||
getExchangePhoneAssociationQuery(
|
||||
{ code: 1202 },
|
||||
{ asset_identifier: '89860624590014594318', associated_phones: [] }
|
||||
),
|
||||
undefined
|
||||
)
|
||||
assert.deepEqual(
|
||||
getExchangePhoneAssociationQuery({ code: 1202, data: { phone: '13900000000' } }, newAsset),
|
||||
{
|
||||
asset_identifier: '89860624590014594318',
|
||||
phone: '13900000000'
|
||||
}
|
||||
)
|
||||
})
|
||||
|
||||
test('association preselection excludes old assets, different phones and invalid historical rows', async () => {
|
||||
const {
|
||||
getPhoneAssetAssociationTarget,
|
||||
getMatchingPhoneAssetAssociations,
|
||||
getPhoneAssetUnbindResultName
|
||||
} = await loadModule('src/utils/business/phoneAssetAssociation.ts')
|
||||
const target = getPhoneAssetAssociationTarget({
|
||||
asset_identifier: ' 89860624590014594318 ',
|
||||
phone: '19232713115'
|
||||
})
|
||||
const rows = [
|
||||
{ id: 1, asset_identifier: target.asset_identifier, phone: target.phone, status: 1 },
|
||||
{ id: 2, asset_identifier: '89860625770070732445', phone: target.phone, status: 1 },
|
||||
{ id: 3, asset_identifier: target.asset_identifier, phone: '13900000000', status: 1 },
|
||||
{ id: 4, asset_identifier: target.asset_identifier, phone: target.phone, status: 0 }
|
||||
]
|
||||
assert.deepEqual(
|
||||
getMatchingPhoneAssetAssociations(rows, target).map((row) => row.id),
|
||||
[1]
|
||||
)
|
||||
assert.deepEqual(getMatchingPhoneAssetAssociations(rows, { ...target, phone: '' }), [])
|
||||
assert.deepEqual(
|
||||
getPhoneAssetAssociationTarget({ asset_identifier: ['a', 'b'], phone: ['19232713115'] }),
|
||||
{ asset_identifier: '', phone: '' }
|
||||
)
|
||||
assert.equal(getPhoneAssetUnbindResultName(true), '解绑成功')
|
||||
assert.equal(getPhoneAssetUnbindResultName(false), '解绑失败')
|
||||
})
|
||||
|
||||
test('association page watches handoff changes, clears stale selections and retains manual unbind confirmation', async () => {
|
||||
const page = await readFile(
|
||||
'src/views/asset-management/phone-asset-association/index.vue',
|
||||
'utf8'
|
||||
)
|
||||
assert.match(page, /getPhoneAssetAssociationTarget\(route.query\)/)
|
||||
assert.match(page, /toggleRowSelection\(row, true\)/)
|
||||
assert.match(page, /requestId !== listRequestId/)
|
||||
assert.match(page, /getPhoneAssetUnbindResultName\(row.success\)/)
|
||||
assert.doesNotMatch(page, /prop="success"/)
|
||||
assert.match(page, /batchForm.confirmed = false/)
|
||||
assert.match(page, /batchFormRef.value\?\.validate/)
|
||||
const table = await readFile('src/components/core/tables/ArtTable.vue', 'utf8')
|
||||
assert.match(table, /clearSelection:.*clearSelection\(\)/)
|
||||
})
|
||||
|
||||
test('password validation errors accept backend message as well as msg', async () => {
|
||||
const { normalizeApiError } = await loadModule('src/utils/business/apiError.ts')
|
||||
for (const field of ['msg', 'message']) {
|
||||
|
||||
Reference in New Issue
Block a user