feat(admin-jd): 商品目录左栏改读服务端按店铺授权树(无上报时回落内置快照)

承接后端 85425771:左栏树不再只有硬编码快照这一档。

- jd-shop-category-api.ts:GET /api/jd-shop-category-tree 取并集森林(复用 jd-category-tree.ts
  的 parseJdCategoryNodeTree 做脏值/超深/超量护栏,与客户端上报侧同口径)
- JdDatabasePage:onMounted 增一路 loadShopCategoryTree(失败静默回落快照,不占首屏
  失败提示);activeCategoryTree=服务端真树优先、否则内置快照,并作为父级点选展开
  集合的唯一口径源(filter.categoryNames 在选中那一刻按同一棵树算好)
- JdCategorySidebar:prop categoryTree 可注入,计数树按它算;tier1 的 treeForeign
  消歧档照旧(整树零命中且树外有行时才收树点名)
- jd-product-filter:state.categoryNames 优先于按快照展开的 jdCategoryNamesUnder

判据:jd-category-tree.test.ts +2(parse 形状/脏值/超深;自定义树计数对照内置快照)、
mount +1(服务端树渲染「收纳用品 260」且不出现服饰内衣/无 treeForeign、不重复出树外组);
source-pin 基线 jd-category-tree.test.ts 15→17。admin 三连绿:node --test 1979、
vitest 251、vue-tsc rc=0。
This commit is contained in:
2026-11-23 21:27:55 +08:00
parent 854257712a
commit 02cf5e95e5
8 changed files with 228 additions and 11 deletions
@@ -10,8 +10,10 @@
* (点兜底行=单名等值旧形状,path 空数组交给页面回落)。 */ * (点兜底行=单名等值旧形状,path 空数组交给页面回落)。 */
import { computed, nextTick, ref, watch } from 'vue' import { computed, nextTick, ref, watch } from 'vue'
import { import {
JD_CATEGORY_TREE,
jdCategoryCountTree, jdCategoryCountTree,
type JdCategoryCountedNode, type JdCategoryCountedNode,
type JdCategoryNode,
} from './jd-category-tree.ts' } from './jd-category-tree.ts'
import type { JdProductCategoryOption, JdProductGroup } from './jd-product-api.ts' import type { JdProductCategoryOption, JdProductGroup } from './jd-product-api.ts'
@@ -31,6 +33,10 @@ const props = defineProps<{
selectedGroupId?: number | null selectedGroupId?: number | null
/** 当前店铺筛选(v1.7 店铺名单点选;空/缺省=未按店铺过滤)。 */ /** 当前店铺筛选(v1.7 店铺名单点选;空/缺省=未按店铺过滤)。 */
selectedShopName?: string | null selectedShopName?: string | null
/** 授权类目树(2026-11-23):页面从服务端取「已上报店铺并集」的真树传入;
* 缺省/空数组=回落内置快照(`JD_CATEGORY_TREE`,一家店的历史取证,
* 另由 treeForeign 判据收树点名,不冒充本店类目)。 */
categoryTree?: JdCategoryNode[] | null
}>() }>()
const emit = defineEmits<{ const emit = defineEmits<{
@@ -64,7 +70,11 @@ const activeTab = ref<'catalog' | 'custom'>('catalog')
// ---------------- 计数聚合(Phase 1 纯函数) ---------------- // ---------------- 计数聚合(Phase 1 纯函数) ----------------
const counted = computed(() => jdCategoryCountTree(props.categoryOptions ?? [])) /** 生效的授权类目树:服务端真树优先,没有则回落到内置快照(一家店的历史取证)。 */
const activeTree = computed<JdCategoryNode[]>(() =>
(props.categoryTree && props.categoryTree.length ? props.categoryTree : JD_CATEGORY_TREE))
const counted = computed(() => jdCategoryCountTree(props.categoryOptions ?? [], activeTree.value))
/** 内置授权树与本店类目体系不同源:整棵树零命中、且兜底组确有行。内置 `JD_CATEGORY_TREE` /** 内置授权树与本店类目体系不同源:整棵树零命中、且兜底组确有行。内置 `JD_CATEGORY_TREE`
* 是 2026-11-16 从**一家店铺**(花屿巷旗舰店)京麦授权接口抓的固定快照,换一家店(如家居 * 是 2026-11-16 从**一家店铺**(花屿巷旗舰店)京麦授权接口抓的固定快照,换一家店(如家居
@@ -46,6 +46,8 @@ import {
JD_PRODUCT_PAGE_SIZE_OPTIONS, JD_PRODUCT_PAGE_SIZE_OPTIONS,
} from './jd-product-filter.ts' } from './jd-product-filter.ts'
import { JD_PRODUCT_DEFAULT_SIZE, type JdProductItem } from './jd-product-model.ts' import { JD_PRODUCT_DEFAULT_SIZE, type JdProductItem } from './jd-product-model.ts'
import { JD_CATEGORY_TREE, jdCategoryNamesUnder, type JdCategoryNode } from './jd-category-tree.ts'
import { fetchJdShopCategoryTree } from './jd-shop-category-api.ts'
import JdCategorySidebar from './JdCategorySidebar.vue' import JdCategorySidebar from './JdCategorySidebar.vue'
import JdProductCard from './JdProductCard.vue' import JdProductCard from './JdProductCard.vue'
import JdProductDetailModal from './JdProductDetailModal.vue' import JdProductDetailModal from './JdProductDetailModal.vue'
@@ -163,6 +165,12 @@ const activeFilterChips = computed(() => {
function onSelectCategory(value: { name: string; path: string[] } | null): void { function onSelectCategory(value: { name: string; path: string[] } | null): void {
filter.category = value?.name || '' filter.category = value?.name || ''
filter.categoryPath = value?.path ?? [] filter.categoryPath = value?.path ?? []
// 父级点选的子树展开集合按**当前生效的树**算好存进过滤态(2026-11-23):树换成服务端
// 真树后,点「收纳用品」展开的就是真树的子类目名;filter 纯函数层不持有树,
// 避免「侧栏用真树、查询用快照树」两处各读一份。
filter.categoryNames = value && value.path.length
? (jdCategoryNamesUnder(value.path, activeCategoryTree.value) ?? undefined)
: undefined
apply() apply()
} }
@@ -381,6 +389,28 @@ async function loadCategoryOptions(): Promise<void> {
} }
} }
/** 服务端授权类目树(2026-11-23:客户端采集时按店铺上报、服务端并集)。
* null=还没取到或取不到 ⇒ 左栏回落内置快照(再由侧栏 treeForeign 判据收树点名)。 */
const serverCategoryTree = ref<JdCategoryNode[] | null>(null)
/** 左栏实际生效的授权树:服务端真树优先,否则内置快照。
* 它同时是「父级点选展开集合」的口径源——树换了两处必须同源,不能各读各的。 */
const activeCategoryTree = computed<JdCategoryNode[]>(() =>
(serverCategoryTree.value && serverCategoryTree.value.length
? serverCategoryTree.value
: JD_CATEGORY_TREE))
/** 取授权类目树:失败静默回落快照(左栏不是首屏主功能,不占 loadFailure 提示,
* 与 loadCategoryOptions 同档兜底)。 */
async function loadShopCategoryTree(): Promise<void> {
try {
const result = await fetchJdShopCategoryTree()
serverCategoryTree.value = result.nodes.length ? result.nodes : null
} catch {
serverCategoryTree.value = null
}
}
/** 切换「分组」下拉:分类筛选(属于上一组的分类)清空,分类选项换成本组,回第一页重取。 /** 切换「分组」下拉:分类筛选(属于上一组的分类)清空,分类选项换成本组,回第一页重取。
* 勾选集是按商品 id 记的(跨页累计),切组不清——归类的落点组随 ownerGroupId 走, * 勾选集是按商品 id 记的(跨页累计),切组不清——归类的落点组随 ownerGroupId 走,
* 误跨组批量归类由归类对话框里的组名标注防住。 */ * 误跨组批量归类由归类对话框里的组名标注防住。 */
@@ -635,6 +665,7 @@ onMounted(async () => {
// 不要先发一条不带 owner_group_id 的列表请求再补,两次请求会落在不同默认组上)。 // 不要先发一条不带 owner_group_id 的列表请求再补,两次请求会落在不同默认组上)。
await loadCategoryScope() await loadCategoryScope()
void loadCategoryOptions() void loadCategoryOptions()
void loadShopCategoryTree()
await load() await load()
}) })
</script> </script>
@@ -832,6 +863,7 @@ onMounted(async () => {
:selected-category="selectedCategoryInfo" :selected-category="selectedCategoryInfo"
:selected-group-id="selectedGroupIdNum" :selected-group-id="selectedGroupIdNum"
:selected-shop-name="filter.shopName" :selected-shop-name="filter.shopName"
:category-tree="activeCategoryTree"
@select-category="onSelectCategory" @select-category="onSelectCategory"
@select-group="onSelectGroup" @select-group="onSelectGroup"
@select-shop="onSelectShop" @select-shop="onSelectShop"
@@ -38,6 +38,31 @@ export function jdCategoryRoots(): JdCategoryNode[] {
return JD_CATEGORY_TREE return JD_CATEGORY_TREE
} }
/** 解析服务端下发的授权树(2026-11-23):形状与内置快照同款 `{name, value, children}`。
*
* 脏值归一:空名/非对象节点自身丢弃但子级仍展开(不丢整支);value 缺失按空串;
* 超过 8 层截断(京麦现状最深 4 级,护栏只防脏数据递归)。
* 纯函数、零依赖——放在本文件而不是 api 文件,`node --test` 才能直测。 */
export function parseJdCategoryNodeTree(raw: unknown, depth = 0): JdCategoryNode[] {
if (!Array.isArray(raw) || depth > 8) return []
const out: JdCategoryNode[] = []
for (const item of raw) {
if (!item || typeof item !== 'object') continue
const record = item as Record<string, unknown>
const name = typeof record.name === 'string' ? record.name.trim() : ''
const value = record.value == null ? '' : String(record.value).trim()
if (!name) {
out.push(...parseJdCategoryNodeTree(record.children, depth + 1))
continue
}
const node: JdCategoryNode = { name, value }
const children = parseJdCategoryNodeTree(record.children, depth + 1)
if (children.length) node.children = children
out.push(node)
}
return out
}
/** 按名称路径下钻取子级;路径无效返回空数组(面板该栏缺省)。 */ /** 按名称路径下钻取子级;路径无效返回空数组(面板该栏缺省)。 */
export function jdCategoryChildren(path: string[]): JdCategoryNode[] { export function jdCategoryChildren(path: string[]): JdCategoryNode[] {
let level = JD_CATEGORY_TREE let level = JD_CATEGORY_TREE
@@ -129,8 +154,8 @@ export function jdCategorySearchNodes(keyword: string): JdCategoryNodeRef[] {
* 某批行的末级名(真机样本「艺考形体服」即三级节点名)。路径无效返回 null(调用方 * 某批行的末级名(真机样本「艺考形体服」即三级节点名)。路径无效返回 null(调用方
* 按单名等值兜底,语义同树外历史行)。 * 按单名等值兜底,语义同树外历史行)。
*/ */
export function jdCategoryNamesUnder(path: string[]): string[] | null { export function jdCategoryNamesUnder(path: string[], tree: JdCategoryNode[] = JD_CATEGORY_TREE): string[] | null {
let level = JD_CATEGORY_TREE let level = tree
let target: JdCategoryNode | null = null let target: JdCategoryNode | null = null
for (const name of path) { for (const name of path) {
const hit = level.find((node) => node.name === name) const hit = level.find((node) => node.name === name)
@@ -192,8 +217,14 @@ export interface JdCategoryCountTree {
* 吊带/背心/赠品)按过滤语义如实计入两个分支——点哪个分支都按同一名字等值命中 * 吊带/背心/赠品)按过滤语义如实计入两个分支——点哪个分支都按同一名字等值命中
* 同一批行,不是双计;父层子树内按名字去重求和(与展开集合口径一致,父层徽标 * 同一批行,不是双计;父层子树内按名字去重求和(与展开集合口径一致,父层徽标
* 不因同名跨支翻倍)。名字对不上树上任何节点的行归树外兜底组。脏值归一:空名 * 不因同名跨支翻倍)。名字对不上树上任何节点的行归树外兜底组。脏值归一:空名
* 跳过、计数非有限数归 0、负数钳 0、同名多行求和。 */ * 跳过、计数非有限数归 0、负数钳 0、同名多行求和。
export function jdCategoryCountTree(entries: JdCategoryCountEntry[]): JdCategoryCountTree { *
* {@code tree} 缺省=内置快照(一家店的历史取证);后管拿到服务端按店铺上报的授权树后
* 传它进来,同一套计数/兜底口径直接复用(2026-11-23)。 */
export function jdCategoryCountTree(
entries: JdCategoryCountEntry[],
tree: JdCategoryNode[] = JD_CATEGORY_TREE,
): JdCategoryCountTree {
const counts = new Map<string, number>() const counts = new Map<string, number>()
for (const entry of Array.isArray(entries) ? entries : []) { for (const entry of Array.isArray(entries) ? entries : []) {
const name = entry && typeof entry.name === 'string' ? entry.name.trim() : '' const name = entry && typeof entry.name === 'string' ? entry.name.trim() : ''
@@ -223,7 +254,7 @@ export function jdCategoryCountTree(entries: JdCategoryCountEntry[]): JdCategory
} }
return { out, names } return { out, names }
} }
const roots = build(JD_CATEGORY_TREE).out const roots = build(tree).out
const extra: JdCategoryCountEntry[] = [] const extra: JdCategoryCountEntry[] = []
let extraTotal = 0 let extraTotal = 0
for (const [name, count] of counts) { for (const [name, count] of counts) {
@@ -53,6 +53,11 @@ export interface JdProductFilterState {
* jdCategoryNamesUnder 展开为子树类目名集合下发(后端 IN);空=末级/树外行, * jdCategoryNamesUnder 展开为子树类目名集合下发(后端 IN);空=末级/树外行,
* 按单名等值下发(旧形状)。 */ * 按单名等值下发(旧形状)。 */
categoryPath?: string[] categoryPath?: string[]
/** 父级点选时按**当前生效授权树**展开好的类目名集合(2026-11-23):树可以是服务端
* 按店铺上报的真树,纯函数层不持有树,所以由页面在选中那一刻算好放在这里。
* 有值时优先于按内置快照展开的 `jdCategoryNamesUnder(categoryPath)`;
* 空/缺省=照旧按快照树展开(向后兼容旧调用与测试)。 */
categoryNames?: string[]
/** 店铺名(v1.7 店铺名单维度:侧栏点店铺行下发,精确 eq;空串不限)。 */ /** 店铺名(v1.7 店铺名单维度:侧栏点店铺行下发,精确 eq;空串不限)。 */
shopName: string shopName: string
/** 分类 id 文本(侧栏店铺分类 Tab 里那一行),空串=全部分类。 */ /** 分类 id 文本(侧栏店铺分类 Tab 里那一行),空串=全部分类。 */
@@ -82,6 +87,7 @@ export function createJdProductFilterState(): JdProductFilterState {
keyword: '', keyword: '',
category: '', category: '',
categoryPath: [], categoryPath: [],
categoryNames: [],
shopName: '', shopName: '',
groupId: '', groupId: '',
classified: JD_PRODUCT_DEFAULT_CLASSIFIED, classified: JD_PRODUCT_DEFAULT_CLASSIFIED,
@@ -164,9 +170,13 @@ function toJdProductFilterQuery(state: JdProductFilterState): Omit<JdProductQuer
if (category) { if (category) {
// 2026-11-18 一级/二级类目可选中:带路径=按子树展开类目名集合(后端 IN); // 2026-11-18 一级/二级类目可选中:带路径=按子树展开类目名集合(后端 IN);
// 路径失效(树外历史名)回落单名等值集合——与旧 eq 语义逐字同形。 // 路径失效(树外历史名)回落单名等值集合——与旧 eq 语义逐字同形。
const expanded = state.categoryPath && state.categoryPath.length // 2026-11-23:页面若已按服务端真树算好 categoryNames,直接用(两处口径同源,
? jdCategoryNamesUnder(state.categoryPath) // 不再拿内置快照树重算一遍)。
: null const expanded = state.categoryNames && state.categoryNames.length
? state.categoryNames
: state.categoryPath && state.categoryPath.length
? jdCategoryNamesUnder(state.categoryPath)
: null
query.category = expanded && expanded.length ? expanded : [category] query.category = expanded && expanded.length ? expanded : [category]
} }
const shopName = (state.shopName || '').trim() const shopName = (state.shopName || '').trim()
@@ -0,0 +1,53 @@
/** 京麦授权类目树读取(2026-11-23):GET `/api/jd-shop-category-tree`。
*
* 数据来源=客户端采集窗口顺手收到的 `getVenderLicenseCategory`(按店铺上报、服务端并集),
* 与内置快照 `JD_CATEGORY_TREE`(2026-11-16 一家店的历史取证)**同形**——
* `{name, value, children}`,页面拿到后直接替换树数据源,计数/兜底/展开逻辑零改动。
*
* 失败/空一律返回空节点数组:页面据此回落内置快照(再由侧栏 `treeForeign` 判据
* 收树点名「本店无匹配」),绝不让接口抖动把左栏变成一个错误块。 */
import { http } from '@/api/http'
import { unwrap } from '../../api/envelope.ts'
import { parseJdCategoryNodeTree, type JdCategoryNode } from './jd-category-tree.ts'
export { parseJdCategoryNodeTree }
export const JD_SHOP_CATEGORY_TREE_ENDPOINT = '/api/jd-shop-category-tree'
/** 已上报店铺(页面只用于「有没有真树」的判断与排查展示)。 */
export interface JdShopCategoryTreeShop {
shopId: string
shopName: string | null
capturedAt: string | null
nodeCount: number
}
export interface JdShopCategoryTreeResult {
/** 并集森林;空数组=服务端还没有任何店铺上报过。 */
nodes: JdCategoryNode[]
shops: JdShopCategoryTreeShop[]
}
/** 递归解析已在 `jd-category-tree.ts`(零依赖、node --test 可直测),这里只做请求与装配。 */
export async function fetchJdShopCategoryTree(): Promise<JdShopCategoryTreeResult> {
const { data } = await http.get<unknown>(JD_SHOP_CATEGORY_TREE_ENDPOINT)
const core = unwrap<unknown>(data)
if (!core || typeof core !== 'object') return { nodes: [], shops: [] }
const record = core as Record<string, unknown>
const shops: JdShopCategoryTreeShop[] = []
for (const raw of Array.isArray(record.shops) ? record.shops : []) {
if (!raw || typeof raw !== 'object') continue
const row = raw as Record<string, unknown>
const shopId = row.shopId == null ? '' : String(row.shopId).trim()
if (!shopId) continue
shops.push({
shopId,
shopName: typeof row.shopName === 'string' ? row.shopName : null,
capturedAt: typeof row.capturedAt === 'string' ? row.capturedAt : null,
nodeCount: typeof row.nodeCount === 'number' && Number.isFinite(row.nodeCount)
? Math.max(0, Math.floor(row.nodeCount))
: 0,
})
}
return { nodes: parseJdCategoryNodeTree(record.nodes), shops }
}
@@ -2,7 +2,7 @@
"note": "readSource 钉子逐文件基线。两把尺子:pins=落在用例体内的读盘,reads=全文读点总数(含模块级夹具与 helper)。都只许减;pins 下降而 reads 没同步下降=把读盘挪出体内,不算改进。由 tests/source-pin-ratchet.test.ts 生成。", "note": "readSource 钉子逐文件基线。两把尺子:pins=落在用例体内的读盘,reads=全文读点总数(含模块级夹具与 helper)。都只许减;pins 下降而 reads 没同步下降=把读盘挪出体内,不算改进。由 tests/source-pin-ratchet.test.ts 生成。",
"totals": { "totals": {
"files": 265, "files": 265,
"cases": 1860, "cases": 1862,
"pins": 463, "pins": 463,
"reads": 664 "reads": 664
}, },
@@ -318,7 +318,7 @@
"reads": 5 "reads": 5
}, },
"jd-category-tree.test.ts": { "jd-category-tree.test.ts": {
"cases": 15, "cases": 17,
"pins": 0, "pins": 0,
"reads": 0 "reads": 0
}, },
@@ -10,7 +10,9 @@ import {
jdCategoryRoots, jdCategoryRoots,
jdCategorySearchLeaves, jdCategorySearchLeaves,
jdCategorySearchNodes, jdCategorySearchNodes,
parseJdCategoryNodeTree,
type JdCategoryCountedNode, type JdCategoryCountedNode,
type JdCategoryNode,
} from '../src/pages/jd/jd-category-tree.ts' } from '../src/pages/jd/jd-category-tree.ts'
/** 京麦授权类目真树(2026-11-16 真机取证 getVenderLicenseCategory 快照;与用户端 /** 京麦授权类目真树(2026-11-16 真机取证 getVenderLicenseCategory 快照;与用户端
@@ -290,3 +292,57 @@ test('计数聚合——空输入:全树 0、兜底组空(结构仍完整可
assert.equal(junk.roots.length, 3) assert.equal(junk.roots.length, 3)
assert.equal(junk.extraTotal, 0) assert.equal(junk.extraTotal, 0)
}) })
test('服务端授权树解析:与内置快照同形、空名节点丢自身保子级、非数组/超深归空', () => {
const parsed = parseJdCategoryNodeTree([
{ name: ' 收纳用品 ', value: '7001', children: [
{ name: '化妆品收纳盒', value: '7002' },
{ name: '', value: 'x', children: [{ name: '孤儿但保留', value: '7003' }] },
{ notAnObject: true },
] },
{ name: '厨房用品', value: 7004 },
])
assert.deepEqual(parsed, [
{ name: '收纳用品', value: '7001', children: [
{ name: '化妆品收纳盒', value: '7002' },
{ name: '孤儿但保留', value: '7003' },
] },
{ name: '厨房用品', value: '7004' },
], 'name trim、value 数字转串、空名节点自身丢弃但子级上提')
assert.deepEqual(parseJdCategoryNodeTree(null), [], '非数组按空处理(接口抖动不炸渲染)')
// 10 层脏数据:只留前 9 层(depth 0..8),第 10 层被护栏截断。
let deep: unknown = [{ name: 'L10', value: '10' }]
for (let i = 9; i >= 1; i--) {
deep = [{ name: 'L' + i, value: String(i), children: deep }]
}
assert.equal(JSON.stringify(parseJdCategoryNodeTree(deep)).includes('L10'), false,
'超过 8 层的脏数据不递归下去(护栏在解析层,不留给渲染层)')
})
test('计数聚合——传入服务端真树:家居类目挂得上树、不再落兜底(2026-11-23 家居店活样本)', () => {
const homeTree: JdCategoryNode[] = [
{ name: '收纳用品', value: '7001', children: [
{ name: '化妆品收纳盒', value: '7002' },
{ name: '脏衣篓', value: '7003' },
] },
{ name: '厨房用品', value: '7101', children: [{ name: '其他收纳架', value: '7102' }] },
]
const counts = [
{ name: '化妆品收纳盒', productCount: 260 },
{ name: '其他收纳架', productCount: 4 },
]
const real = jdCategoryCountTree(counts, homeTree)
assert.equal(real.treeMatched, true, '真树有命中 ⇒ 侧栏不收树')
assert.equal(real.extra.length, 0, '家居类目全部挂得上真树,不再落树外兜底')
assert.equal(real.roots.length, 2)
assert.equal(nodeAt(real.roots, ['收纳用品', '化妆品收纳盒'])!.count, 260)
assert.equal(nodeAt(real.roots, ['收纳用品'])!.count, 260, '父级徽标=子树和')
assert.equal(nodeAt(real.roots, ['厨房用品'])!.count, 4)
// 同一批计数行套内置快照树 ⇒ 整树零命中(数据没错,是树不对——这就是本次修的那个形状)。
const snapshot = jdCategoryCountTree(counts)
assert.equal(snapshot.treeMatched, false)
assert.equal(snapshot.extraTotal, 264)
})
@@ -280,6 +280,31 @@ describe('内置授权树与本店不同源(2026-11-23:家居日用店打开
expect(treeDisplay(catalog)).not.toBe('none') expect(treeDisplay(catalog)).not.toBe('none')
wrapper.unmount() wrapper.unmount()
}) })
it('传服务端真树(家居店):树上就是收纳类目、兜底清空、不同源判据不触发', () => {
const wrapper = mount(JdCategorySidebar, {
props: {
categoryOptions: FOREIGN_OPTIONS,
categories: CATEGORIES,
editable: true,
selectedCategory: null,
selectedGroupId: null,
// 2026-11-23:客户端按店铺上报的授权树(形状与内置快照同款)。
categoryTree: [
{ name: '收纳用品', value: '7001', children: [{ name: '化妆品收纳盒', value: '7002' }] },
{ name: '厨房用品', value: '7101', children: [{ name: '其他收纳架', value: '7102' }] },
],
},
})
const catalog = wrapper.get('.jd-side-catalog')
expect(catalog.find('.jd-side-foreign-head').exists()).toBe(false,
'真树有命中 ⇒ 不再点名「本店无匹配」')
expect(treeDisplay(catalog)).not.toBe('none', '真树直接渲染,不收起')
expect(rowByText(catalog, '收纳用品').text()).toContain('260', '计数徽标按真树聚合')
expect(catalog.find('.jd-side-extra').exists()).toBe(false, '所有类目都挂得上真树,兜底组不占位')
expect(catalog.text()).not.toContain('服饰内衣', '内置快照树被服务端真树替换')
wrapper.unmount()
})
}) })
describe('店铺分类 Tab(当前分组分类平铺+入口分档)', () => { describe('店铺分类 Tab(当前分组分类平铺+入口分档)', () => {