feat(phase-5): 京东数据库页重写装配——侧栏+卡片网格+居中详情弹窗;级联面板/详情抽屉退役(AC-9 参数逐字等价)
This commit is contained in:
@@ -1,82 +0,0 @@
|
||||
/**
|
||||
* 京东类目级联面板(JdCategoryCascader)圆点选中态的挂载契约。
|
||||
*
|
||||
* 2026-11-19 用户口径「怎么就最后一个才实心圆点阿」⇒ 圆点填芯改成**整条选中链**:
|
||||
* 选中末级时,路径上的祖先行(母婴/童装/家居服)圆点一并亮蓝芯;非路径行(兄弟、
|
||||
* 叔叔档)保持空心。把填芯改回「仅全路径等值」即红(祖先变空心),把兄弟也填上
|
||||
* 即红(非路径断言变绿不了)。搜索态扁平列表同一判据(前缀行也填芯)。
|
||||
*
|
||||
* 跑法:`npx vitest run tests/mount/jd-category-cascader.mount.test.ts`
|
||||
*/
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { mount, type VueWrapper } from '@vue/test-utils'
|
||||
|
||||
import JdCategoryCascader from '@/pages/jd/JdCategoryCascader.vue'
|
||||
|
||||
/** 真树路径(jd-category-tree.ts,京麦授权类目):母婴 > 童装 > 家居服 > 家居服套装。 */
|
||||
const LEAF_PATH = ['母婴', '童装', '家居服', '家居服套装']
|
||||
|
||||
type Wrapper = VueWrapper<Element>
|
||||
|
||||
function mountCascader(props: { modelValue: string; selectedPath: string[] }): Wrapper {
|
||||
return mount(JdCategoryCascader, { props: { ...props, options: [] } })
|
||||
}
|
||||
|
||||
/** 按 .cat-name 精确文本找行,返回其圆点是否填芯;行不存在返回 null。 */
|
||||
function dotOn(wrapper: Wrapper, name: string): boolean | null {
|
||||
const row = wrapper.findAll('.cat-row').find((item) => item.find('.cat-name').text() === name)
|
||||
if (!row) return null
|
||||
return row.find('.cat-dot').classes().includes('on')
|
||||
}
|
||||
|
||||
async function openPanel(wrapper: Wrapper): Promise<void> {
|
||||
await wrapper.find('.cat-trigger').trigger('click')
|
||||
}
|
||||
|
||||
describe('下钻态:选中末级 ⇒ 整条路径填芯', () => {
|
||||
it('路径各级圆点全亮,兄弟/叔叔行空心', async () => {
|
||||
const wrapper = mountCascader({ modelValue: '家居服套装', selectedPath: LEAF_PATH })
|
||||
// 重开面板自动按 selectedPath 铺栏(toggle 既有行为),路径四级同屏可见。
|
||||
await openPanel(wrapper)
|
||||
for (const name of LEAF_PATH) {
|
||||
expect(dotOn(wrapper, name), `路径行 ${name} 应填芯`).toBe(true)
|
||||
}
|
||||
// 非路径行:一级栏的兄弟(服饰内衣/运动户外)、童装栏的兄弟(礼服/演出服)、
|
||||
// 家居服栏的兄弟(家居服上装)都不得亮;清选行的「全部类目」在已选时也不亮。
|
||||
for (const name of ['服饰内衣', '运动户外', '礼服/演出服', '家居服上装', '全部类目']) {
|
||||
expect(dotOn(wrapper, name), `非路径行 ${name} 应保持空心`).toBe(false)
|
||||
}
|
||||
})
|
||||
|
||||
it('选中父级 ⇒ 该级与祖先填芯,其子级空心', async () => {
|
||||
const wrapper = mountCascader({ modelValue: '家居服', selectedPath: ['母婴', '童装', '家居服'] })
|
||||
await openPanel(wrapper)
|
||||
for (const name of ['母婴', '童装', '家居服']) {
|
||||
expect(dotOn(wrapper, name), `路径行 ${name} 应填芯`).toBe(true)
|
||||
}
|
||||
// activePath 只铺到童装,家居服套装不在屏上——栏算到选中级即止。
|
||||
expect(dotOn(wrapper, '家居服套装')).toBeNull()
|
||||
expect(dotOn(wrapper, '儿童汉服/旗袍/唐装')).toBe(false)
|
||||
})
|
||||
|
||||
it('未选(全部类目)⇒ 只有清选行填芯', async () => {
|
||||
const wrapper = mountCascader({ modelValue: '', selectedPath: [] })
|
||||
await openPanel(wrapper)
|
||||
expect(dotOn(wrapper, '全部类目')).toBe(true)
|
||||
expect(dotOn(wrapper, '母婴')).toBe(false)
|
||||
})
|
||||
})
|
||||
|
||||
describe('搜索态:扁平结果同一判据', () => {
|
||||
it('关键词命中时,选中链(前缀行+末级行)填芯,其余空心', async () => {
|
||||
const wrapper = mountCascader({ modelValue: '家居服套装', selectedPath: LEAF_PATH })
|
||||
await openPanel(wrapper)
|
||||
await wrapper.find('input[placeholder="搜索类目"]').setValue('家居服')
|
||||
// 家居服=路径前缀、家居服套装=全路径命中 ⇒ 都填芯。
|
||||
expect(dotOn(wrapper, '家居服')).toBe(true)
|
||||
expect(dotOn(wrapper, '家居服套装')).toBe(true)
|
||||
// 家居服上装=同关键词命中但不在选中链上;睡衣/家居服=服饰内衣支的同名近亲 ⇒ 空心。
|
||||
expect(dotOn(wrapper, '家居服上装')).toBe(false)
|
||||
expect(dotOn(wrapper, '睡衣/家居服')).toBe(false)
|
||||
})
|
||||
})
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user