86 lines
3.6 KiB
TypeScript
86 lines
3.6 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 source = readFileSync(
|
|
join(
|
|
dirname(fileURLToPath(import.meta.url)),
|
|
'../src/pages/customer-fulfillment/CustomerFulfillmentPage.tsx',
|
|
),
|
|
'utf8',
|
|
)
|
|
const layoutStyles = readFileSync(
|
|
join(dirname(fileURLToPath(import.meta.url)), '../src/styles/customer/layout.css'),
|
|
'utf8',
|
|
)
|
|
const weiboStyles = readFileSync(
|
|
join(dirname(fileURLToPath(import.meta.url)), '../src/styles/customer/platform/weibo.css'),
|
|
'utf8',
|
|
)
|
|
|
|
test('微博与虎牙共用同一套登录表单结构', () => {
|
|
assert.match(source, /const renderLoginForm = \(options: \{/)
|
|
assert.ok(source.includes("platformLabel: '虎牙'"))
|
|
assert.ok(source.includes("platformLabel: '微博'"))
|
|
assert.ok(!source.includes('customer-auth-tabs'))
|
|
assert.ok(!source.includes('SafetyCertificateOutlined'))
|
|
})
|
|
|
|
test('微博保留两种登录方式与全部原有提示', () => {
|
|
assert.ok(source.includes('改用二维码登录'))
|
|
assert.ok(source.includes('改用手机号登录'))
|
|
assert.ok(source.includes('smsMfaRequired'))
|
|
assert.ok(source.includes('如安全验证弹窗未出现'))
|
|
assert.ok(source.includes('CustomerPrivacyNote'))
|
|
assert.ok(source.includes('温馨提示:未成年人禁止下单'))
|
|
})
|
|
|
|
test('二维码切换与虎牙一致:直接切到扫码并发起登录', () => {
|
|
assert.ok(source.includes("setLoginMode('qr')"))
|
|
assert.ok(source.includes('void handleStartLogin()'))
|
|
})
|
|
|
|
test('微博登录后展示微信/QQ 游戏角色绑定,不再登录即完成', () => {
|
|
assert.ok(source.includes('const showWeiboBindingStage = Boolean('))
|
|
assert.ok(source.includes('绑定微博游戏角色'))
|
|
assert.ok(source.includes('handleStartWeiboBinding'))
|
|
assert.ok(source.includes('微信绑定'))
|
|
assert.ok(source.includes('QQ 绑定'))
|
|
assert.ok(source.includes('微博角色已绑定,等待客服处理'))
|
|
assert.ok(source.includes("selectedTask.bindingStatus === 'confirmed'"))
|
|
assert.ok(!source.includes('微博登录即授权'))
|
|
})
|
|
|
|
test('微博绑定轮询与虎牙共用会话恢复和失效重新登录入口', () => {
|
|
assert.ok(source.includes('const weiboBinding ='))
|
|
assert.ok(source.includes('pollCustomerBinding(orderNo, selectedTask.id)'))
|
|
assert.ok(source.includes("'weibo_session_not_found'"))
|
|
assert.ok(source.includes("'weibo_credential_invalid'"))
|
|
assert.ok(source.includes('微博登录已失效'))
|
|
})
|
|
|
|
test('微博订单卡只展示订单号/商品/平台/状态,不含游戏和角色名称', () => {
|
|
const weiboBranch = source.slice(
|
|
source.indexOf("if (task.platform === 'weibo')"),
|
|
source.indexOf('const zone = task.customerServerZone'),
|
|
)
|
|
assert.ok(weiboBranch.includes('<span>订单号</span>'))
|
|
assert.ok(weiboBranch.includes('<span>商品</span>'))
|
|
assert.ok(weiboBranch.includes('<span>平台</span>'))
|
|
assert.ok(weiboBranch.includes('<span>状态</span>'))
|
|
assert.ok(!weiboBranch.includes('角色名称'))
|
|
assert.ok(!weiboBranch.includes('游戏名称'))
|
|
})
|
|
|
|
test('客户登录/绑定页顶部统一显示 inside-kv 背景,不再按平台区分', () => {
|
|
assert.match(
|
|
layoutStyles,
|
|
/\.customer-auth-hero \{[^}]*url\('\/images\/customer\/inside-kv\.jpg'\)[^}]*\}/s,
|
|
)
|
|
assert.ok(!weiboStyles.includes('.customer-auth-page.is-weibo .customer-auth-hero'))
|
|
assert.ok(!layoutStyles.includes('.customer-auth-page.is-huya .customer-auth-hero'))
|
|
assert.ok(weiboStyles.includes('.customer-auth-page.is-weibo .customer-auth-brand'))
|
|
})
|