74 lines
3.2 KiB
TypeScript
74 lines
3.2 KiB
TypeScript
import test from 'node:test'
|
|
import assert from 'node:assert/strict'
|
|
import { readSource } from './helpers.ts'
|
|
import { adminPages } from '../src/router/routes.ts'
|
|
import {
|
|
OPERATION_GUIDES,
|
|
OPERATION_GUIDE_FALLBACK,
|
|
OPERATION_GUIDE_STORAGE_KEY,
|
|
operationGuideFor,
|
|
} from '../src/layout/operation-guides.ts'
|
|
|
|
/** 对齐旧版 admin-interactions.js guides 表:每业务菜单页顶部展示可折叠「当前页面操作提示」,文案沿用旧版原文;店铺撞款监控(例外)不展示。 */
|
|
|
|
const EXCEPTED_KEY = 'admin_shop_data_duplicate_check'
|
|
|
|
test('align_guide_users_matches_reference_text', () => {
|
|
const g = operationGuideFor('admin_users')
|
|
assert.ok(g)
|
|
assert.equal(g.text, '先用筛选定位账号,再编辑角色和菜单权限;删除账号会要求二次确认。')
|
|
assert.deepEqual(g.steps, ['筛选账号', '编辑权限', '确认保存'])
|
|
})
|
|
|
|
test('align_guide_history_and_version_reference_text', () => {
|
|
assert.match(operationGuideFor('admin_history')!.text, /生成记录可按用户和时间范围回溯/)
|
|
assert.deepEqual(operationGuideFor('admin_version')!.steps, ['上传压缩包', '检查版本记录', '维护历史版本'])
|
|
})
|
|
|
|
test('align_guide_group_manage_falls_back', () => {
|
|
// 旧版 group-manage 无独立 guide,用通用 fallback。
|
|
assert.deepEqual(operationGuideFor('admin_group_manage'), OPERATION_GUIDE_FALLBACK)
|
|
})
|
|
|
|
test('align_guide_duplicate_check_not_present', () => {
|
|
// 例外页:不展示提示条(不参与本轮对齐)。
|
|
assert.equal(operationGuideFor(EXCEPTED_KEY), null)
|
|
assert.equal(EXCEPTED_KEY in OPERATION_GUIDES, false)
|
|
})
|
|
|
|
test('align_guide_unknown_key_null', () => {
|
|
assert.equal(operationGuideFor(undefined), null)
|
|
assert.equal(operationGuideFor(null), null)
|
|
assert.equal(operationGuideFor('not-a-menu'), null)
|
|
assert.equal(operationGuideFor(''), null)
|
|
})
|
|
|
|
test('align_guide_every_router_page_has_guide_except_duplicate_check', () => {
|
|
// 路由注册表里的业务页除例外页外都应有独立/兜底提示。
|
|
const without = adminPages.filter((p) => p.menuKey !== EXCEPTED_KEY)
|
|
assert.ok(without.length >= 15, '业务页至少 15')
|
|
for (const page of without) {
|
|
assert.ok(operationGuideFor(page.menuKey), `缺少 guide: ${page.menuKey}`)
|
|
}
|
|
})
|
|
|
|
test('align_guide_storage_key_matches_legacy', () => {
|
|
assert.equal(OPERATION_GUIDE_STORAGE_KEY, 'shufuAdminGuideCollapsed')
|
|
})
|
|
|
|
test('align_guide_component_in_layout_headline', () => {
|
|
const layout = readSource('src/layout/AdminLayout.vue')
|
|
assert.match(layout, /OperationGuide/, '壳层引用 OperationGuide 组件')
|
|
const comp = readSource('src/layout/OperationGuide.vue')
|
|
assert.match(comp, /当前页面操作提示/, '标题对齐旧版 adminOperationGuide 语义')
|
|
assert.match(comp, /收起提示/, '折叠按钮文案')
|
|
assert.match(comp, /展开提示/, '展开按钮文案')
|
|
assert.match(comp, /operationGuideFor\(route\.meta\.menuKey\)/, '按菜单 key 查文案')
|
|
assert.match(comp, /OPERATION_GUIDE_STORAGE_KEY/, '折叠态读写同一 localStorage key')
|
|
})
|
|
|
|
test('align_guide_fallback_shape', () => {
|
|
assert.equal(OPERATION_GUIDE_FALLBACK.steps.length, 3)
|
|
assert.ok(OPERATION_GUIDE_FALLBACK.text.length > 10)
|
|
})
|