Files
order_site/apps/frontend/tests/customer-fulfillment-weibo-ui.test.ts
T

59 lines
2.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 source = readFileSync(
join(
dirname(fileURLToPath(import.meta.url)),
'../src/pages/customer-fulfillment/CustomerFulfillmentPage.tsx',
),
'utf8',
)
const styles = readFileSync(
join(dirname(fileURLToPath(import.meta.url)), '../src/styles/client.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('微博订单卡只展示订单号/商品/平台/状态,不含游戏和角色名称', () => {
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.ok(styles.includes('.customer-auth-page.is-weibo .customer-auth-hero'))
assert.ok(styles.includes("url('/images/customer/inside-kv.jpg')"))
assert.ok(!styles.includes('.customer-auth-page.is-huya .customer-auth-hero'))
})