feat(admin): 京东分类管理并入京东数据库页「分类管理」对话框+删「清除勾选」按钮(V208)

This commit is contained in:
2026-11-17 09:32:24 +08:00
parent 848fef3b03
commit db71803430
16 changed files with 857 additions and 753 deletions
@@ -17,8 +17,10 @@ const KEYWORD_USAGE_MIGRATION = join(process.cwd(), '..', 'backend-java', 'src',
'V175__move_gating_and_add_keyword_usage_menu.sql')
const JD_DATABASE_MIGRATION = join(process.cwd(), '..', 'backend-java', 'src', 'main', 'resources', 'db',
'V196__jd_database_menu.sql')
const JD_CATEGORY_MANAGE_MIGRATION = join(process.cwd(), '..', 'backend-java', 'src', 'main', 'resources', 'db',
'V204__jd_category_manage_menu.sql')
/** V204 插入的「京东分类管理」菜单行已随 2026-11-17 用户口径「京东分类管理并到京东数据库
* 分类编辑里」由 V208 删除(页面并入 JdDatabasePage 工具栏「分类管理」对话框)。 */
const JD_CATEGORY_MANAGE_DROP_MIGRATION = join(process.cwd(), '..', 'backend-java', 'src', 'main', 'resources', 'db',
'V208__drop_jd_category_manage_menu.sql')
interface MigrationMenu {
name: string
@@ -124,23 +126,15 @@ test('V196 新增的京东数据库菜单 key 必须在路由注册表登记', (
assert.ok(!sql.includes('user_column_permission'), 'V196 不得预插授权行(默认仅超管可见)')
})
test('V204 新增的京东分类管理菜单 key 必须在路由注册表登记(2026-11-17 弹窗下线、CRUD 挪子菜单页)', () => {
const sql = readFileSync(JD_CATEGORY_MANAGE_MIGRATION, 'utf8')
const menus = menusInsertedBy(sql)
const insertCount = (sql.match(/INSERT INTO `columns`/g) || []).length
assert.ok(menus.length > 0, 'V204 应当插入后台菜单,一条都没解析出来说明正则失效')
assert.equal(menus.length, insertCount, `解析到 ${menus.length} 条,但迁移有 ${insertCount} 条 INSERT INTO columns`)
test('V208 删掉 V204 的京东分类管理菜单行,且注册表不再认这个 key(2026-11-17 分类管理并入京东数据库页)', () => {
// V204 本体已应用不可回改(铁律 10,文件原样保留作历史取证);下线动作由 V208 出 DELETE,
// 页面并入京东数据库页工具栏「分类管理」对话框。
const sql = readFileSync(JD_CATEGORY_MANAGE_DROP_MIGRATION, 'utf8')
assert.ok(sql.includes("DELETE FROM `columns` WHERE `column_key` = 'admin_jd_category_manage'"),
'V208 必须 DELETE admin_jd_category_manage 菜单行(授权行随外键 CASCADE)')
const menu = menus.find((item) => item.columnKey === 'admin_jd_category_manage')
assert.ok(menu, 'V204 必须插入 admin_jd_category_manage 菜单')
const page = adminPages.find((item) => item.menuKey === 'admin_jd_category_manage')
assert.ok(page, 'routes.ts 必须有 admin_jd_category_manage 页面,否则菜单点进去 404')
assert.equal(page.path, menu.routePath, '库里的 route_path 应与注册表路径一致')
assert.equal(page.title, menu.name, '页面标题应与菜单名一致')
assert.equal(page.companyScoped, false, '分类按数据权限分组隔离(V203),不按公司 tab 取数')
// 每公司一套树,挂数据管理组、排序 69(V196 京东数据库占 68)。
assert.ok(sql.includes("grp.`column_key` = 'admin_group_data'"), 'V204 必须把京东分类管理挂到数据管理组')
assert.ok(/'京东分类管理', 'admin_jd_category_manage', 'admin', 'jd-center\/categories', 69/.test(sql), '京东分类管理排序应为 69')
assert.ok(!sql.includes('user_column_permission'), 'V204 不得预插授权行(默认仅超管可见)')
const registered = adminPages.find((item) => item.menuKey === 'admin_jd_category_manage')
assert.ok(!registered, 'routes.ts 不得再登记 admin_jd_category_manage(页面已并入京东数据库页,残留=404 入口)')
const jdRouteGone = !adminPages.some((item) => item.path === 'jd-center/categories')
assert.ok(jdRouteGone, 'jd-center/categories 路由必须下线')
})
@@ -32,14 +32,13 @@ test('routes 注册表出现京东数据库页面且退出公司 tab(2026-11-1
assert.equal(page.companyScoped, false, '京东数据库全平台公共,不画公司 tab(AC-6 已被 11-15/11-16 口径推翻)')
})
/** 2026-11-17 用户口径「店铺分类弹窗删了,加个京东分类管理的子菜单维护 CRUD」(V204):
* 分类建/改名/删除独立成页,与京东数据库页同在京东平台侧(platform-scope 用例另钉)。 */
test('routes 注册表出现京东分类管理页面(V204 子菜单),与京东数据库并排退出公司 tab', () => {
const page = adminPages.find((item) => item.menuKey === 'admin_jd_category_manage')
assert.ok(page, 'routes.ts 缺 menuKey=admin_jd_category_manage 的注册行')
assert.equal(page.path, 'jd-center/categories', 'route_path 必须与 V204 菜单一侧一致')
assert.equal(page.title, '京东分类管理', '菜单标题以「京东分类管理」为准')
assert.equal(page.companyScoped, false, '分类按数据权限分组隔离(V203),不画公司 tab')
/** 2026-11-17 用户口径「京东分类管理并到京东数据库分类编辑里」:V204 独立子菜单页下线
* (分类建/改名/删收进京东数据库页工具栏「分类管理」对话框),路由注册表不得再登记该 key。 */
test('routes 注册表不再登记京东分类管理独立页(V204 页并入京东数据库页,残留=404 入口)', () => {
assert.ok(!adminPages.some((item) => item.menuKey === 'admin_jd_category_manage'),
'admin_jd_category_manage 注册行必须已删(页面并入京东数据库页)')
assert.ok(!adminPages.some((item) => item.path === 'jd-center/categories'),
'jd-center/categories 路由必须下线')
})
/** 详情面的 SKU 矩阵解析(V198):后端下发 camelCase,snake 容错;坏行不炸整块。 */
@@ -0,0 +1,214 @@
/**
* 京东分类管理对话框(JdCategoryManageDialog)的挂载契约。
*
* 2026-11-17 用户口径「京东分类管理并到京东数据库分类编辑里,做一个搜索和添加 删除
* 编辑 分类名称即可」:V204 独立子菜单页(JdCategoryManagerPage,已删)整体并入本对话框,
* 从京东数据库页工具栏「分类管理」打开。原页面契约逐条承接:当前数据权限分组的
* 分类建/改名/删除;新增名称搜索(本地过滤)。商品归类不在这里(去「批量编辑分类」)。
* 权限口径(V203)不变:editable 才渲染写控件;同组普通号只读可看。
*
* 跑法:`npx vitest run tests/mount/jd-category-manage-dialog.mount.test.ts`
*/
import { beforeEach, describe, expect, it, vi } from 'vitest'
import { flushPromises, mount, type VueWrapper } from '@vue/test-utils'
import { createPinia, setActivePinia, type Pinia } from 'pinia'
import JdCategoryManageDialog from '@/pages/jd/JdCategoryManageDialog.vue'
const jdApi = vi.hoisted(() => ({
fetchJdProductGroups: vi.fn(),
createJdProductGroup: vi.fn(),
updateJdProductGroup: vi.fn(),
deleteJdProductGroup: vi.fn(),
}))
const confirmMock = vi.hoisted(() => vi.fn())
vi.mock('@/pages/jd/jd-product-api.ts', () => jdApi)
vi.mock('@/components/admin-confirm', () => ({ openAdminConfirm: confirmMock }))
/** 分组 id 常量:默认作用域就这一个可见且可写的组(组长档形状)。 */
const GROUP_A = 11
function group(id: number, name: string, productCount = 0, sortOrder = 0) {
return { id, name, ownerGroupId: GROUP_A, sortOrder, productCount }
}
let pinia: Pinia
beforeEach(() => {
vi.clearAllMocks()
pinia = createPinia()
setActivePinia(pinia)
jdApi.fetchJdProductGroups.mockResolvedValue([])
confirmMock.mockResolvedValue(true)
})
async function mountDialog(editable = true): Promise<VueWrapper<Element>> {
const wrapper = mount(JdCategoryManageDialog, {
global: { plugins: [pinia] },
props: {
visible: true,
ownerGroupId: GROUP_A,
ownerGroupName: '甲组',
editable,
},
})
await flushPromises()
await flushPromises()
return wrapper
}
describe('京东分类管理对话框(V204 独立页 2026-11-17 并入京东数据库页)', () => {
it('打开即按当前分组取分类(ownerGroupId 必带);标题带当前分组名', async () => {
jdApi.fetchJdProductGroups.mockResolvedValue([group(7, '裙装', 3)])
const wrapper = await mountDialog()
expect(jdApi.fetchJdProductGroups).toHaveBeenCalledWith(GROUP_A)
expect(wrapper.get('.manage-modal').text()).toContain('分类管理')
expect(wrapper.get('.manage-modal').text()).toContain('甲组', '标题/上下文带当前分组名')
expect(wrapper.findAll('.option-row')).toHaveLength(1)
wrapper.unmount()
})
it('新建分类:落当前分组归属(ownerGroupId 必带),成功后清输入重取并通知父页刷新', async () => {
jdApi.fetchJdProductGroups.mockResolvedValue([group(7, '裙装', 3)])
const wrapper = await mountDialog()
await wrapper.get('.group-create input').setValue('上新区')
await wrapper.findAll('button').find((b) => b.text() === '新建')!.trigger('click')
await flushPromises()
expect(jdApi.createJdProductGroup).toHaveBeenCalledWith({ name: '上新区', sortOrder: 0, ownerGroupId: GROUP_A })
expect((wrapper.get('.group-create input').element as HTMLInputElement).value).toBe('')
expect(jdApi.fetchJdProductGroups).toHaveBeenCalledTimes(2, '成功后重取分类列表')
expect(wrapper.emitted('changed'), '写成功必须 emit changed 让父页刷筛选下拉').toBeTruthy()
wrapper.unmount()
})
it('搜索:按名称包含本地过滤(不发额外请求),命中后新建会清关键字', async () => {
jdApi.fetchJdProductGroups.mockResolvedValue([group(7, '裙装', 3), group(8, '裤装', 1), group(9, '配饰', 0)])
const wrapper = await mountDialog()
const callsBefore = jdApi.fetchJdProductGroups.mock.calls.length
await wrapper.get('.search-input').setValue('裙')
await flushPromises()
expect(wrapper.findAll('.option-row')).toHaveLength(1, '「裙」只命中裙装')
expect(wrapper.findAll('.option-row')[0].text()).toContain('裙装')
expect(jdApi.fetchJdProductGroups.mock.calls.length).toBe(callsBefore, '搜索是本地过滤,不另发请求')
expect(wrapper.text()).not.toContain('裤装', '不匹配项不出现')
await wrapper.get('.group-create input').setValue('上新区')
await wrapper.findAll('button').find((b) => b.text() === '新建')!.trigger('click')
await flushPromises()
expect((wrapper.get('.search-input').element as HTMLInputElement).value).toBe('',
'新建成功清关键字(新分类不被旧搜索藏住)')
wrapper.unmount()
})
it('搜索无命中给显式空态文案(不是空列表静默)', async () => {
jdApi.fetchJdProductGroups.mockResolvedValue([group(7, '裙装', 3)])
const wrapper = await mountDialog()
await wrapper.get('.search-input').setValue('不存在的分类')
expect(wrapper.get('.manage-empty').text()).toBe('没有匹配的分类')
wrapper.unmount()
})
it('改名:行内编辑后按 (id, {name, sortOrder}) 提交并 emit changed', async () => {
jdApi.fetchJdProductGroups.mockResolvedValue([group(7, '裙装', 3)])
const wrapper = await mountDialog()
await wrapper.findAll('button').find((b) => b.text() === '改名')!.trigger('click')
await wrapper.get('.rename-input').setValue('长裙')
await wrapper.findAll('button').find((b) => b.text() === '保存')!.trigger('click')
await flushPromises()
expect(jdApi.updateJdProductGroup).toHaveBeenCalledWith(7, { name: '长裙', sortOrder: 0 })
expect(wrapper.emitted('changed')).toBeTruthy()
wrapper.unmount()
})
it('删除:二次确认文案点名商品数(删除不删商品,只解挂归属),确认后调端点重取', async () => {
jdApi.fetchJdProductGroups.mockResolvedValue([group(7, '裙装', 3)])
const wrapper = await mountDialog()
await wrapper.findAll('button').find((b) => b.text() === '删除')!.trigger('click')
await flushPromises()
expect(confirmMock).toHaveBeenCalledTimes(1)
const options = confirmMock.mock.calls[0][0]
expect(options.title).toBe('删除分类')
expect(options.message).toContain('确定删除分类「裙装」吗')
expect(options.message).toContain('3 个商品回到未分类', '文案点名该分类下的商品数')
expect(options.danger).toBe(true)
expect(jdApi.deleteJdProductGroup).toHaveBeenCalledWith(7)
expect(jdApi.fetchJdProductGroups).toHaveBeenCalledTimes(2, '删除成功后重取列表')
expect(wrapper.emitted('changed')).toBeTruthy()
wrapper.unmount()
})
it('删除确认点取消就不发请求(防误删第一道闸)', async () => {
confirmMock.mockResolvedValue(false)
jdApi.fetchJdProductGroups.mockResolvedValue([group(7, '裙装', 3)])
const wrapper = await mountDialog()
await wrapper.findAll('button').find((b) => b.text() === '删除')!.trigger('click')
await flushPromises()
expect(confirmMock).toHaveBeenCalledTimes(1)
expect(jdApi.deleteJdProductGroup).not.toHaveBeenCalled()
wrapper.unmount()
})
it('只读档(editable=false):无新建行、无搜索仍可用、无改名/删除按钮', async () => {
const wrapper = await mountDialog(false)
expect(wrapper.find('.group-create').exists()).toBe(false, '只读账号不渲染新建行')
expect(wrapper.findAll('button').some((b) => b.text() === '改名')).toBe(false)
expect(wrapper.findAll('button').some((b) => b.text() === '删除')).toBe(false)
expect(wrapper.get('.search-input').exists()).toBe(true, '搜索是读面,只读档保留')
wrapper.unmount()
})
it('不属于任何数据权限分组(ownerGroupId<=0):不发取数请求,空态直说', async () => {
const wrapper = mount(JdCategoryManageDialog, {
global: { plugins: [pinia] },
props: { visible: true, ownerGroupId: 0, ownerGroupName: '', editable: false },
})
await flushPromises()
await flushPromises()
expect(jdApi.fetchJdProductGroups).not.toHaveBeenCalled()
expect(wrapper.get('.manage-empty').text()).toBe('你还不属于任何数据权限分组')
expect(wrapper.find('.group-create').exists()).toBe(false)
wrapper.unmount()
})
it('本组暂无分类:可写档文案引导新建,只读档直说', async () => {
const writable = await mountDialog(true)
expect(writable.get('.manage-empty').text()).toBe('本组暂无分类,先新建一个')
writable.unmount()
const readonly = await mountDialog(false)
expect(readonly.get('.manage-empty').text()).toBe('本组暂无分类')
readonly.unmount()
})
it('加载失败:红条可见且重试真能重跑(取数页硬规矩)', async () => {
jdApi.fetchJdProductGroups.mockRejectedValueOnce(new Error('上游 502'))
const wrapper = mount(JdCategoryManageDialog, {
global: { plugins: [pinia] },
props: { visible: true, ownerGroupId: GROUP_A, ownerGroupName: '甲组', editable: true },
})
await flushPromises()
await flushPromises()
const bar = wrapper.find('.load-failure-bar')
expect(bar.exists()).toBe(true, '失败态必须可见(不是一闪而过的 toast)')
expect(bar.text()).toContain('分类列表加载失败')
expect(bar.text()).toContain('上游 502', '后端/网络原因要进文案')
jdApi.fetchJdProductGroups.mockResolvedValue([group(7, '裙装', 3)])
await bar.find('button').trigger('click')
await flushPromises()
await flushPromises()
expect(wrapper.find('.load-failure-bar').exists()).toBe(false, '重试成功后红条消失')
expect(wrapper.text()).toContain('裙装')
wrapper.unmount()
})
it('页面职责边界(反向钉):归类不在本对话框——不出现批量归类/删除勾选入口', async () => {
jdApi.fetchJdProductGroups.mockResolvedValue([group(7, '裙装', 3)])
const wrapper = await mountDialog()
expect(wrapper.findAll('button').some((b) => b.text() === '批量编辑分类')).toBe(false, '归类入口在京东数据库页')
expect(wrapper.text()).toContain('批量编辑分类', '但提示要指路(关掉本框去勾选商品归类)')
expect(jdApi.deleteJdProductGroup).not.toHaveBeenCalled()
wrapper.unmount()
})
})
@@ -1,172 +0,0 @@
/**
* 京东分类管理页(V204,2026-11-17 用户口径「店铺分类弹窗删了,加个京东分类管理的子菜单
* 维护 CRUD」)的挂载契约:当前数据权限分组的分类建/改名/删除独立成页;分组作用域与
* 京东数据库页同一套(京东侧分组,非亚马逊——platform-scope JD_MENU_KEYS);
* 商品归类不在这里(去京东数据库页「批量编辑分类」)。
*
* 跑法:`npx vitest run tests/mount/jd-category-manager-page.mount.test.ts`
*/
import { beforeEach, describe, expect, it, vi } from 'vitest'
import { flushPromises, mount } from '@vue/test-utils'
import { createPinia, setActivePinia, type Pinia } from 'pinia'
import JdCategoryManagerPage from '@/pages/jd/JdCategoryManagerPage.vue'
const jdApi = vi.hoisted(() => ({
fetchJdCategoryScope: vi.fn(),
fetchJdProductGroups: vi.fn(),
createJdProductGroup: vi.fn(),
updateJdProductGroup: vi.fn(),
deleteJdProductGroup: vi.fn(),
}))
const confirmMock = vi.hoisted(() => vi.fn())
vi.mock('@/pages/jd/jd-product-api.ts', () => jdApi)
vi.mock('@/components/admin-confirm', () => ({ openAdminConfirm: confirmMock }))
/** 分组 id 常量:默认作用域就这一个可见且可写的组(组长档形状)。 */
const GROUP_A = 11
function singleGroupScope(editable = true) {
return {
platformSuperAdmin: false,
defaultGroupId: GROUP_A,
groups: [{ id: GROUP_A, name: '甲组', label: '甲组', editable }],
}
}
function group(id: number, name: string, productCount = 0, sortOrder = 0) {
return { id, name, ownerGroupId: GROUP_A, sortOrder, productCount }
}
let pinia: Pinia
beforeEach(() => {
vi.clearAllMocks()
pinia = createPinia()
setActivePinia(pinia)
jdApi.fetchJdCategoryScope.mockResolvedValue(singleGroupScope())
jdApi.fetchJdProductGroups.mockResolvedValue([])
confirmMock.mockResolvedValue(true)
})
async function mountPage(): Promise<ReturnType<typeof mount>> {
const wrapper = mount(JdCategoryManagerPage, { global: { plugins: [pinia] } })
await flushPromises()
await flushPromises()
return wrapper
}
describe('京东分类管理(V204 子菜单页)', () => {
it('首屏按默认组取分类;多组可见出「分组」下拉,切组重取', async () => {
jdApi.fetchJdCategoryScope.mockResolvedValue({
platformSuperAdmin: true,
defaultGroupId: GROUP_A,
groups: [
{ id: GROUP_A, name: 'A组', label: '甲公司 / A组', editable: true },
{ id: 12, name: 'B组', label: '甲公司 / B组', editable: false },
],
})
jdApi.fetchJdProductGroups.mockResolvedValue([group(7, '裙装', 3)])
const wrapper = await mountPage()
expect(jdApi.fetchJdProductGroups).toHaveBeenCalledWith(GROUP_A)
const picker = wrapper.get('[aria-label="当前分组"]')
expect((picker.element as HTMLSelectElement).closest('.form-group')?.querySelector('label')?.textContent).toBe('分组',
'分组是带标签的表单控件(与京东数据库页筛选行同口径)')
expect(picker.findAll('option').map((o) => o.text())).toEqual(['甲公司 / A组', '甲公司 / B组'])
await picker.setValue('12')
await flushPromises()
// 切组后分类按新组重取(跨组不可见,V203)。
expect(jdApi.fetchJdProductGroups).toHaveBeenLastCalledWith(12)
wrapper.unmount()
})
it('新建分类:落当前分组归属(ownerGroupId 必带),成功后清输入并重取', async () => {
jdApi.fetchJdProductGroups.mockResolvedValue([group(7, '裙装', 3)])
const wrapper = await mountPage()
await wrapper.get('.group-create input').setValue('上新区')
await wrapper.findAll('button').find((b) => b.text() === '新建')!.trigger('click')
await flushPromises()
expect(jdApi.createJdProductGroup).toHaveBeenCalledWith({ name: '上新区', sortOrder: 0, ownerGroupId: GROUP_A })
expect((wrapper.get('.group-create input').element as HTMLInputElement).value).toBe('')
expect(jdApi.fetchJdProductGroups).toHaveBeenCalledTimes(2, '成功后重取分类列表')
wrapper.unmount()
})
it('改名:行内编辑后按 (id, {name, sortOrder}) 提交', async () => {
jdApi.fetchJdProductGroups.mockResolvedValue([group(7, '裙装', 3)])
const wrapper = await mountPage()
await wrapper.findAll('button').find((b) => b.text() === '改名')!.trigger('click')
await wrapper.get('.rename-input').setValue('长裙')
await wrapper.findAll('button').find((b) => b.text() === '保存')!.trigger('click')
await flushPromises()
expect(jdApi.updateJdProductGroup).toHaveBeenCalledWith(7, { name: '长裙', sortOrder: 0 })
wrapper.unmount()
})
it('删除:二次确认文案点名商品数(删除不删商品,只解挂归属),确认后调端点重取', async () => {
jdApi.fetchJdProductGroups.mockResolvedValue([group(7, '裙装', 3)])
const wrapper = await mountPage()
await wrapper.findAll('button').find((b) => b.text() === '删除')!.trigger('click')
await flushPromises()
expect(confirmMock).toHaveBeenCalledTimes(1)
const options = confirmMock.mock.calls[0][0]
expect(options.title).toBe('删除分类')
expect(options.message).toContain('确定删除分类「裙装」吗')
expect(options.message).toContain('3 个商品回到未分类', '文案点名该分类下的商品数')
expect(options.danger).toBe(true)
expect(jdApi.deleteJdProductGroup).toHaveBeenCalledWith(7)
wrapper.unmount()
})
it('只读档(editable=false):无新建行、无改名/删除按钮,空表文案不带「先新建」', async () => {
jdApi.fetchJdCategoryScope.mockResolvedValue(singleGroupScope(false))
jdApi.fetchJdProductGroups.mockResolvedValue([])
const wrapper = await mountPage()
expect(wrapper.find('.group-create').exists()).toBe(false, '只读账号不渲染新建行')
expect(wrapper.findAll('button').some((b) => b.text() === '改名')).toBe(false)
expect(wrapper.findAll('button').some((b) => b.text() === '删除')).toBe(false)
expect(wrapper.find('thead').text()).not.toContain('操作', '只读档连操作列表头都不渲染')
expect(wrapper.find('.empty-tip').text()).toBe('本组暂无分类')
wrapper.unmount()
})
it('不属于任何数据权限分组:锁定芯片直说空态,不出下拉与新建行', async () => {
jdApi.fetchJdCategoryScope.mockResolvedValue({ platformSuperAdmin: false, defaultGroupId: null, groups: [] })
const wrapper = await mountPage()
expect(wrapper.find('[aria-label="当前分组"]').exists()).toBe(false)
expect(wrapper.get('.group-locked').text()).toBe('你还不属于任何数据权限分组')
expect(wrapper.find('.group-create').exists()).toBe(false)
expect(wrapper.find('.empty-tip').text()).toBe('你还不属于任何数据权限分组')
wrapper.unmount()
})
it('加载失败:红条可见且重试真能重跑(取数页硬规矩),切组后重取成功即清', async () => {
jdApi.fetchJdProductGroups.mockRejectedValueOnce(new Error('上游 502'))
const wrapper = mount(JdCategoryManagerPage, { global: { plugins: [pinia] } })
await flushPromises()
await flushPromises()
const bar = wrapper.find('.load-failure-bar')
expect(bar.exists()).toBe(true, '失败态必须可见(不是一闪而过的 toast)')
expect(bar.text()).toContain('分类列表加载失败')
expect(bar.text()).toContain('上游 502', '后端/网络原因要进文案')
jdApi.fetchJdProductGroups.mockResolvedValue([group(7, '裙装', 3)])
await bar.find('button').trigger('click')
await flushPromises()
await flushPromises()
expect(wrapper.find('.load-failure-bar').exists()).toBe(false, '重试成功后红条消失')
expect(wrapper.text()).toContain('裙装')
wrapper.unmount()
})
it('页面职责边界(反向钉):归类不在本页——页面不出现批量归类/商品列表入口', async () => {
jdApi.fetchJdProductGroups.mockResolvedValue([group(7, '裙装', 3)])
const wrapper = await mountPage()
expect(wrapper.findAll('button').some((b) => b.text() === '批量编辑分类')).toBe(false, '归类入口在京东数据库页')
expect(wrapper.text()).toContain('京东数据库', '页内提示指路「京东数据库」页')
expect(jdApi.deleteJdProductGroup).not.toHaveBeenCalled()
wrapper.unmount()
})
})
@@ -4,8 +4,11 @@
* 形态:panel-box + 筛选行(商品编码/标题关键字/类目/分组/同步起止 date 对)+
* 查询/重置 + 自绘明细表(点行开详情抽屉)+ OldPagination;
* 分组下拉 2026-11-16 用户口径「做成分组」上移进筛选行=带标签的表单控件(不再是工具栏裸下拉);
* 店铺分类弹窗 2026-11-17 用户口径下线:工具栏改「批量编辑分类」(勾选跨页累计+归入/移出),
* 分类建/改名/删除挪「京东分类管理」子菜单页(V204,另见 jd-category-manager-page.mount.test.ts)。
* 店铺分类弹窗 2026-11-17 用户口径下线:工具栏改「批量编辑分类」(勾选跨页累计+归入/移出);
* 同日第二刀「京东分类管理并到京东数据库分类编辑里」:V204 独立子菜单页下线
* (jd-category-manager-page.mount.test.ts 随之删除),建/改名/删分类+搜索收进工具栏
* 「分类管理」对话框(另见 jd-category-manage-dialog.mount.test.ts);
* 「清除勾选」按钮同日用户口径删除(勾选只在批量操作成功后自动清)。
* 公司维度 2026-11-16 整页摘除(「删除掉公司 tab,参考品牌数据库」):页面不消费公司 tab
* store、列表/类目下拉不带 company_id(反向钉在 company-tab-wiring「公司维度不得回流」)。
* 商品状态筛选/列与导出按钮已随 2026-11-15 客户口径从前端下线(后端端点保留);
@@ -114,7 +117,7 @@ async function mountWith(payload: unknown): Promise<VueWrapper<Element>> {
* 勾选跨页累计记忆(翻页/重取不清)→ 对话框选目标分类归入或移出 → 按 (ids, groupId,
* ownerGroupId) 提交;成功后清勾选并重取。旧弹窗的「勾选翻页即清」口径同日废止。 */
describe('批量编辑分类(店铺分类弹窗 2026-11-17 下线后的替代入口)', () => {
it('勾选跨页记忆:第 1 页勾 1 行翻到第 2 页再勾 1 行,删除按累计 2 行提交,清除勾选可显式清零', async () => {
it('勾选跨页记忆:第 1 页勾 1 行翻到第 2 页再勾 1 行,删除按累计 2 行提交;「清除勾选」按钮已删(2026-11-17 用户口径)', async () => {
jdApi.fetchJdProductList
.mockImplementationOnce(() => Promise.resolve({ items: [item(1)], total: 40, page: 1, pageSize: 20 }))
.mockImplementation(() => Promise.resolve({ items: [item(2)], total: 40, page: 2, pageSize: 20 }))
@@ -122,7 +125,6 @@ describe('批量编辑分类(店铺分类弹窗 2026-11-17 下线后的替代
await flushPromises()
await flushPromises()
const deleteBtn = () => wrapper.get('.jd-delete-btn')
const clearBtn = () => wrapper.findAll('button').find((b) => b.text() === '清除勾选')
await wrapper.findAll('tbody input[type="checkbox"]')[0].setValue(true)
expect(deleteBtn().text()).toContain('删除勾选(1)')
@@ -133,7 +135,8 @@ describe('批量编辑分类(店铺分类弹窗 2026-11-17 下线后的替代
expect(deleteBtn().text()).toContain('删除勾选(1)', '翻页后第 1 页的勾选仍在累计集里')
await wrapper.findAll('tbody input[type="checkbox"]')[0].setValue(true)
expect(deleteBtn().text()).toContain('删除勾选(2)', '第 2 页再勾 1 行,累计 2 行')
expect(clearBtn(), '有勾选时「清除勾选」出现').toBeTruthy()
expect(wrapper.findAll('button').some((b) => b.text() === '清除勾选')).toBe(false,
'「清除勾选」按钮 2026-11-17 用户口径删除(显式反悔口没了,勾选只在批量操作成功后自动清)')
// 累计勾选直达删除:跨页的行一起删(确认弹窗点名总数)。
jdApi.deleteJdProducts.mockResolvedValueOnce({ deleted: 2, imagesDeleted: 0, objectsDeleted: 0, objectsKept: 0, objectsSkipped: 0 })
@@ -143,12 +146,7 @@ describe('批量编辑分类(店铺分类弹窗 2026-11-17 下线后的替代
expect(confirmMock.mock.calls.at(-1)![0].message).toContain('确定删除勾选的 2 个商品吗', '确认文案点名累计总数')
// 跨页累计的 id 一起提交。
expect(jdApi.deleteJdProducts).toHaveBeenLastCalledWith([1, 2])
// 显式反悔口:清除勾选后按钮回置灰。
await wrapper.findAll('tbody input[type="checkbox"]')[0].setValue(true)
await clearBtn()!.trigger('click')
expect(deleteBtn().text()).toContain('删除勾选(0)')
expect(wrapper.findAll('button').some((b) => b.text() === '清除勾选')).toBe(false, '勾选 0 时清除按钮消失')
expect(deleteBtn().text()).toContain('删除勾选(0)', '批量删除成功后自动清勾选')
wrapper.unmount()
})
@@ -206,7 +204,7 @@ describe('批量编辑分类(店铺分类弹窗 2026-11-17 下线后的替代
wrapper.unmount()
})
it('本组暂无分类:对话框只留提示不给提交(移出对未分类行是无谓操作),引导去分类管理页', async () => {
it('本组暂无分类:对话框只留提示不给提交(移出对未分类行是无谓操作),引导去工具栏「分类管理」新建', async () => {
jdApi.fetchJdProductGroups.mockResolvedValue([])
const wrapper = await mountWith({ items: [item(1)], total: 1, page: 1, pageSize: 20 })
await wrapper.findAll('tbody input[type="checkbox"]')[0].setValue(true)
@@ -214,7 +212,7 @@ describe('批量编辑分类(店铺分类弹窗 2026-11-17 下线后的替代
await flushPromises()
const modal = wrapper.get('.batch-modal')
expect(modal.text()).toContain('本组暂无分类')
expect(modal.text()).toContain('京东分类管理', '空态把维护入口指向「京东分类管理」')
expect(modal.text()).toContain('分类管理', '空态把维护入口指向工具栏「分类管理」(独立页 2026-11-17 并入本页)')
expect(modal.findAll('button').some((b) => b.text() === '移出分类' && b.attributes('disabled') === undefined)).toBe(false,
'无分类时移出不可提交')
expect(jdApi.batchAssignJdProductGroup).not.toHaveBeenCalled()
@@ -231,6 +229,60 @@ describe('批量编辑分类(店铺分类弹窗 2026-11-17 下线后的替代
})
})
/** 分类管理入口(2026-11-17 用户口径「京东分类管理并到京东数据库分类编辑里」):
* V204 独立子菜单页下线,工具栏「分类管理」打开 JdCategoryManageDialog(搜索+新建+
* 改名+删除);入口对所有人渲染(同组普通号只读可看),写控件由对话框按 editable 分档;
* 对话框 CRUD 成功 emit changed ⇒ 父页刷分类筛选下拉。 */
describe('分类管理入口(V204 独立页并入京东数据库页)', () => {
it('工具栏「分类管理」入口常显(勾选 0 也可用),点开渲染对话框且按当前分组取分类', async () => {
jdApi.fetchJdProductGroups.mockResolvedValue([{ id: 7, name: '裙装', sortOrder: 0, productCount: 3 }])
const wrapper = await mountWith({ items: [item(1)], total: 1, page: 1, pageSize: 20 })
const manageBtn = () => wrapper.findAll('button').find((b) => b.text() === '分类管理')
expect(manageBtn(), '入口常显(不等勾选)').toBeTruthy()
expect(wrapper.find('.manage-modal').exists()).toBe(false, '未点开时不渲染对话框')
const callsBefore = jdApi.fetchJdProductGroups.mock.calls.length
await manageBtn()!.trigger('click')
await flushPromises()
const modal = wrapper.get('.manage-modal')
expect(modal.text()).toContain('分类管理')
expect(modal.text()).toContain('甲组', '标题带当前分组名')
expect(modal.get('.search-input').exists()).toBe(true, '搜索框是本对话框新能力')
expect(modal.text()).toContain('裙装')
expect(jdApi.fetchJdProductGroups.mock.calls.length).toBeGreaterThan(callsBefore,
'对话框打开时按当前分组自取列表')
wrapper.unmount()
})
it('对话框内删分类成功(emit changed)后父页重取分类下拉(筛选选项与商品数徽标同步刷新)', async () => {
// 取数按次序变形:页面首屏=裙装;对话框打开与 changed 后的重取=删后列表(只剩裤装)。
let groupFetchCount = 0
jdApi.fetchJdProductGroups.mockImplementation(() => {
groupFetchCount += 1
return groupFetchCount === 1
? Promise.resolve([{ id: 7, name: '裙装', sortOrder: 0, productCount: 3 }])
: Promise.resolve([{ id: 8, name: '裤装', sortOrder: 1, productCount: 1 }])
})
const wrapper = await mountWith({ items: [item(1)], total: 1, page: 1, pageSize: 20 })
expect(wrapper.get('[aria-label="筛选店铺分类"]').text()).toContain('裙装', '首屏下拉含首取分类')
await wrapper.findAll('button').find((b) => b.text() === '分类管理')!.trigger('click')
await flushPromises()
const modal = wrapper.get('.manage-modal')
confirmMock.mockResolvedValue(true)
jdApi.deleteJdProductGroup.mockResolvedValueOnce(undefined)
await modal.findAll('button').find((b) => b.text() === '删除')!.trigger('click')
await flushPromises()
await flushPromises()
expect(jdApi.deleteJdProductGroup, '删除按钮属于当前列表行').toHaveBeenCalledWith(8)
// changed → 父页 loadGroupOptions:下拉按新列表重取(最后一次调用拿到删后列表)。
const select = wrapper.get('[aria-label="筛选店铺分类"]')
expect(select.text()).toContain('裤装', '下拉刷新出新一轮分类')
expect(select.text()).not.toContain('裙装', '删掉的分类不再出现在筛选下拉')
wrapper.unmount()
})
})
describe('京东数据库页(v1.4 Phase 5)', () => {
it('挂载后按首屏分页参数取列表(pageSize 默认 20、不带公司维度),行数=本页条数', async () => {
const wrapper = await mountWith({ items: [item(1), item(2), item(3)], total: 42, page: 1, pageSize: 20 })
@@ -699,10 +751,10 @@ describe('京东数据库页(v1.4 Phase 5)', () => {
})
/** 写权限分档(2026-11-16 用户口径收窄商品行写;2026-11-17 弹窗下线后更新):
* 商品行写(编辑/删除/勾选批量删)只对平台超管渲染;分类写(批量编辑分类)由 scope 的
* 每组 editable 决定(本组管理员/公司超管/平台超管)——同组普通号在本页只读,
* 只读查看入口在「京东分类管理」子菜单页(V204)。勾选列 2026-11-17 起对本组可写
* 分类管理员开放(服务批量归类),商品行按钮仍只归平台超管。 */
* 商品行写(编辑/删除/勾选批量删)只对平台超管渲染;分类写(批量编辑分类、分类管理)由
* scope 的每组 editable 决定(本组管理员/公司超管/平台超管)——同组普通号在本页只读,
* 分类维护入口=工具栏「分类管理」对话框(V204 独立页 2026-11-17 并入,只读可看)。
* 勾选列 2026-11-17 起对本组可写分类管理员开放(服务批量归类),商品行按钮仍只归平台超管。 */
describe('京东数据库写权限分档(商品行写=平台超管;分类写=本组 editable)', () => {
it('非超管且本组不可写:无勾选列、无操作列、无删除勾选、无批量编辑分类;列表/筛选/详情照常', async () => {
useAdminSessionStore().user = { id: 2, username: 'ops', role: 'admin' }
@@ -717,9 +769,11 @@ describe('京东数据库写权限分档(商品行写=平台超管;分类
expect(wrapper.findAll('tbody input[type="checkbox"]')).toHaveLength(0, '不可写分类的普通号没有勾选列')
expect(wrapper.find('.jd-delete-btn').exists()).toBe(false, '批量删除按钮不渲染')
expect(wrapper.findAll('button').some((b) => b.text() === '批量编辑分类')).toBe(false, '分类写入口不渲染(本组不可写)')
expect(wrapper.findAll('button').some((b) => b.text() === '分类管理')).toBe(true,
'分类管理入口是读面,普通号也能打开看(写控件由对话框按 editable 分档)')
expect(wrapper.find('thead').text()).not.toContain('操作', '操作列(编辑/删除)不渲染')
expect(wrapper.text()).toContain('只读:编辑/删除仅超级管理员可用', '只读提示必须看得见并区分两类写权限')
expect(wrapper.text()).toContain('京东分类管理', '提示把分类维护入口指向「京东分类管理」子菜单页')
expect(wrapper.text()).toContain('分类在本页「分类管理」查看与维护', '提示把分类维护入口指向本页「分类管理」(独立页已并入)')
// 读面不受影响:筛选下拉、列表行、点行开详情都还在。
expect(wrapper.get('[aria-label="筛选店铺分类"]').exists()).toBe(true, '分类筛选是读面,保留')
@@ -834,7 +888,7 @@ describe('京东数据库分类按数据权限分组隔离(V203)', () => {
wrapper.unmount()
})
it('不属于任何数据权限分组:分类全空、不给切换也不给批量归类入口(空态兜底在「京东分类管理」页)', async () => {
it('不属于任何数据权限分组:分类全空、不给切换也不给批量归类入口', async () => {
jdApi.fetchJdCategoryScope.mockResolvedValue({ platformSuperAdmin: false, defaultGroupId: null, groups: [] })
const wrapper = await mountWith({ items: [item(1, { groupId: null, groupName: '' })], total: 1, page: 1, pageSize: 20 })
expect(wrapper.find('[aria-label="当前分组"]').exists()).toBe(false)
@@ -36,8 +36,8 @@ const OPS_MIN_COL_PX: Record<string, number> = {
'src/pages/asin/ProductCategoryPage.vue': 138,
'src/pages/asin/QueryAsinPage.vue': 138,
'src/pages/asin/SkipPricePage.vue': 138,
// 京东分类管理(V204):改名/删除两颗 btn-sm(两字 53×2+gap+左右 padding 24)。
'src/pages/jd/JdCategoryManagerPage.vue': 138,
// 京东分类管理页(V204)2026-11-17 下线:CRUD 并入京东数据库页「分类管理」对话框
// (对话框无表格操作列,不进本表)。
'src/pages/records/DeviceLogsPage.vue': 138,
'src/pages/records/RecordsDigitalHumanVersionPage.vue': 287,
'src/pages/records/RecordsSoftwareVersionPage.vue': 77,
@@ -40,7 +40,6 @@ const TREE: AdminMenuNode[] = [
node('admin_query_asin', '查询ASIN', '/asin-center/query'),
node('admin_appearance_patent_clean_items', '外观专利数据库', '/patent-center/clean-items'),
node('admin_jd_database', '京东数据库', '/jd-center/database'),
node('admin_jd_category_manage', '京东分类管理', '/jd-center/categories'),
node('admin_product_categories', '商品类目', '/asin-center/categories'),
]),
]
@@ -60,24 +59,20 @@ test('menuKey 平台归属:京东独占即 [jd],双侧清单即两侧,其
assert.deepEqual(platformsOfMenuKey(''), ['amazon'])
})
test('京东 tab:账号与权限只余双侧三项,数据管理只余京东两页(数据库+分类管理);顺序与 route 原样透传', () => {
test('京东 tab:账号与权限只余双侧三项,数据管理只余京东独占页(2026-11-17 分类管理并入京东数据库页后只剩数据库一页);顺序与 route 原样透传', () => {
const filtered = filterMenuTreeByPlatform(TREE, 'jd')
assert.deepEqual(filtered.map((item) => item.key), ['admin_group_account', 'admin_group_data'])
assert.deepEqual(groupChildKeys(filtered, 'admin_group_account'),
['admin_users', 'admin_group_manage', 'admin_companies'])
// 2026-11-17 用户口径「这边分组是京东的分组管理的而不是亚马逊的」:分类管理子菜单
// 归京东侧(JD_MENU_KEYS),亚马逊 tab 侧看不到它(亚马逊用例反向钉住)。
assert.deepEqual(groupChildKeys(filtered, 'admin_group_data'),
['admin_jd_database', 'admin_jd_category_manage'])
// 2026-11-17 晚用户口径「京东分类管理并到京东数据库分类编辑里」:分类管理子菜单
// (V204)下线,京东侧数据管理组只剩京东数据库一页。
assert.deepEqual(groupChildKeys(filtered, 'admin_group_data'), ['admin_jd_database'])
const jd = filtered[1].children![0]
assert.equal(jd.route, '/jd-center/database')
assert.equal(jd.name, '京东数据库')
const categoryManage = filtered[1].children![1]
assert.equal(categoryManage.route, '/jd-center/categories', 'V204 菜单行的 route_path 与注册表一致')
assert.equal(categoryManage.name, '京东分类管理')
})
test('亚马逊 tab:除京东独占两页外全数保留(含 2026-11-17 回归的双侧账号域三页),分组结构不变', () => {
test('亚马逊 tab:除京东独占页外全数保留(含 2026-11-17 回归的双侧账号域三页),分组结构不变', () => {
const filtered = filterMenuTreeByPlatform(TREE, 'amazon')
assert.deepEqual(groupChildKeys(filtered, 'admin_group_account'),
['admin_columns', 'admin_users', 'admin_group_manage', 'admin_user_secrets',
@@ -120,13 +115,13 @@ test('tab 显示依据:两侧都有可见页才画 tab 条,仅一侧授权
assert.deepEqual(visiblePlatformsFor(null), [])
})
test('平台 tab 定义与两份菜单清单钉死(防清单漂移):京东独占两页、双侧共用账号域三页', () => {
test('平台 tab 定义与两份菜单清单钉死(防清单漂移):京东独占仅数据库一页、双侧共用账号域三页', () => {
assert.deepEqual(PLATFORM_TABS, [
{ id: 'amazon', label: '亚马逊' },
{ id: 'jd', label: '京东' },
])
assert.deepEqual([...JD_MENU_KEYS].sort(),
['admin_jd_category_manage', 'admin_jd_database'])
// 2026-11-17 晚分类管理(admin_jd_category_manage)并入京东数据库页后从清单摘除。
assert.deepEqual([...JD_MENU_KEYS], ['admin_jd_database'])
assert.deepEqual([...BOTH_PLATFORM_MENU_KEYS].sort(),
['admin_companies', 'admin_group_manage', 'admin_users'])
})