修复(虎牙绑定): 扫错角色可重新扫码、绑定失败留证、确认后引导截图联系客服
按业务口径重审「资料 → 登录 → 读角色 → 绑定」全链路,修复 3 个 P0 与 4 处口径问题: P0 重新扫码空转 - startPublicBinding 改为按 allowedActions 判定能否重新出码,不再只看 primaryAction。 此前 first_bind_role_mismatch(primaryAction=contact_support)点「刷新绑定二维码」 后端直接早退:二维码不重生成、旧 pending 不清,客户扫错角色后卡死。 P0 扫错角色被判成人工核实 - 换绑 pending 与目标资料不一致时不再返回 manual_review,改为 rebind_required (start_rebind + edit_profile + contact_support),客户可自愈。 - first_bind_role_mismatch 保留(后端仍会产出),客户页重新渲染该状态, 确认按钮不再吞掉「重新扫码」「上一步修改资料」两个退回入口。 - requiresSupport 只在 manual_review 为真;canGenerateBindingQr 改为从 allowedActions 推导。 - 新增前端守卫测试:后端会产出的每个 flowState 在客户页都必须有可操作落点。 P0 确认后没有下一步引导 - confirmed 区块改为「绑定已确认」+「请截图本页,把订单号和这张截图发给客服」, 展示并可复制订单号,保留刷新按钮。 失败留证 - Connector 拒绝时 bind_confirm_message 带平台返回码;确认写接口抛异常也落 bind_confirm_message + last_error,不再只停在 submitting 等超时。 - rebind_platform_message 不再被「本次无消息」覆盖成空串;DTO 暴露 bindConfirmState / bindConfirmMessage,客户页按去重顺序展示真实失败原因。 - 加密 role token 不再写入任务事件(仅保留 hasRoleToken 布尔标记)。 换绑冷却 - 平台未返回 changeBindTime 时不再推算「从现在起 N 天」; 页面只在剩余天数 > 0 时展示「剩余约 N 天」,否则提示平台未返回。 - 冷却态补「刷新绑定状态」入口与「冷却结束后再回来点重新扫码换绑」指引。 文档同步虎牙绑定的可自愈动作、确认后截图引导、冷却与失败留证口径。
This commit is contained in:
@@ -982,7 +982,7 @@ export default function CustomerFulfillmentPage({
|
||||
}
|
||||
|
||||
/** 角色信息无法自动核对时引导客户把订单号发给客服。 */
|
||||
async function copyOrderNoForSupport() {
|
||||
async function copyOrderNoForSupport(successMessage = '订单号已复制,请联系客服核实角色信息') {
|
||||
const text = String(orderNo || selectedTask?.orderNo || '').trim()
|
||||
if (!text) {
|
||||
message.warning('订单号为空,请直接联系客服')
|
||||
@@ -990,7 +990,7 @@ export default function CustomerFulfillmentPage({
|
||||
}
|
||||
try {
|
||||
await navigator.clipboard.writeText(text)
|
||||
message.success('订单号已复制,请联系客服核实角色信息')
|
||||
message.success(successMessage)
|
||||
} catch {
|
||||
message.error('复制失败,请手动记录订单号后联系客服')
|
||||
}
|
||||
@@ -1038,6 +1038,8 @@ export default function CustomerFulfillmentPage({
|
||||
[
|
||||
'current_role_confirmable',
|
||||
'first_bind_role_ready',
|
||||
// 首次绑定扫错角色:后端仍会产出该状态(allowedActions 含重新出码 + 修改资料),
|
||||
// 页面必须渲染决策区,否则客户只剩一条提示、没有任何可点动作。
|
||||
'first_bind_role_mismatch',
|
||||
'first_bind_failed',
|
||||
'rebind_required',
|
||||
@@ -1070,6 +1072,36 @@ export default function CustomerFulfillmentPage({
|
||||
const bindConfirmState = bindingInfo?.bindConfirmState || 'idle'
|
||||
const bindConfirmRejected = bindConfirmState === 'rejected'
|
||||
const bindConfirmPending = bindConfirmState === 'submitting' || bindConfirmState === 'accepted'
|
||||
// 冷却天数只认后端返回值(账号/角色侧):平台没返回 changeBindTime 时后端给 0。
|
||||
// 不得用 platformChangeBindDay 推成「从现在起 N 天」,否则「没有冷却信息」会显示成「剩 N 天」。
|
||||
const rebindCooldownDays = Number(bindingInfo?.rebindCooldownDays || 0)
|
||||
const rebindCooldownText =
|
||||
rebindCooldownDays > 0 ? `当前仍处于虎牙换绑冷却期,剩余约 ${rebindCooldownDays} 天` : ''
|
||||
// 微博页不涉及虎牙,冷却口径相同但文案不写虎牙。
|
||||
const weiboRebindCooldownText =
|
||||
rebindCooldownDays > 0 ? `当前角色仍在换绑冷却期,剩余约 ${rebindCooldownDays} 天` : ''
|
||||
// 虎牙账号/目标角色仍在换绑冷却期:后端已不再给「重新扫码换绑」,页面只提供只读刷新。
|
||||
const isRebindBlocked =
|
||||
bindingDecision?.flowState === 'rebind_blocked_account' ||
|
||||
bindingDecision?.flowState === 'rebind_blocked_target_role'
|
||||
const canRefreshBindingState = decisionCanRefreshBinding || isRebindBlocked
|
||||
// 失败原因按「平台确认原因 → 任务原因 → 决策消息」去重,同一句只打印一次。
|
||||
const bindingFailureReasons = (() => {
|
||||
const seen = new Set<string>()
|
||||
const reasons: string[] = []
|
||||
const push = (value: string | null | undefined) => {
|
||||
const text = String(value || '').trim()
|
||||
if (!text || seen.has(text)) return
|
||||
seen.add(text)
|
||||
reasons.push(text)
|
||||
}
|
||||
push(bindingInfo?.bindConfirmMessage)
|
||||
push(selectedTask?.bindConfirmMessage)
|
||||
push(bindingInfo?.rebindConfirmMessage)
|
||||
push(bindingDecision?.message)
|
||||
push(selectedTask?.lastError)
|
||||
return reasons
|
||||
})()
|
||||
// 只有角色名缺失时才需要人工核实;加密 role token 不再冒充客户游戏角色 UID。
|
||||
const bindingRequiresSupport = Boolean(
|
||||
bindingDecision?.requiresSupport || bindingInfo?.requiresSupport,
|
||||
@@ -1084,12 +1116,8 @@ export default function CustomerFulfillmentPage({
|
||||
const bindingBanner = (() => {
|
||||
if (bindingSessionExpired) return null
|
||||
if (bindingDecision) {
|
||||
if (bindingDecision.flowState === 'rebind_blocked_account') {
|
||||
return { tone: 'is-warning', text: formatHuyaBindingDecisionMessage(bindingDecision) }
|
||||
}
|
||||
if (bindingDecision.flowState === 'rebind_blocked_target_role') {
|
||||
return { tone: 'is-warning', text: formatHuyaBindingDecisionMessage(bindingDecision) }
|
||||
}
|
||||
// 冷却态由下方绑定卡片的冷却提示条统一说明,这里不重复刷同一句话。
|
||||
if (isRebindBlocked) return null
|
||||
if (bindingDecision.flowState === 'rebind_effect_pending') {
|
||||
return { tone: 'is-info', text: bindingDecision.message }
|
||||
}
|
||||
@@ -1141,6 +1169,16 @@ export default function CustomerFulfillmentPage({
|
||||
const nextRebindText = bindingInfo?.nextRebindAt
|
||||
? formatAdminDateTime(bindingInfo.nextRebindAt)
|
||||
: ''
|
||||
// 冷却期文案只按后端返回的事实说话:既没有冷却天数也没有下次可换绑时间时,不猜时间。
|
||||
const rebindBlockedMessage = isRebindBlocked
|
||||
? formatHuyaBindingDecisionMessage(bindingDecision)
|
||||
: ''
|
||||
const rebindAvailableKnown = Boolean(
|
||||
rebindCooldownDays > 0 ||
|
||||
nextRebindText ||
|
||||
bindingDecision?.accountRebindAvailableAt ||
|
||||
bindingDecision?.targetRoleRebindAvailableAt,
|
||||
)
|
||||
const renderLoginForm = (options: {
|
||||
platformLabel: string
|
||||
mobilePlaceholder: string
|
||||
@@ -1607,12 +1645,8 @@ export default function CustomerFulfillmentPage({
|
||||
</Space>
|
||||
</div>
|
||||
)}
|
||||
{Number(bindingInfo?.rebindCooldownDays || 0) > 0 ? (
|
||||
<Alert
|
||||
type="info"
|
||||
showIcon
|
||||
message={`当前角色仍在换绑冷却期,剩余约 ${bindingInfo?.rebindCooldownDays || 0} 天`}
|
||||
/>
|
||||
{weiboRebindCooldownText ? (
|
||||
<Alert type="info" showIcon message={weiboRebindCooldownText} />
|
||||
) : null}
|
||||
</section>
|
||||
) : null}
|
||||
@@ -1669,6 +1703,35 @@ export default function CustomerFulfillmentPage({
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
{bindingDecision?.flowState === 'initial_bind_required' && !profileEditing ? (
|
||||
<div className="customer-binding-initial">
|
||||
<p className="customer-binding-initial-desc">
|
||||
{bindingDecision.message || '虎牙账号尚未绑定角色,请绑定目标角色'}
|
||||
</p>
|
||||
<Button
|
||||
block
|
||||
size="large"
|
||||
type="primary"
|
||||
className="customer-binding-next"
|
||||
icon={<QrcodeOutlined />}
|
||||
loading={bindingLoading}
|
||||
onClick={() => void handleRefreshBinding(true)}
|
||||
>
|
||||
生成绑定二维码
|
||||
</Button>
|
||||
{decisionCanEditProfile ? (
|
||||
<Button
|
||||
block
|
||||
size="large"
|
||||
icon={<ExclamationCircleOutlined />}
|
||||
onClick={() => void openProfileEditor()}
|
||||
>
|
||||
上一步修改资料
|
||||
</Button>
|
||||
) : null}
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
{bindingQrVisible && !bindingSessionExpired && !profileEditing ? (
|
||||
<div className="customer-binding-qr-card customer-huya-qr-card">
|
||||
<div className="customer-huya-qr-heading">
|
||||
@@ -1772,6 +1835,17 @@ export default function CustomerFulfillmentPage({
|
||||
返回登录
|
||||
</Button>
|
||||
)}
|
||||
{decisionCanEditProfile ? (
|
||||
<Button
|
||||
block
|
||||
size="large"
|
||||
className="customer-binding-rebind"
|
||||
icon={<ExclamationCircleOutlined />}
|
||||
onClick={() => void openProfileEditor()}
|
||||
>
|
||||
上一步修改资料
|
||||
</Button>
|
||||
) : null}
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
@@ -1799,12 +1873,19 @@ export default function CustomerFulfillmentPage({
|
||||
message={
|
||||
bindingDecision?.flowState === 'rebind_rejected'
|
||||
? '虎牙未接受本次换绑'
|
||||
: '绑定失败'
|
||||
: bindConfirmRejected
|
||||
? '虎牙未接受本次绑定'
|
||||
: '绑定失败'
|
||||
}
|
||||
description={
|
||||
bindingDecision?.message ||
|
||||
bindingInfo?.message ||
|
||||
'请刷新二维码后重新扫码,如持续失败请联系客服。'
|
||||
<Space direction="vertical" size={2}>
|
||||
{(bindingFailureReasons.length
|
||||
? bindingFailureReasons
|
||||
: ['请刷新二维码后重新扫码,如持续失败请联系客服。']
|
||||
).map((reason) => (
|
||||
<span key={reason}>{reason}</span>
|
||||
))}
|
||||
</Space>
|
||||
}
|
||||
action={
|
||||
<Button size="small" onClick={handleRefreshBindingQr}>
|
||||
@@ -1825,6 +1906,22 @@ export default function CustomerFulfillmentPage({
|
||||
orderNo || selectedTask?.orderNo || ''
|
||||
} 联系客服,核实完成前无法确认绑定。`}
|
||||
/>
|
||||
) : isRebindBlocked ? (
|
||||
<Alert
|
||||
type="warning"
|
||||
showIcon
|
||||
message="虎牙换绑冷却中,暂时无法换绑"
|
||||
description={
|
||||
<Space direction="vertical" size={2}>
|
||||
<span>{rebindBlockedMessage}</span>
|
||||
{rebindCooldownText ? <span>{rebindCooldownText}。</span> : null}
|
||||
{!rebindAvailableKnown ? (
|
||||
<span>平台未返回下次可换绑时间,请联系客服核实。</span>
|
||||
) : null}
|
||||
<span>冷却结束后再回来点「重新扫码换绑」。</span>
|
||||
</Space>
|
||||
}
|
||||
/>
|
||||
) : showRebindFailure ? (
|
||||
<Alert
|
||||
type={rebindRejected ? 'error' : 'warning'}
|
||||
@@ -1836,18 +1933,17 @@ export default function CustomerFulfillmentPage({
|
||||
平台仍返回原绑定角色:
|
||||
{bindingRoleName || '未识别到角色'}
|
||||
</span>
|
||||
{bindingInfo?.rebindConfirmMessage ? (
|
||||
<span>虎牙原因:{bindingInfo.rebindConfirmMessage}</span>
|
||||
) : null}
|
||||
{bindingFailureReasons.length ? (
|
||||
bindingFailureReasons.map((reason) => <span key={reason}>{reason}</span>)
|
||||
) : (
|
||||
<span>请核对虎牙弹窗中选中的目标角色后重新提交。</span>
|
||||
)}
|
||||
{nextRebindText ? <span>预计下次可换绑:{nextRebindText}</span> : null}
|
||||
{Number(bindingInfo?.platformChangeBindDay || 0) > 0 ? (
|
||||
<span>
|
||||
虎牙规则:每 {bindingInfo?.platformChangeBindDay} 个自然日可换绑 1 次
|
||||
</span>
|
||||
) : null}
|
||||
{!bindingInfo?.rebindConfirmMessage && !nextRebindText ? (
|
||||
<span>请核对虎牙弹窗中选中的目标角色后重新提交。</span>
|
||||
) : null}
|
||||
</Space>
|
||||
}
|
||||
/>
|
||||
@@ -1872,12 +1968,7 @@ export default function CustomerFulfillmentPage({
|
||||
{nextRebindText ? (
|
||||
<span>平台预计下次允许换绑:{nextRebindText}</span>
|
||||
) : null}
|
||||
{Number(bindingInfo?.rebindCooldownDays || 0) > 0 ? (
|
||||
<span>
|
||||
当前仍处于虎牙换绑冷却期,剩余约{' '}
|
||||
{Number(bindingInfo?.rebindCooldownDays || 0)} 天。
|
||||
</span>
|
||||
) : null}
|
||||
{rebindCooldownText ? <span>{rebindCooldownText}。</span> : null}
|
||||
</Space>
|
||||
}
|
||||
/>
|
||||
@@ -1902,64 +1993,78 @@ export default function CustomerFulfillmentPage({
|
||||
>
|
||||
确认绑定这个角色到虎牙
|
||||
</Button>
|
||||
) : (
|
||||
<>
|
||||
{decisionRequiresRebind || decisionCanRefreshQr ? (
|
||||
<Button
|
||||
block
|
||||
size="large"
|
||||
className="customer-binding-rebind"
|
||||
icon={<ReloadOutlined />}
|
||||
loading={bindingLoading}
|
||||
onClick={() => void handleRefreshBinding(true)}
|
||||
>
|
||||
{bindingDecision?.flowState === 'rebind_required'
|
||||
? '重新扫码换绑'
|
||||
: '刷新绑定二维码'}
|
||||
</Button>
|
||||
) : null}
|
||||
{decisionCanEditProfile ? (
|
||||
<Button
|
||||
block
|
||||
size="large"
|
||||
className="customer-binding-rebind"
|
||||
icon={<ExclamationCircleOutlined />}
|
||||
onClick={() => void openProfileEditor()}
|
||||
>
|
||||
上一步修改资料
|
||||
</Button>
|
||||
) : null}
|
||||
{bindingNeedsSupport ? (
|
||||
<Button
|
||||
block
|
||||
size="large"
|
||||
className="customer-binding-confirm"
|
||||
onClick={() => void copyOrderNoForSupport()}
|
||||
>
|
||||
复制订单号联系客服
|
||||
</Button>
|
||||
) : null}
|
||||
{decisionCanRefreshBinding ? (
|
||||
<Button
|
||||
block
|
||||
size="large"
|
||||
className="customer-binding-rebind"
|
||||
icon={<ReloadOutlined />}
|
||||
loading={bindingLoading}
|
||||
onClick={() => void handlePollBindingNow()}
|
||||
>
|
||||
刷新绑定状态
|
||||
</Button>
|
||||
) : null}
|
||||
</>
|
||||
)}
|
||||
) : null}
|
||||
{/* 选错角色必须能退回:确认按钮在上,重新扫码与修改资料始终保留。 */}
|
||||
{decisionRequiresRebind || decisionCanRefreshQr ? (
|
||||
<Button
|
||||
block
|
||||
size="large"
|
||||
className="customer-binding-rebind"
|
||||
icon={<ReloadOutlined />}
|
||||
loading={bindingLoading}
|
||||
onClick={() => void handleRefreshBinding(true)}
|
||||
>
|
||||
{bindingDecision?.flowState === 'rebind_required'
|
||||
? '重新扫码换绑'
|
||||
: '刷新绑定二维码'}
|
||||
</Button>
|
||||
) : null}
|
||||
{decisionCanEditProfile ? (
|
||||
<Button
|
||||
block
|
||||
size="large"
|
||||
className="customer-binding-rebind"
|
||||
icon={<ExclamationCircleOutlined />}
|
||||
onClick={() => void openProfileEditor()}
|
||||
>
|
||||
上一步修改资料
|
||||
</Button>
|
||||
) : null}
|
||||
{bindingNeedsSupport ? (
|
||||
<Button
|
||||
block
|
||||
size="large"
|
||||
className="customer-binding-confirm"
|
||||
onClick={() => void copyOrderNoForSupport()}
|
||||
>
|
||||
复制订单号联系客服
|
||||
</Button>
|
||||
) : null}
|
||||
{canRefreshBindingState ? (
|
||||
<Button
|
||||
block
|
||||
size="large"
|
||||
className="customer-binding-rebind"
|
||||
icon={<ReloadOutlined />}
|
||||
loading={bindingLoading}
|
||||
onClick={() => void handlePollBindingNow()}
|
||||
>
|
||||
刷新绑定状态
|
||||
</Button>
|
||||
) : null}
|
||||
</div>
|
||||
</Space>
|
||||
) : null}
|
||||
|
||||
{bindingDecision?.flowState === 'confirmed' && !profileEditing ? (
|
||||
<div className="customer-binding-verify">
|
||||
<p>平台角色绑定已确认,客服正在处理订单</p>
|
||||
<p className="customer-binding-verify-title">绑定已确认</p>
|
||||
<p className="customer-binding-verify-desc">
|
||||
请截图本页,把订单号和这张截图发给客服,客服会按截图核对并继续处理。
|
||||
</p>
|
||||
<div className="customer-binding-order-no">
|
||||
<span>订单号</span>
|
||||
<strong>{orderNo || selectedTask?.orderNo || ''}</strong>
|
||||
<Button
|
||||
size="small"
|
||||
icon={<CopyOutlined />}
|
||||
onClick={() =>
|
||||
void copyOrderNoForSupport('订单号已复制,请连同截图一起发给客服')
|
||||
}
|
||||
>
|
||||
复制订单号
|
||||
</Button>
|
||||
</div>
|
||||
<Button
|
||||
block
|
||||
size="large"
|
||||
|
||||
@@ -270,6 +270,52 @@
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
.customer-binding-verify .customer-binding-verify-title {
|
||||
color: #fff;
|
||||
font-size: 18px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.customer-binding-verify .customer-binding-verify-desc {
|
||||
color: #cbd5e1;
|
||||
font-size: 14px;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.customer-binding-order-no {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
padding: 10px 12px;
|
||||
border: 1px dashed #3a4150;
|
||||
border-radius: 10px;
|
||||
color: #9aa3b2;
|
||||
font-size: 14px;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.customer-binding-order-no strong {
|
||||
flex: 1 1 auto;
|
||||
min-width: 0;
|
||||
color: #fff;
|
||||
font-weight: 600;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.customer-binding-initial {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.customer-binding-initial-desc {
|
||||
margin: 0;
|
||||
color: #e5e7eb;
|
||||
font-size: 15px;
|
||||
line-height: 1.6;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.customer-binding-qr-card {
|
||||
padding: 18px;
|
||||
border-radius: 12px;
|
||||
|
||||
@@ -97,6 +97,9 @@ export type SemiAutoTask = {
|
||||
targetRoleMatch: HuyaTargetRoleMatch
|
||||
rebindBlockScope: HuyaRebindBlockScope
|
||||
rebindPlatformMessage: string
|
||||
/** 平台确认结果与原因(含「返回码 N」),与客户页同一口径。 */
|
||||
bindConfirmState: 'idle' | 'submitting' | 'accepted' | 'rejected'
|
||||
bindConfirmMessage: string
|
||||
customerGameRoleId: string
|
||||
customerGameRoleName: string
|
||||
customerServerZone: string
|
||||
|
||||
@@ -55,6 +55,12 @@ export type CustomerSemiAutoTask = {
|
||||
verificationBasis: string
|
||||
bindingDecision: HuyaBindingDecision | null
|
||||
bindingFlowState: HuyaBindingFlowState
|
||||
/** 平台确认(首次绑定/换绑)提交状态,由平台确认写接口回写。 */
|
||||
bindConfirmState: 'idle' | 'submitting' | 'accepted' | 'rejected'
|
||||
/** 平台返回的拒绝原因,已含「返回码 N」,客户页直接展示。 */
|
||||
bindConfirmMessage: string
|
||||
/** 任务执行异常(确认写接口抛错等),与平台原因分开保留。 */
|
||||
lastError: string
|
||||
customerGameRoleId: string
|
||||
customerGameRoleName: string
|
||||
customerServerZone: string
|
||||
@@ -111,8 +117,8 @@ export type CustomerBindingInfo = {
|
||||
rebindUnchanged: boolean
|
||||
rebindConfirmState: 'idle' | 'submitting' | 'accepted' | 'rejected'
|
||||
rebindConfirmMessage: string
|
||||
bindConfirmState?: 'idle' | 'submitting' | 'accepted' | 'rejected'
|
||||
bindConfirmMessage?: string
|
||||
bindConfirmState: 'idle' | 'submitting' | 'accepted' | 'rejected'
|
||||
bindConfirmMessage: string
|
||||
rebindCooldownDays: number
|
||||
nextRebindAt: string
|
||||
platformChangeBindDay?: number
|
||||
|
||||
@@ -0,0 +1,169 @@
|
||||
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 customerTypes = readFileSync(join(root, '../src/types/customer-fulfillment.ts'), 'utf8')
|
||||
|
||||
/** 取样一段源码,找不到时直接失败,避免测试静默通过。 */
|
||||
function pickSlice(startMarker: string, endMarker: string) {
|
||||
const start = source.indexOf(startMarker)
|
||||
assert.ok(start >= 0, `源码缺少 ${startMarker}`)
|
||||
const end = source.indexOf(endMarker, start)
|
||||
assert.ok(end > start, `源码缺少 ${endMarker}`)
|
||||
return source.slice(start, end)
|
||||
}
|
||||
|
||||
test('确认成功区块引导客户截图并发给客服,同时给出可复制订单号', () => {
|
||||
const block = pickSlice(
|
||||
"bindingDecision?.flowState === 'confirmed' && !profileEditing",
|
||||
'{isWeibo &&',
|
||||
)
|
||||
assert.ok(block.includes('绑定已确认'))
|
||||
assert.ok(block.includes('截图'))
|
||||
assert.ok(block.includes('发给客服'))
|
||||
assert.ok(block.includes('刷新订单状态'))
|
||||
assert.ok(block.includes('订单号'))
|
||||
// 订单号直接取页面已有的 orderNo / task.orderNo,不另建字段。
|
||||
assert.ok(block.includes('{orderNo || selectedTask?.orderNo || '))
|
||||
assert.ok(block.includes('copyOrderNoForSupport('))
|
||||
// 旧文案已被替换。
|
||||
assert.ok(!source.includes('平台角色绑定已确认,客服正在处理订单'))
|
||||
})
|
||||
|
||||
test('确认按钮不吞掉重新扫码与修改资料两个退回入口', () => {
|
||||
const panel = pickSlice('className="customer-binding-role-actions"', '</div>')
|
||||
const confirmIndex = panel.indexOf('确认绑定这个角色到虎牙')
|
||||
assert.ok(confirmIndex > 0)
|
||||
assert.ok(panel.indexOf('重新扫码换绑') > confirmIndex)
|
||||
assert.ok(panel.indexOf('上一步修改资料') > confirmIndex)
|
||||
assert.ok(panel.includes('onClick={() => void openProfileEditor()}'))
|
||||
assert.ok(panel.includes('onClick={() => void handleRefreshBinding(true)}'))
|
||||
// 不再用 canConfirmDecision ? confirm : 其它动作 的三元结构。
|
||||
assert.ok(!panel.includes(') : ('))
|
||||
})
|
||||
|
||||
test('页面任何位置都不渲染 40 位 role token', () => {
|
||||
const confirmStart = source.indexOf('async function handleConfirmBinding()')
|
||||
const confirmEnd = source.indexOf('async function openProfileEditor()')
|
||||
assert.ok(confirmStart > 0 && confirmEnd > confirmStart)
|
||||
const confirmFn = source.slice(confirmStart, confirmEnd)
|
||||
// token 只用于「确认绑定」请求体,不参与展示。
|
||||
assert.ok(confirmFn.includes('expectedRoleToken'))
|
||||
const outside = source.slice(0, confirmStart) + source.slice(confirmEnd)
|
||||
assert.ok(!outside.includes('bindGameRoleToken'))
|
||||
assert.ok(!source.includes('>{bindingInfo?.bindGameRoleToken'))
|
||||
assert.ok(!source.includes('>{selectedTask?.bindGameRoleToken'))
|
||||
})
|
||||
|
||||
test('冷却天数只按后端返回值展示,为 0 时不出现「剩余约」', () => {
|
||||
const needle = '剩余约'
|
||||
let index = source.indexOf(needle)
|
||||
assert.ok(index > 0, '冷却期文案应当存在')
|
||||
let occurrences = 0
|
||||
while (index > 0) {
|
||||
occurrences += 1
|
||||
const guard = source.slice(Math.max(0, index - 200), index)
|
||||
assert.ok(
|
||||
guard.includes('rebindCooldownDays > 0'),
|
||||
'「剩余约」必须由 rebindCooldownDays > 0 守卫',
|
||||
)
|
||||
index = source.indexOf(needle, index + needle.length)
|
||||
}
|
||||
assert.ok(occurrences >= 1)
|
||||
// 虎牙口径的冷却文案必须存在(客户页绑定阶段使用)。
|
||||
assert.ok(source.includes('当前仍处于虎牙换绑冷却期,剩余约 ${rebindCooldownDays} 天'))
|
||||
// 冷却天数不得由 platformChangeBindDay 推算:窗口天数只用于「每 N 天可换绑 1 次」说明。
|
||||
const dayMarkers = source.split('platformChangeBindDay').length - 1
|
||||
assert.ok(dayMarkers <= 3)
|
||||
assert.ok(!source.includes('rebindCooldownDays + '))
|
||||
})
|
||||
|
||||
test('首次绑定缺码时给出生成二维码主按钮,二维码待扫态可退回改资料', () => {
|
||||
const initialBlock = pickSlice(
|
||||
"bindingDecision?.flowState === 'initial_bind_required'",
|
||||
'{bindingQrVisible && !bindingSessionExpired',
|
||||
)
|
||||
assert.ok(initialBlock.includes('生成绑定二维码'))
|
||||
assert.ok(initialBlock.includes('handleRefreshBinding(true)'))
|
||||
assert.ok(initialBlock.includes('bindingDecision.message'))
|
||||
|
||||
const qrStart = source.indexOf('customer-binding-qr-card customer-huya-qr-card')
|
||||
const qrBlock = source.slice(qrStart, source.indexOf('绑定二维码已过期', qrStart))
|
||||
assert.ok(qrBlock.includes('上一步修改资料'))
|
||||
assert.ok(qrBlock.includes('openProfileEditor()'))
|
||||
})
|
||||
|
||||
test('换绑冷却态提供只读刷新,并明确冷却后的下一步', () => {
|
||||
const blocked = pickSlice('isRebindBlocked ? (', ') : showRebindFailure ? (')
|
||||
assert.ok(blocked.includes('冷却结束后再回来点「重新扫码换绑」'))
|
||||
assert.ok(blocked.includes('平台未返回下次可换绑时间,请联系客服核实'))
|
||||
assert.ok(!blocked.includes('剩余约'))
|
||||
// 冷却态没有换绑动作,只能用只读刷新按钮重新查状态。
|
||||
assert.ok(
|
||||
source.includes('const canRefreshBindingState = decisionCanRefreshBinding || isRebindBlocked'),
|
||||
)
|
||||
assert.ok(source.includes('刷新绑定状态'))
|
||||
})
|
||||
|
||||
test('失败提示展示平台原因与任务异常且去重', () => {
|
||||
assert.ok(source.includes('bindingInfo?.bindConfirmMessage'))
|
||||
assert.ok(source.includes('selectedTask?.bindConfirmMessage'))
|
||||
assert.ok(source.includes('bindingDecision?.message'))
|
||||
assert.ok(source.includes('selectedTask?.lastError'))
|
||||
assert.ok(source.includes('seen.has(text)'))
|
||||
assert.ok(source.includes('bindingFailureReasons'))
|
||||
// 任务 DTO 新增字段已进类型。
|
||||
assert.ok(customerTypes.includes('bindConfirmState'))
|
||||
assert.ok(customerTypes.includes('bindConfirmMessage'))
|
||||
assert.ok(customerTypes.includes('lastError'))
|
||||
})
|
||||
|
||||
test('first_bind_role_mismatch 走可自愈动作,不归到人工核实', () => {
|
||||
// 首次绑定扫错角色仍由后端产出该状态,页面必须渲染它(含重新扫码 + 修改资料),
|
||||
// 且不能把它当成「两侧信息不完整,只能联系客服」。
|
||||
assert.ok(source.includes("'first_bind_role_mismatch'"))
|
||||
assert.ok(source.includes('bindingRequiresSupport'))
|
||||
assert.ok(!source.includes("['manual_review', 'first_bind_role_mismatch']"))
|
||||
})
|
||||
|
||||
test('后端可能产出的每个 flowState 都在客户页有落点,不存在只提示无动作的死状态', () => {
|
||||
const pageSource = readFileSync(
|
||||
join(root, '../src/pages/customer-fulfillment/CustomerFulfillmentPage.tsx'),
|
||||
'utf8',
|
||||
)
|
||||
const policySource = readFileSync(
|
||||
join(root, '../../../apps/backend/src/services/semi-auto/huya-binding-policy.ts'),
|
||||
'utf8',
|
||||
)
|
||||
const enumBlock = policySource.slice(
|
||||
policySource.indexOf('export type HuyaBindingFlowState ='),
|
||||
policySource.indexOf('export type HuyaBindingAction ='),
|
||||
)
|
||||
const flowStates = [...enumBlock.matchAll(/'([a-z_]+)'/g)].map((match) => match[1])
|
||||
assert.ok(flowStates.length >= 15, '未解析到 flowState 枚举')
|
||||
|
||||
// 这些状态由其它区块承载:二维码卡片、已确认区块、过期提示、首查、初绑。
|
||||
const handledElsewhere = new Set([
|
||||
'binding_query_required',
|
||||
'initial_bind_required',
|
||||
'first_bind_qr_pending',
|
||||
'rebind_qr_pending',
|
||||
'confirmed',
|
||||
'expired',
|
||||
])
|
||||
const decisionStageBlock = pageSource.slice(
|
||||
pageSource.indexOf('const showBindingDecisionStage = Boolean('),
|
||||
pageSource.indexOf('const bindingComparison ='),
|
||||
)
|
||||
const missing = flowStates.filter(
|
||||
(state) => !handledElsewhere.has(state) && !decisionStageBlock.includes(`'${state}'`),
|
||||
)
|
||||
assert.deepEqual(missing, [], `以下状态在客户页没有任何可操作落点:${missing.join(', ')}`)
|
||||
})
|
||||
@@ -88,17 +88,23 @@ test('虎牙绑定只在二维码或平台生效等待态轮询,过期二维
|
||||
assert.ok(!pollingSource.includes('bindingActions.has('))
|
||||
})
|
||||
|
||||
test('角色名和区服一致才显示页内确认按钮,不一致时展示原因', () => {
|
||||
test('角色名和区服一致时确认按钮在最上,退回入口不被吞掉', () => {
|
||||
assert.ok(source.includes('确认绑定这个角色到虎牙'))
|
||||
assert.ok(source.includes('canConfirmDecision'))
|
||||
assert.ok(source.includes('onClick={() => void handleConfirmBinding()}'))
|
||||
assert.ok(source.includes('{canConfirmDecision ? ('))
|
||||
const confirmBranchStart = source.indexOf('{canConfirmDecision ? (')
|
||||
const confirmBranchEnd = source.indexOf(') : (', confirmBranchStart)
|
||||
const confirmBranch = source.slice(confirmBranchStart, confirmBranchEnd)
|
||||
assert.ok(confirmBranch.includes('确认绑定这个角色到虎牙'))
|
||||
assert.ok(!confirmBranch.includes('刷新绑定二维码'))
|
||||
assert.ok(!confirmBranch.includes('上一步修改资料'))
|
||||
const panelStart = source.indexOf('className="customer-binding-role-actions"')
|
||||
const panelEnd = source.indexOf('</div>', panelStart)
|
||||
const panel = source.slice(panelStart, panelEnd)
|
||||
const confirmIndex = panel.indexOf('确认绑定这个角色到虎牙')
|
||||
assert.ok(confirmIndex > 0)
|
||||
// 确认按钮排在最上面,但重新扫码 / 修改资料必须同时可点,不能落进 else 分支。
|
||||
assert.ok(panel.includes('重新扫码换绑'))
|
||||
assert.ok(panel.includes('刷新绑定二维码'))
|
||||
assert.ok(panel.includes('上一步修改资料'))
|
||||
assert.ok(confirmIndex < panel.indexOf('刷新绑定二维码'))
|
||||
assert.ok(confirmIndex < panel.indexOf('上一步修改资料'))
|
||||
assert.ok(!panel.includes(') : ('))
|
||||
assert.ok(source.includes('平台角色与已填资料不一致'))
|
||||
assert.ok(source.includes('角色名称、区服和平台信息一致后才能确认绑定'))
|
||||
assert.ok(!styles.includes('.customer-binding-modal'))
|
||||
|
||||
Reference in New Issue
Block a user