feat(semi-auto): 虎牙客户页登录→资料→绑定流程与返回上一步重置

This commit is contained in:
2026-11-17 20:40:12 +08:00
parent 5d0be12476
commit 23b8e4fdd3
21 changed files with 1455 additions and 558 deletions
@@ -11,48 +11,42 @@ const source = readFileSync(
)
const styles = readFileSync(join(root, '../src/styles/client.css'), 'utf8')
test('扫码识别角色后,资料不一致也打开对比弹窗', () => {
// 自动弹窗 effect 不再因 mismatch 提前 return。
assert.ok(source.includes('识别到角色(含与资料不一致)都要弹出对比框'))
assert.ok(!source.includes("if (bindingInfo.comparison.verdict === 'mismatch') return"))
// 手动刷新时 mismatch 同样打开弹窗,不再关闭并只弹提示。
assert.ok(source.includes('资料不一致同样打开对比框'))
assert.ok(!source.includes('平台角色与已填资料不一致,请先同步资料'))
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('修改资料'))
assert.ok(source.includes('同步平台角色'))
assert.ok(source.includes('canSyncBindingProfile'))
assert.ok(source.includes('onClick={openProfileEditor}'))
assert.ok(
source.includes(
"disabled={!bindingCustomerReady || bindingComparison?.verdict === 'mismatch'}",
),
)
assert.ok(styles.includes('.customer-binding-modal-actions.is-mismatch'))
assert.ok(styles.includes('repeat(auto-fit, minmax(140px, 1fr))'))
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('保存资料或同步平台角色后会重新打开对比弹窗', () => {
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(
'reopenBindingConfirm(bindingResponse.data.task, bindingResponse.data.binding)',
),
)
assert.ok(source.includes('角色资料已保存,请重新核对绑定角色'))
assert.ok(source.includes('资料已保存且与平台角色一致,请提交平台绑定'))
})
test('资料不一致时仍保持后端严格比对:确认按钮禁用并显示原因', () => {
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,避免直接返回已有角色', () => {
@@ -0,0 +1,50 @@
import assert from 'node:assert/strict'
import { readFile } from 'node:fs/promises'
import test from 'node:test'
function source(relativePath: string) {
return new URL(`../src/${relativePath}`, import.meta.url)
}
/**
* 半自动履约客户页是公开 H5 页面,可能被应用内浏览器、分屏或系统显示放大打开。
* 全局 base.css 的 body { min-width:320px } + worker.css 的 overflow-x:hidden
* 会在实际视口小于 320px 时把页面右侧直接裁掉(输入框/商品值/提示文案)。
* 这里锁住客户页专属移动端根类和 480px 移动壳,防止以后被全局样式改回去。
*/
test('客户履约页必须覆盖 body 320px 最小宽度并使用 480px 移动端壳', async () => {
const [app, css] = await Promise.all([
readFile(source('App.tsx'), 'utf8'),
readFile(source('styles/client.css'), 'utf8'),
])
assert.match(app, /customer-mobile-html/)
assert.match(app, /customer-mobile-body/)
assert.match(
css,
/html\.customer-mobile-html,\s*body\.customer-mobile-body\s*\{[^}]*min-width:\s*0/s,
)
assert.match(
css,
/body\.customer-mobile-body \.customer-collect-body\s*\{[^}]*max-width:\s*480px/s,
)
assert.match(
css,
/body\.customer-mobile-body \.customer-auth-shell\s*\{[^}]*width:\s*min\(480px,\s*100%\)/s,
)
})
test('客户履约页固定宽度弹窗必须收进手机视口', async () => {
const [page, huya, css] = await Promise.all([
readFile(source('pages/customer-fulfillment/CustomerFulfillmentPage.tsx'), 'utf8'),
readFile(source('pages/customer-fulfillment/HuyaChallengeModal.tsx'), 'utf8'),
readFile(source('styles/client.css'), 'utf8'),
])
assert.match(page, /className="customer-binding-modal"/)
assert.match(huya, /className="customer-huya-challenge-modal"/)
assert.match(
css,
/\.customer-binding-modal,\s*\.customer-huya-challenge-modal\s*\{[^}]*width:\s*calc\(100vw - 24px\)\s*!important/s,
)
})
@@ -12,20 +12,47 @@ const source = readFileSync(
'utf8',
)
test('换绑失败页用「返回上一步」替换「仍使用原角色」', () => {
assert.ok(source.includes('rebindFailureDismissed'))
assert.ok(source.includes('返回上一步'))
assert.ok(!source.includes('仍使用原角色'))
test('换绑失败页提供重新扫码换绑与上一步修改资料,不再直接使用原角色', () => {
assert.ok(source.includes('showRebindFailure || comparisonMismatch'))
assert.ok(source.includes('重新扫码换绑'))
assert.ok(source.includes('上一步修改资料'))
assert.ok(!source.includes('确认使用原角色'))
assert.ok(!source.includes('handleAcceptExistingRole'))
assert.ok(!source.includes('rebindFailureDismissed'))
})
test('返回后展示资料不一致核对界面', () => {
assert.ok(source.includes('showRebindFailure'))
assert.ok(source.includes('!showRebindFailure &&'))
assert.ok(source.includes('同步平台角色并继续'))
test('换绑后仍不一致时以修改资料为主,同时保留重新扫码入口', () => {
const panelStart = source.indexOf('showRebindFailure || comparisonMismatch')
assert.ok(panelStart > 0)
const panel = source.slice(panelStart, panelStart + 1600)
assert.ok(panel.includes('重新扫码换绑'))
assert.ok(panel.includes('上一步修改资料'))
assert.ok(source.includes('id="customer-binding-stage"'))
})
test('资料同步后提供确认使用原角色', () => {
assert.ok(source.includes('确认使用原角色'))
assert.ok(source.includes('handleAcceptExistingRole'))
test('取消直接使用原角色的快捷确认路径', () => {
assert.ok(!source.includes('acceptExistingRole'))
assert.ok(!source.includes('modal.confirm'))
})
test('点击上一步修改资料会回到第二步并隐藏绑定区', () => {
// 步骤条把编辑资料视为第二步,即使资料原本已完整。
assert.ok(source.includes(': profileEditing || !profileComplete'))
assert.ok(source.includes("'第二步:请填写游戏角色资料"))
assert.ok(source.includes('返回绑定角色'))
// 资料步骤隐藏二维码、失败提示和比对操作,避免与第二步混在一起。
assert.ok(source.includes('!profileEditing'))
assert.ok(source.includes("getElementById('customer-binding-stage')"))
})
test('上一步修改资料会清空换绑状态并保留已填资料', () => {
// 进入资料编辑时同步调用重置接口,清掉虎牙未接受换绑等失败痕迹。
assert.ok(source.includes('async function openProfileEditor()'))
assert.ok(source.includes('await resetCustomerBinding(orderNo, selectedTask.id)'))
assert.ok(source.includes('setBindingInfo(response.data.binding)'))
assert.ok(source.includes("message.success('已返回上一步,请修改资料后重新提交')"))
// 已登录且有绑定结果时才重置,资料表单本身不受影响。
assert.ok(source.includes("selectedTask.bindingStatus === 'not_started'"))
// 重置失败不阻断客户修改资料。
assert.ok(source.includes('重置绑定状态失败,请稍后重试'))
})
@@ -51,8 +51,12 @@ test('微博订单卡只展示订单号/商品/平台/状态,不含游戏和
assert.ok(!weiboBranch.includes('游戏名称'))
})
test('微博顶部使用 inside-kv 背景,虎牙保持纯色', () => {
assert.ok(styles.includes('.customer-auth-page.is-weibo .customer-auth-hero'))
assert.ok(styles.includes("url('/images/customer/inside-kv.jpg')"))
test('客户登录/绑定页顶部统一显示 inside-kv 背景,不再按平台区分', () => {
assert.match(
styles,
/\.customer-auth-hero \{[^}]*url\('\/images\/customer\/inside-kv\.jpg'\)[^}]*\}/s,
)
assert.ok(!styles.includes('.customer-auth-page.is-weibo .customer-auth-hero'))
assert.ok(!styles.includes('.customer-auth-page.is-huya .customer-auth-hero'))
assert.ok(styles.includes('.customer-auth-page.is-weibo .customer-auth-brand'))
})