feat(jd): 京东数据库筛选行加「分类状态」下拉(全部/已分类/未分类)
This commit is contained in:
@@ -73,3 +73,23 @@ test('类目筛选参数序列化:空串不下发、非空下发 category(
|
||||
assert.equal(toJdProductListParams(filtered, 1, 20).category, '服饰内衣', '去空白透传(等值过滤)')
|
||||
assert.equal(jdProductFilterActive(filtered), true, '选中类目算激活筛选')
|
||||
})
|
||||
|
||||
/** 分类状态筛选(2026-11-15 客户口径「查询已分类的跟未分类,分类好的可以不显示」):
|
||||
* 全部不下发、已分类下发 grouped、未分类下发 ungrouped(与店铺分类弹窗同一后端谓词)。 */
|
||||
test('分类状态筛选参数序列化:全部不下发、已分类 grouped、未分类 ungrouped', async () => {
|
||||
const { createJdProductFilterState, toJdProductListParams, jdProductFilterActive } =
|
||||
await import('../src/pages/jd/jd-product-filter.ts')
|
||||
const empty = createJdProductFilterState()
|
||||
assert.equal('grouped' in toJdProductListParams(empty, 1, 20), false, '全部不下发 grouped')
|
||||
assert.equal('ungrouped' in toJdProductListParams(empty, 1, 20), false, '全部不下发 ungrouped')
|
||||
|
||||
const grouped = { ...empty, groupScope: 'grouped' as const }
|
||||
assert.equal(toJdProductListParams(grouped, 1, 20).grouped, true, '已分类档下发 grouped=true')
|
||||
assert.equal('ungrouped' in toJdProductListParams(grouped, 1, 20), false, '已分类档不下发 ungrouped')
|
||||
assert.equal(jdProductFilterActive(grouped), true, '选中已分类算激活筛选')
|
||||
|
||||
const ungrouped = { ...empty, groupScope: 'ungrouped' as const }
|
||||
assert.equal(toJdProductListParams(ungrouped, 1, 20).ungrouped, true, '未分类档下发 ungrouped=true')
|
||||
assert.equal('grouped' in toJdProductListParams(ungrouped, 1, 20), false, '未分类档不下发 grouped')
|
||||
assert.equal(jdProductFilterActive(ungrouped), true, '选中未分类算激活筛选')
|
||||
})
|
||||
|
||||
@@ -278,10 +278,10 @@ describe('京东数据库页(v1.4 Phase 5)', () => {
|
||||
const wrapper = await mountWith({ items: [], total: 0, page: 1, pageSize: 20 })
|
||||
expect(jdApi.fetchJdProductCategories).toHaveBeenCalledWith(1)
|
||||
|
||||
// 第 1 个 select = 分组(既有契约不动),类目下拉紧随其后
|
||||
// 第 1 个 select = 分组(既有契约不动),第 2 个 = 分类状态(2026-11-15 增),类目下拉第 3
|
||||
const selects = wrapper.findAll('.jd-filter-row select')
|
||||
expect(selects).toHaveLength(2)
|
||||
const categorySelect = selects[1]
|
||||
expect(selects).toHaveLength(3)
|
||||
const categorySelect = selects[2]
|
||||
const optionTexts = categorySelect.findAll('option').map((o) => o.text())
|
||||
expect(optionTexts[0]).toBe('全部类目')
|
||||
expect(optionTexts).toContain('服饰内衣(120)')
|
||||
@@ -293,6 +293,24 @@ describe('京东数据库页(v1.4 Phase 5)', () => {
|
||||
expect(jdApi.fetchJdProductList.mock.calls.at(-1)![0]).toMatchObject({ category: '运动户外', page: 1 })
|
||||
})
|
||||
|
||||
it('分类状态下拉:全部/已分类/未分类三档,选中即查回第一页并下发对应参数', async () => {
|
||||
const wrapper = await mountWith({ items: [], total: 0, page: 1, pageSize: 20 })
|
||||
const selects = wrapper.findAll('.jd-filter-row select')
|
||||
const scopeSelect = selects[1]
|
||||
const optionTexts = scopeSelect.findAll('option').map((o) => o.text())
|
||||
expect(optionTexts).toEqual(['全部', '已分类', '未分类'])
|
||||
|
||||
// 选「已分类」= 只看 group_id 非空的行(分类好的行想单独看时用这一档)
|
||||
await scopeSelect.setValue('grouped')
|
||||
await flushPromises()
|
||||
expect(jdApi.fetchJdProductList.mock.calls.at(-1)![0]).toMatchObject({ groupScope: 'grouped', page: 1 })
|
||||
|
||||
// 选「未分类」= 只看 group_id 为空的行(分类好的不显示)
|
||||
await scopeSelect.setValue('ungrouped')
|
||||
await flushPromises()
|
||||
expect(jdApi.fetchJdProductList.mock.calls.at(-1)![0]).toMatchObject({ groupScope: 'ungrouped', page: 1 })
|
||||
})
|
||||
|
||||
it('重置把筛选面回空并回第一页重取', async () => {
|
||||
const wrapper = await mountWith({ items: [], total: 0, page: 1, pageSize: 20 })
|
||||
const textInputs = wrapper.findAll('.form-group input[type="text"]')
|
||||
|
||||
Reference in New Issue
Block a user