feat(consignment): 打手端寄卖页标题跟随分类 tab 名称
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
import assert from 'node:assert/strict'
|
||||
import { readFileSync } from 'node:fs'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
import test from 'node:test'
|
||||
|
||||
import { resolveConsignmentPageTitle } from '../src/utils/consignment-page-title.ts'
|
||||
|
||||
test('寄卖页标题优先使用打手端 tab 名称', () => {
|
||||
assert.equal(
|
||||
resolveConsignmentPageTitle({ tabTitle: ' 苏尔南寄卖 ', categoryName: '苏尔南手枪' }),
|
||||
'苏尔南寄卖',
|
||||
)
|
||||
})
|
||||
|
||||
test('打手端 tab 名称为空时回退分类名称', () => {
|
||||
assert.equal(
|
||||
resolveConsignmentPageTitle({ tabTitle: ' ', categoryName: ' 暗潮手枪 ' }),
|
||||
'暗潮手枪',
|
||||
)
|
||||
})
|
||||
|
||||
test('tab 名称与分类名称都为空时回退「寄卖」', () => {
|
||||
assert.equal(resolveConsignmentPageTitle({ tabTitle: '', categoryName: '' }), '寄卖')
|
||||
assert.equal(resolveConsignmentPageTitle(null), '寄卖')
|
||||
assert.equal(resolveConsignmentPageTitle(undefined), '寄卖')
|
||||
})
|
||||
|
||||
test('打手端寄卖页标题必须跟随选中分类,不得硬编码', () => {
|
||||
const page = readFileSync(
|
||||
fileURLToPath(new URL('../src/pages/worker/WorkerConsignmentPage.tsx', import.meta.url)),
|
||||
'utf8',
|
||||
)
|
||||
assert.ok(
|
||||
page.includes('const pageTitle = resolveConsignmentPageTitle(selectedProfile)'),
|
||||
'标题必须由当前选中的寄卖配置计算',
|
||||
)
|
||||
const headingStart = page.indexOf('className="worker-orders-heading"')
|
||||
assert.ok(headingStart > 0, '找不到寄卖页大标题')
|
||||
const headingBlock = page.slice(headingStart, headingStart + 160)
|
||||
assert.ok(headingBlock.includes('{pageTitle}'), '大标题必须渲染动态 pageTitle')
|
||||
assert.ok(!headingBlock.includes('苏尔南寄卖'), '大标题不得再硬编码苏尔南寄卖')
|
||||
assert.ok(page.includes('即可发布寄卖'), '白名单提示应使用通用「寄卖」文案')
|
||||
assert.ok(!page.includes('即可发布苏尔南寄卖'), '白名单提示不得再硬编码苏尔南寄卖')
|
||||
})
|
||||
Reference in New Issue
Block a user