feat(common-tools): 工具台新增常用工具分类,三个桌面工具网页化
- tool-catalog 最前插入「常用工具」组(brand_common_tools,23 工具·4 大分类), 三工具各自权限键:pricing-calc / five-asin / keyword-share - /pricing-calc:站点(英 GBP÷9、德法 EUR÷8)+ 买货价/运费 → 营业额/利润/ 利润率/换算汇率,公式与精度照抄桌面版,纯函数 node --test 钉住 - /five-asin:五国常量 + ASIN 10 位校验 → 亚马逊商品链接,window.open 与 :href 出口全部过 safeHttpUrl(url-outlet 棘轮),邮编一键复制 - /keyword-share:筛选/四级类目级联/统计卡/表格分页 200/标记与取消使用/ 添加/删除/随机抽词/共享记录,对接 keywordshare 后端九端点 - 顶栏与 BrandTopBar 导航同步;router 注册三路由;补 test:mount 脚本 (vitest mount 套件入口,与后管同口径)
This commit is contained in:
@@ -11,9 +11,9 @@ import {
|
||||
TOOL_MAP,
|
||||
} from '../src/pages/amazon/tool-catalog.ts'
|
||||
|
||||
test('工具目录:20 个工具 id 唯一且每个都有图标与渐变配色', () => {
|
||||
test('工具目录:23 个工具 id 唯一且每个都有图标与渐变配色', () => {
|
||||
const ids = TOOL_GROUPS.flatMap((g) => g.tools.map((t) => t.id))
|
||||
assert.equal(ids.length, 20, '工具总数应为 20(前端8 + 运营10 + 后勤2)')
|
||||
assert.equal(ids.length, 23, '工具总数应为 23(常用3 + 前端8 + 运营10 + 后勤2)')
|
||||
assert.equal(new Set(ids).size, ids.length, '工具 id 不应重复')
|
||||
for (const id of ids) {
|
||||
assert.ok(TOOL_ICON_SHAPES[id], `图标形状缺失: ${id}`)
|
||||
@@ -22,6 +22,51 @@ test('工具目录:20 个工具 id 唯一且每个都有图标与渐变配色'
|
||||
}
|
||||
})
|
||||
|
||||
test('工具目录:常用工具分组排在最前且三个工具都有页面与权限键', () => {
|
||||
const common = TOOL_GROUPS[0]
|
||||
assert.equal(common.key, 'common', '常用工具组应在 TOOL_GROUPS 最前')
|
||||
assert.equal(common.columnKey, 'brand_common_tools')
|
||||
assert.equal(common.name, '常用工具')
|
||||
assert.equal(common.desc, '换算 · 查询 · 词库共享,高频小工具')
|
||||
assert.ok(common.color, '常用工具组应有主色')
|
||||
assert.equal(common.workflow, undefined, '常用工具组没有标准工作流')
|
||||
|
||||
const byId = new Map(common.tools.map((tool) => [tool.id, tool]))
|
||||
assert.deepEqual(
|
||||
[...byId.keys()],
|
||||
['pricing-calc', 'five-asin', 'keyword-share'],
|
||||
'常用工具组的三个工具顺序固定',
|
||||
)
|
||||
assert.equal(byId.get('pricing-calc')?.href, '/pricing-calc')
|
||||
assert.equal(byId.get('five-asin')?.href, '/five-asin')
|
||||
assert.equal(byId.get('keyword-share')?.href, '/keyword-share')
|
||||
assert.deepEqual(byId.get('pricing-calc')?.permissionKeys, ['pricing-calc'])
|
||||
assert.deepEqual(byId.get('five-asin')?.permissionKeys, ['five-asin'])
|
||||
assert.deepEqual(byId.get('keyword-share')?.permissionKeys, ['keyword-share'])
|
||||
})
|
||||
|
||||
test('权限过滤:常用工具组整组 / 单工具键都按口径过滤', () => {
|
||||
// 组键命中:整组保留且排在最前
|
||||
const withCommon = filterGroupsByPermission(TOOL_GROUPS, ['brand_common_tools'])
|
||||
const common = withCommon.find((group) => group.key === 'common')
|
||||
assert.ok(common, '组键 brand_common_tools 命中时常用工具组应整组可见')
|
||||
assert.deepEqual(common.tools.map((tool) => tool.id), ['pricing-calc', 'five-asin', 'keyword-share'])
|
||||
|
||||
// 只给单个工具权限键:常用组只留命中工具,不整组放行
|
||||
const partial = filterGroupsByPermission(TOOL_GROUPS, ['pricing-calc', 'keyword-share'])
|
||||
const partialCommon = partial.find((group) => group.key === 'common')
|
||||
assert.ok(partialCommon, '有可见工具时常用组不应整体隐藏')
|
||||
assert.deepEqual(partialCommon.tools.map((tool) => tool.id), ['pricing-calc', 'keyword-share'])
|
||||
assert.equal(partialCommon.tools.some((tool) => tool.id === 'five-asin'), false, '无权限的 five-asin 不应混入')
|
||||
|
||||
// 无任何常用权限:常用组整体隐藏
|
||||
const none = filterGroupsByPermission(TOOL_GROUPS, ['brand_front_tools'])
|
||||
assert.equal(none.some((group) => group.key === 'common'), false, '无常用权限时常用组应隐藏')
|
||||
|
||||
// 无任何权限:全部隐藏
|
||||
assert.equal(filterGroupsByPermission(TOOL_GROUPS, []).length, 0)
|
||||
})
|
||||
|
||||
test('工具目录:无页面的工具应在 catalog 里标记为未开通(无 href)', () => {
|
||||
const pending = TOOL_GROUPS.flatMap((g) => g.tools).filter((t) => !t.href)
|
||||
const pendingIds = pending.map((t) => t.id).sort()
|
||||
|
||||
Reference in New Issue
Block a user