fix(admin-jd): 别店快照类目树不再冒充本店——整树零命中时收树并点名
- jdCategoryCountTree 增 treeMatched(树内任一节点 count>0);侧栏据此判「内置授权树 与本店不同源」:JD_CATEGORY_TREE 是 2026-11-16 从花屿巷旗舰店抓的固定快照, 家居日用店打开时整树 0 命中、商品全落树外兜底,旧行为让界面看着像这家店卖女装。 - 整树零命中 ⇒ 树默认收起成一行「授权类目树(本店无匹配)」、点开给一句固定快照说明; 兜底行照旧单名等值可选(筛选不因收树失效);树内有命中时渲染与判据都不变。 - 判据:jd-category-tree.test.ts +1(treeMatched 三态)、mount +3(收起/点开/不误伤); 反向验证关掉判据=2 红。后管 node --test 1977 绿、vitest 250 绿、vue-tsc rc=0; 源码钉子基线只动本笔 cases 14→15(pins/reads 不变)。 - 可读性基线逐条点名:JdCategorySidebar.vue 846→890 行(本笔 +44,树消歧模板/文案/CSS)。
This commit is contained in:
@@ -218,6 +218,70 @@ describe('树外兜底组(树上对不上的历史行,单名等值出口)'
|
||||
})
|
||||
})
|
||||
|
||||
describe('内置授权树与本店不同源(2026-11-23:家居日用店打开服饰快照树)', () => {
|
||||
/** 活样本:库里只有家居收纳类目(家居日用数据库店的 264 件),内置树(花屿巷旗舰店的
|
||||
* 服饰授权快照)节点全 0——旧行为照样渲染整棵服饰树,界面看着像「这家店卖女装」。 */
|
||||
const FOREIGN_OPTIONS: JdProductCategoryOption[] = [
|
||||
{ name: '化妆品收纳盒', productCount: 260 },
|
||||
{ name: '其他收纳架', productCount: 4 },
|
||||
]
|
||||
|
||||
function mountForeign(): VueWrapper<Element> {
|
||||
return mount(JdCategorySidebar, {
|
||||
props: {
|
||||
categoryOptions: FOREIGN_OPTIONS,
|
||||
categories: CATEGORIES,
|
||||
editable: true,
|
||||
selectedCategory: null,
|
||||
selectedGroupId: null,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
/** 树容器的 v-show 态:直接读 inline style(jsdom 的 getComputedStyle 有缓存,
|
||||
* 同一元素二次切换后 isVisible() 仍回旧值——不拿它当判据)。 */
|
||||
function treeDisplay(catalog: VueWrapper<Element>): string {
|
||||
return (catalog.get('.jd-side-tree').element as HTMLElement).style.display
|
||||
}
|
||||
|
||||
it('整树零命中 ⇒ 树默认收起、只留一行「本店无匹配」,兜底行仍可选', async () => {
|
||||
const wrapper = mountForeign()
|
||||
const catalog = wrapper.get('.jd-side-catalog')
|
||||
const head = catalog.get('.jd-side-foreign-head')
|
||||
expect(head.text()).toContain('本店无匹配', '点名「这棵树不适用本店」,不让人以为本店有服饰类目')
|
||||
expect(treeDisplay(catalog)).toBe('none', '整棵树收起(别店快照不冒充本店类目)')
|
||||
expect(catalog.find('.jd-side-tree-ops').exists()).toBe(false, '收起态不摆展开/收起按钮')
|
||||
const extra = rowByText(catalog, '化妆品收纳盒')
|
||||
await extra.trigger('click')
|
||||
await flushPromises()
|
||||
expect(wrapper.emitted('select-category')).toEqual([[{ name: '化妆品收纳盒', path: [] }]],
|
||||
'树外历史行照旧按单名等值出口,筛选不因收树失效')
|
||||
wrapper.unmount()
|
||||
})
|
||||
|
||||
it('点说明行 ⇒ 展开原树与提示文案;再点收起', async () => {
|
||||
const wrapper = mountForeign()
|
||||
const catalog = wrapper.get('.jd-side-catalog')
|
||||
await catalog.get('.jd-side-foreign-head').trigger('click')
|
||||
await flushPromises()
|
||||
expect(treeDisplay(catalog)).not.toBe('none', '点开仍可查原树形状(只读参考)')
|
||||
expect(catalog.get('.jd-side-foreign-tip').text()).toContain('固定快照')
|
||||
expect(catalog.find('.jd-side-tree-ops').exists()).toBe(true, '点开后恢复展开/收起操作')
|
||||
await catalog.get('.jd-side-foreign-head').trigger('click')
|
||||
await flushPromises()
|
||||
expect(treeDisplay(catalog)).toBe('none')
|
||||
wrapper.unmount()
|
||||
})
|
||||
|
||||
it('树内有命中时照旧全树渲染(不同源判据不误伤正常店)', () => {
|
||||
const wrapper = mountSidebar()
|
||||
const catalog = wrapper.get('.jd-side-catalog')
|
||||
expect(catalog.find('.jd-side-foreign-head').exists()).toBe(false)
|
||||
expect(treeDisplay(catalog)).not.toBe('none')
|
||||
wrapper.unmount()
|
||||
})
|
||||
})
|
||||
|
||||
describe('店铺分类 Tab(当前分组分类平铺+入口分档)', () => {
|
||||
it('点店铺分类切 Tab;分类行带计数;点行 emit id、再点已选中的 emit null(toggle 清选)', async () => {
|
||||
const wrapper = mountSidebar()
|
||||
|
||||
Reference in New Issue
Block a user