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/client.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(')) assert.ok(source.includes("if (nextTask.bindingStatus !== 'role_ready') return false")) assert.ok(source.includes("if (nextBinding.comparison.verdict !== 'match') return false")) assert.ok(source.includes('reopened = reopenBindingConfirm(')) assert.ok(source.includes('资料已保存且与平台角色一致,请提交平台绑定')) }) 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}')) })