45 lines
1.8 KiB
TypeScript
45 lines
1.8 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 root = dirname(fileURLToPath(import.meta.url))
|
|
const page = readFileSync(
|
|
join(root, '../src/pages/douyu-fulfillment/DouyuFulfillmentPage.tsx'),
|
|
'utf8',
|
|
)
|
|
const frontendService = readFileSync(join(root, '../src/services/douyu-fulfillment.ts'), 'utf8')
|
|
const backendRoute = readFileSync(
|
|
join(root, '../../backend/src/routes/douyu-fulfillment.ts'),
|
|
'utf8',
|
|
)
|
|
|
|
test('斗鱼准备阶段只刷新状态,不自动重复开始绑定', () => {
|
|
assert.ok(!page.includes('autoStartRef'))
|
|
assert.ok(!page.includes('void startDouyuBinding(orderNo)'))
|
|
assert.ok(page.includes('async function refreshStatus()'))
|
|
assert.ok(page.includes('onClick={() => void refreshStatus()}'))
|
|
assert.ok(page.includes('刷新状态'))
|
|
})
|
|
|
|
test('刷新二维码前先同步权威状态,有效二维码直接复用', () => {
|
|
const start = page.indexOf('async function startBinding(forceRefresh = false)')
|
|
const body = page.slice(start, start + 1200)
|
|
assert.ok(
|
|
body.indexOf('refreshDouyuBinding(orderNo)') < body.indexOf('startDouyuBinding(orderNo'),
|
|
)
|
|
assert.ok(body.includes('二维码仍在有效期内,已复用当前二维码'))
|
|
})
|
|
|
|
test('客户刷新状态走独立接口,不复用绑定启动接口', () => {
|
|
assert.ok(frontendService.includes('/binding/refresh'))
|
|
assert.ok(backendRoute.includes("'/:orderNo/binding/refresh'"))
|
|
assert.ok(backendRoute.includes('refreshDouyuCustomerBinding'))
|
|
})
|
|
|
|
test('斗鱼领取页顶部保留 KV,不再展示领取标题', () => {
|
|
assert.ok(!page.includes('斗鱼精英宝典领取'))
|
|
assert.ok(page.includes('customer-auth-hero" aria-hidden="true"'))
|
|
})
|