68 lines
3.3 KiB
TypeScript
68 lines
3.3 KiB
TypeScript
import assert from 'node:assert/strict'
|
|
import { readFileSync } from 'node:fs'
|
|
import { dirname, join } from 'node:path'
|
|
import { fileURLToPath } from 'node:url'
|
|
import test from 'node:test'
|
|
|
|
const root = dirname(fileURLToPath(import.meta.url))
|
|
const source = readFileSync(
|
|
join(root, '../src/pages/customer-fulfillment/CustomerFulfillmentPage.tsx'),
|
|
'utf8',
|
|
)
|
|
const styles = readFileSync(join(root, '../src/styles/customer/binding.css'), 'utf8')
|
|
|
|
test('资料不一致时不自动弹核对框,由页面两个按钮处理', () => {
|
|
assert.ok(source.includes("if (bindingInfo.comparison.verdict !== 'match') return"))
|
|
assert.ok(source.includes('不一致时不弹框'))
|
|
// 手动刷新时也只有三项一致才打开核对框。
|
|
assert.ok(source.includes("if (nextBinding?.comparison?.verdict === 'match') {"))
|
|
})
|
|
|
|
test('资料不一致时固定提供重新扫码换绑与上一步修改资料', () => {
|
|
assert.ok(source.includes('showRebindFailure || comparisonMismatch'))
|
|
assert.ok(source.includes('重新扫码换绑'))
|
|
assert.ok(source.includes('上一步修改资料'))
|
|
assert.ok(source.includes('onClick={() => void openProfileEditor()}'))
|
|
// 取消同步平台角色与直接使用原角色的快捷路径。
|
|
assert.ok(!source.includes('同步平台角色'))
|
|
assert.ok(!source.includes('确认使用原角色'))
|
|
assert.ok(styles.includes('.customer-binding-role-actions'))
|
|
})
|
|
|
|
test('保存资料后只由单一自动绑定流程推进,不再并发轮询', () => {
|
|
assert.ok(!source.includes('function reopenBindingConfirm('))
|
|
const saveStart = source.indexOf('async function handleSaveProfile()')
|
|
assert.ok(saveStart > 0)
|
|
const saveBody = source.slice(saveStart, saveStart + 1800)
|
|
assert.ok(!saveBody.includes('pollCustomerBinding('))
|
|
assert.ok(source.includes("message.success('资料已保存,正在重新核对平台角色')"))
|
|
assert.ok(source.includes("if (selectedTask.bindingStatus !== 'not_started'"))
|
|
})
|
|
|
|
test('登录和绑定专用同步阶段暂停整单轮询', () => {
|
|
assert.ok(source.includes('const dedicatedLoginPoll ='))
|
|
assert.ok(source.includes('const dedicatedBindingPoll ='))
|
|
assert.ok(source.includes('if (dedicatedLoginPoll || dedicatedBindingPoll) return'))
|
|
assert.ok(source.includes('}, 10_000)'))
|
|
})
|
|
|
|
test('三项一致才出现提交平台绑定,不一致时展示原因', () => {
|
|
assert.ok(source.includes('提交平台绑定'))
|
|
assert.ok(source.includes("bindingComparison?.verdict === 'match'"))
|
|
assert.ok(source.includes('两侧角色信息不一致,无法提交平台绑定'))
|
|
assert.ok(source.includes('customer-binding-modal-error'))
|
|
})
|
|
|
|
test('二维码区提示扫码后会核对平台角色与已填资料', () => {
|
|
assert.ok(source.includes('扫码后系统会核对平台角色与已填资料'))
|
|
assert.ok(source.includes('三项完全一致才能提交平台绑定'))
|
|
})
|
|
|
|
test('换绑流程刷新二维码必须带 forceRebind,避免直接返回已有角色', () => {
|
|
assert.ok(source.includes('function handleRefreshBindingQr()'))
|
|
assert.ok(source.includes('handleRefreshBinding(bindingInfo?.rebindRequested === true)'))
|
|
// 三处刷新/重新获取入口都不能再固定传 false。
|
|
assert.ok(!source.includes('handleRefreshBinding(false)'))
|
|
assert.ok(source.includes('onClick={handleRefreshBindingQr}'))
|
|
})
|