feat(jd): 整合自定义分类并保护商品数据

This commit is contained in:
2026-11-16 16:12:04 +08:00
parent 79eb7a7f16
commit 8c81546aa7
23 changed files with 708 additions and 1643 deletions
+2 -2
View File
@@ -442,7 +442,7 @@ onUnmounted(() => {
</div>
<div class="category-block">
<span class="category-label">店铺分类(管理员维护,只读)</span>
<span class="category-label">自定义分类</span>
<p v-if="groupList.length" class="group-chips">
<span v-for="group in groupList" :key="group.id" class="group-chip"
:title="`${group.name}:${group.productCount} 个商品`">
@@ -450,7 +450,7 @@ onUnmounted(() => {
</span>
</p>
<p v-else class="category-hint">
后台还没建店铺分类;管理员在「京东数据库 → 店铺分类」里建的会显示在这里。
后台还没建自定义分类;管理员可在「京东数据库」的类目面板中新建自定义分类,建好后会显示在这里。
</p>
</div>
+2 -2
View File
@@ -69,8 +69,8 @@ test('endpoints 注册店铺分类 groups 只读端点,页面加载并只读
)
assert.ok(page.includes('fetchJdCollectGroups'),
'JdCollectTab.vue 必须调 fetchJdCollectGroups(普通账号在这里看到管理员建的分类)')
assert.ok(page.includes('店铺分类(管理员维护,只读)'),
'JdCollectTab.vue 必须有「店铺分类」只读展示块(口径点名「管理员维护,只读」)')
assert.ok(page.includes('自定义分类</span>'),
'JdCollectTab.vue 必须以「自定义分类」展示分类块')
})
test('建单请求体与推送载荷都带 categoryPaths', () => {
@@ -332,9 +332,9 @@ describe('获取店铺数据:一键采集 + 任务面板', () => {
const w = await mountPage()
expect(api.fetchJdCollectGroups).toHaveBeenCalledTimes(1)
const block = w.findAll('.category-block').find((el) => el.text().includes('店铺分类'))
expect(block, '必须有「店铺分类」展示块').toBeTruthy()
expect(block!.text()).toContain('店铺分类(管理员维护,只读)')
const block = w.findAll('.category-block').find((el) => el.text().includes('自定义分类'))
expect(block, '必须有「自定义分类」展示块').toBeTruthy()
expect(block!.text()).toContain('自定义分类')
const chips = block!.findAll('.group-chip')
expect(chips.length).toBe(2)
expect(chips[0].text()).toContain('ASSS(20)')
@@ -345,10 +345,11 @@ describe('获取店铺数据:一键采集 + 任务面板', () => {
it('后台还没建分类:只读块落空态提示,采集主路照常', async () => {
const w = await mountPage()
const block = w.findAll('.category-block').find((el) => el.text().includes('店铺分类'))
expect(block, '空态也要有「店铺分类」块(不能整块消失让用户以为没这功能)').toBeTruthy()
expect(block!.text()).toContain('后台还没建店铺分类')
expect(block!.text()).toContain('管理员在「京东数据库 → 店铺分类」里建的会显示在这里')
const block = w.findAll('.category-block').find((el) => el.text().includes('自定义分类'))
expect(block, '空态也要有「自定义分类」块(不能整块消失让用户以为没这功能)').toBeTruthy()
expect(block!.text()).toContain('后台还没建自定义分类')
expect(block!.text()).toContain('管理员可在「京东数据库」的类目面板中新建自定义分类')
expect(block!.text()).not.toContain('京东数据库 → 店铺分类')
expect(block!.find('.group-chip').exists()).toBe(false)
// 拉取失败只 warning、不影响建单主路(catch 口径见 catch-silence-ratchet 319)
expect(w.find('.collect-btn').exists()).toBe(true)
@@ -18,7 +18,7 @@ import { resolve, dirname } from 'node:path'
*/
const repoRoot = resolve(dirname(fileURLToPath(import.meta.url)), '..')
const read = (rel: string) => readFileSync(resolve(repoRoot, rel), 'utf-8')
const read = (rel: string) => readFileSync(resolve(repoRoot, rel), 'utf-8').replace(/\r\n/g, '\n')
interface TabSpec {
name: string
@@ -25,7 +25,7 @@ const PAGE = join(
dirname(fileURLToPath(import.meta.url)),
'../src/pages/brand/components/BrandPriceTrackTab.vue',
)
const source = readFileSync(PAGE, 'utf8')
const source = readFileSync(PAGE, 'utf8').replace(/\r\n/g, '\n')
test('状态目录:三项、顺序稳定、取值与客户端目录同名', () => {
assert.deepEqual(