54 lines
2.9 KiB
TypeScript
54 lines
2.9 KiB
TypeScript
import test from 'node:test'
|
||
import assert from 'node:assert/strict'
|
||
import { readSource } from './helpers.ts'
|
||
import { makeCategoryLoadMoreNode, toProductCategoryNode } from '../src/pages/asin/product-category-model.ts'
|
||
|
||
// 验收反馈(两轮):类目树显示不对,参考旧版页面 —— 改为树形表格:
|
||
// 缩进层级 + [+/-] 展开折叠标记 + 名称/层级路径/排序/来源/说明/操作列,懒加载与加载更多保留。
|
||
|
||
test('align_category_tree_table_normal_primary_path', () => {
|
||
const page = readSource('src/pages/asin/ProductCategoryPage.vue')
|
||
assert.ok(!page.includes('<el-tree'), '不再使用 el-tree,改为树形表格')
|
||
assert.match(page, /tree-node-mark/, '树形展开折叠标记(+/−)')
|
||
assert.match(page, /tree-indent/, '层级缩进')
|
||
})
|
||
|
||
test('align_category_tree_table_normal_variant_input', () => {
|
||
const page = readSource('src/pages/asin/ProductCategoryPage.vue')
|
||
assert.match(page, /expandedIds/, '客户端展开状态集合')
|
||
assert.match(page, /treeRows/, '按展开状态扁平化行集')
|
||
for (const col of ['层级路径', '排序', '来源', '备注']) {
|
||
assert.match(page, new RegExp(col), `树形表格含「${col}」列(旧版列名为备注)`)
|
||
}
|
||
})
|
||
|
||
test('align_category_tree_table_boundary_empty_input', () => {
|
||
// 展开折叠标记:childCount>0 显示 +/−;叶子无标记(对齐旧版 tree-node-mark is-leaf)。
|
||
const page = readSource('src/pages/asin/ProductCategoryPage.vue')
|
||
assert.match(page, /childCount/, '标记按 childCount 判断')
|
||
assert.match(page, /is-leaf/, '叶子标记态样式')
|
||
})
|
||
|
||
test('align_category_tree_table_boundary_single_item', () => {
|
||
// 懒加载保留:展开时未加载子级先拉取第一页;加载更多合成行保留。
|
||
const page = readSource('src/pages/asin/ProductCategoryPage.vue')
|
||
assert.match(page, /loadChildrenPage/, '展开懒加载保留')
|
||
assert.match(page, /isCategoryLoadMoreNode/, '加载更多行保留')
|
||
})
|
||
|
||
test('align_category_tree_table_repeated_operation_is_idempotent', () => {
|
||
// 合成节点 id 仍唯一(loadMore 独立负数域,避免 node key 冲突致行错位)。
|
||
const ids = new Set([makeCategoryLoadMoreNode(null, 1, 2).id, makeCategoryLoadMoreNode(1, 1, 2).id, makeCategoryLoadMoreNode(2, 1, 2).id])
|
||
assert.equal(ids.size, 3)
|
||
// 叶子节点 children 为空数组(无占位注入)。
|
||
const leaf = toProductCategoryNode({ id: 9, name: '叶子', child_count: 0, path: '叶子' })
|
||
assert.ok(leaf && leaf.children.length === 0)
|
||
})
|
||
|
||
test('align_category_tree_table_dependency_failure_returns_actionable_message', () => {
|
||
// 视觉复刻旧版:圆角方块标记、层级缩进(24px/级)、名称加粗。
|
||
const page = readSource('src/pages/asin/ProductCategoryPage.vue')
|
||
assert.match(page, /tree-node-mark/, '展开标记样式存在')
|
||
assert.match(page, /row\.depth \* 24/, '缩进 24px/级')
|
||
})
|