revert(common-tools): 回滚常用工具分类与三个工具页
按 2026-10-24 决定整体下线:工具目录分组、定价换算/五国ASIN/关键词共享 三页面与路由、资料下载区与测试全部移除;保留 package.json 的 test:mount 脚本(仓内测试基础设施,与后管同口径)。
This commit is contained in:
@@ -11,9 +11,9 @@ import {
|
||||
TOOL_MAP,
|
||||
} from '../src/pages/amazon/tool-catalog.ts'
|
||||
|
||||
test('工具目录:23 个工具 id 唯一且每个都有图标与渐变配色', () => {
|
||||
test('工具目录:20 个工具 id 唯一且每个都有图标与渐变配色', () => {
|
||||
const ids = TOOL_GROUPS.flatMap((g) => g.tools.map((t) => t.id))
|
||||
assert.equal(ids.length, 23, '工具总数应为 23(常用3 + 前端8 + 运营10 + 后勤2)')
|
||||
assert.equal(ids.length, 20, '工具总数应为 20(前端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,51 +22,6 @@ test('工具目录:23 个工具 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