feat(platform): 后管菜单平台隔离收窄+列表密度收口(2026-11-18 用户截图口径「密钥管理与密钥用量统计仅亚马逊侧;菜单配置展示树按当前平台先裁剪再展平分页」)——①双侧共用清单四件收窄:AdminMenuPlatformScope.BOTH_MENU_KEYS(后端唯一出处)与 admin platform-scope.ts BOTH_PLATFORM_MENU_KEYS 同源去掉 admin_user_secrets/admin_user_secret_usage,密钥两页京东侧不再下发也不可配;②菜单管理页:全树字典保留(授权数据不动),展示树与父级候选走 filterMenuTreeNodesByPlatform 先裁剪再展平分页,切平台清筛选回页1并关弹窗;③列表密度收口:顶栏 76→56、内容区留白 30/32→12/16、筛选行 flex 换行紧凑、表格行距 6px、按钮/输入 34px 同高,三档响应式断点(1440/820/560,窄屏菜单项不再整体隐藏);task-243 顶栏 56px 断言随行、task-244 新钉六条紧凑断言与「窄屏不许 display:none 菜单项」反向钉。判据:AdminMenuPlatformScopeTest 11+AdminConsoleCurrentUserMenusPlatformTest 3(后端点名绿)+vue-tsc rc0+node --test 35+npx vitest run 全量 188/188 rc0(新增 menu-manage-platform.mount 3 支:京东侧菜单配置页无亚马逊项、保留账号域四件与京东工具、密钥页归亚马逊)+快检 overall=pass 四面绿(2026-11-18 12:5x,Git PATH 前置壳)
This commit is contained in:
@@ -84,4 +84,8 @@ test('align_menu_page_drag_and_type_wiring', () => {
|
||||
assert.match(page, /menuSiblingGroupKey/, '拖拽分组按类型+父级')
|
||||
assert.match(page, /MENU_TYPE_OPTIONS|菜单类型/, '新建/编辑弹窗含菜单类型下拉')
|
||||
assert.match(page, /menuParentCandidates/, '父菜单候选按类型过滤')
|
||||
assert.match(page, /filterMenuTreeNodesByPlatform/, '配置树必须先按当前平台裁剪,再展平分页')
|
||||
assert.match(page, /platformTab\.active/, '配置树跟随当前平台')
|
||||
assert.match(page, /walk\(visibleMenuTree\.value, 0\)/, '展平读取当前平台树,京东数据库不能被全量菜单分页挤走')
|
||||
assert.match(page, /watch\(\(\) => platformTab\.active/, '切平台必须回第一页并清筛选')
|
||||
})
|
||||
|
||||
@@ -112,9 +112,10 @@ describe('AdminLayout × 平台锁定(2026-11-18)', () => {
|
||||
const texts = wrapper.findAll('.admin-menu .el-menu-item').map((item) => item.text())
|
||||
expect(texts).toContain('京东数据库')
|
||||
expect(texts).not.toContain('查询ASIN')
|
||||
// 双侧账号域照画(2026-11-18 扩双侧后含菜单权限配置/密钥管理/密钥用量统计)
|
||||
// 共用菜单配置保留,两个密钥入口仅亚马逊侧可见。
|
||||
expect(texts).toContain('菜单权限配置')
|
||||
expect(texts).toContain('密钥管理')
|
||||
expect(texts).not.toContain('密钥管理')
|
||||
expect(texts).not.toContain('密钥用量统计')
|
||||
wrapper.unmount()
|
||||
})
|
||||
|
||||
|
||||
@@ -0,0 +1,186 @@
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
import { DOMWrapper, flushPromises, mount, type VueWrapper } from '@vue/test-utils'
|
||||
import ElementPlus from 'element-plus'
|
||||
import { createPinia, setActivePinia, type Pinia } from 'pinia'
|
||||
|
||||
import MenusPage from '@/pages/account/MenusPage.vue'
|
||||
import type { MenuManageNode } from '@/pages/account/menu-manage-model'
|
||||
import { useAdminSessionStore } from '@/stores/admin-session'
|
||||
import { useCompanyTabStore } from '@/stores/company-tab'
|
||||
import { usePlatformTabStore } from '@/stores/platform-tab'
|
||||
|
||||
const menuApi = vi.hoisted(() => ({
|
||||
loadMenuManageTree: vi.fn(),
|
||||
createMenu: vi.fn(),
|
||||
updateMenu: vi.fn(),
|
||||
deleteMenu: vi.fn(),
|
||||
reorderMenus: vi.fn(),
|
||||
}))
|
||||
|
||||
vi.mock('@/pages/account/menu-manage-api', () => menuApi)
|
||||
|
||||
/** 同一次加载返回完整字典,平台隔离由真实页面完成。 */
|
||||
function mixedMenuTree(): MenuManageNode[] {
|
||||
let nextId = 1
|
||||
function node(
|
||||
columnKey: string,
|
||||
name: string,
|
||||
menuType: 'admin' | 'app',
|
||||
children: MenuManageNode[] = [],
|
||||
): MenuManageNode {
|
||||
const id = nextId++
|
||||
return {
|
||||
id, columnKey, name, menuType, parentId: null, routePath: '', sortOrder: id,
|
||||
children: children.map((child) => ({ ...child, parentId: id })),
|
||||
}
|
||||
}
|
||||
return [
|
||||
node('video_image', '视频图片', 'app'),
|
||||
node('admin_account', '账号与权限管理', 'admin', [
|
||||
node('admin_columns', '菜单权限管理', 'admin'),
|
||||
node('admin_users', '用户管理', 'admin'),
|
||||
node('admin_group_manage', '分组管理', 'admin'),
|
||||
node('admin_companies', '公司管理', 'admin'),
|
||||
node('admin_user_secrets', '密钥管理', 'admin'),
|
||||
node('admin_user_secret_usage', '密钥用量统计', 'admin'),
|
||||
]),
|
||||
node('admin_data', '数据管理', 'admin', [
|
||||
node('admin_shop_manage', '店铺管理', 'admin'),
|
||||
node('admin_appearance_patent', '外观专利管理', 'admin'),
|
||||
node('admin_similar_asin', '相似ASIN管理', 'admin'),
|
||||
node('admin_price_track', '跟价管理', 'admin'),
|
||||
node('admin_collect_data', '采集数据管理', 'admin'),
|
||||
node('admin_publish', '发布管理', 'admin'),
|
||||
node('admin_brand', '品牌管理', 'admin'),
|
||||
node('admin_records', '生成记录管理', 'admin'),
|
||||
node('admin_jd_database', '京东数据库', 'admin'),
|
||||
]),
|
||||
node('jd_tools', '京东工具台', 'app', [
|
||||
node('jd-collect', '京东店铺数据采集', 'app'),
|
||||
node('jd-publish', '京东商品上架', 'app'),
|
||||
]),
|
||||
]
|
||||
}
|
||||
|
||||
let pinia: Pinia
|
||||
let wrapper: VueWrapper<Element> | undefined
|
||||
let host: HTMLDivElement
|
||||
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks()
|
||||
window.localStorage.removeItem('admin-platform-tab')
|
||||
pinia = createPinia()
|
||||
setActivePinia(pinia)
|
||||
useAdminSessionStore().user = { id: 1, username: 'root', role: 'super_admin' }
|
||||
useCompanyTabStore().setActiveId(7)
|
||||
menuApi.loadMenuManageTree.mockResolvedValue(mixedMenuTree())
|
||||
host = document.createElement('div')
|
||||
document.body.appendChild(host)
|
||||
})
|
||||
|
||||
afterEach(() => {
|
||||
wrapper?.unmount()
|
||||
wrapper = undefined
|
||||
host.remove()
|
||||
window.localStorage.removeItem('admin-platform-tab')
|
||||
})
|
||||
|
||||
async function mountMenus() {
|
||||
wrapper = mount(MenusPage, { attachTo: host, global: { plugins: [pinia, ElementPlus] } })
|
||||
await flushPromises()
|
||||
expect(menuApi.loadMenuManageTree).toHaveBeenCalledWith(7)
|
||||
return wrapper
|
||||
}
|
||||
|
||||
function visibleNames(page: VueWrapper<Element>) {
|
||||
return page.findAll('tbody .menu-name-text').map((cell) => cell.text())
|
||||
}
|
||||
|
||||
async function clickNextPage(page: VueWrapper<Element>) {
|
||||
const next = page.findAll('.old-pagination button').find((button) => button.text() === '下一页')
|
||||
expect(next).toBeTruthy()
|
||||
expect(next!.attributes('disabled')).toBeUndefined()
|
||||
await next!.trigger('click')
|
||||
await flushPromises()
|
||||
}
|
||||
|
||||
/** 通过真实分页收齐表格行,避免只检查首屏而漏掉后页的跨平台菜单。 */
|
||||
async function allVisibleNames(page: VueWrapper<Element>) {
|
||||
const names = visibleNames(page)
|
||||
while (true) {
|
||||
const next = page.findAll('.old-pagination button').find((button) => button.text() === '下一页')
|
||||
if (!next || next.attributes('disabled') !== undefined) return names
|
||||
await clickNextPage(page)
|
||||
names.push(...visibleNames(page))
|
||||
}
|
||||
}
|
||||
|
||||
async function pickMenuType(page: VueWrapper<Element>, label: string) {
|
||||
const input = page.get('[aria-label="筛选菜单类型"]')
|
||||
await input.trigger('click')
|
||||
await flushPromises()
|
||||
const contentId = input.attributes('aria-controls')
|
||||
const panel = contentId ? document.getElementById(contentId) : null
|
||||
expect(panel).toBeTruthy()
|
||||
const option = [...panel!.querySelectorAll('.el-select-dropdown__item')]
|
||||
.find((item) => !item.classList.contains('is-hidden') && item.textContent?.trim() === label)
|
||||
expect(option).toBeTruthy()
|
||||
await new DOMWrapper(option!).trigger('click')
|
||||
await flushPromises()
|
||||
}
|
||||
|
||||
describe('菜单权限配置页的平台隔离', () => {
|
||||
it('京东表格排除视频图片和密钥,保留账号基础菜单、数据管理祖先及京东工具', async () => {
|
||||
usePlatformTabStore().setActive('jd')
|
||||
const page = await mountMenus()
|
||||
|
||||
expect(await allVisibleNames(page)).toEqual([
|
||||
'账号与权限管理', '菜单权限管理', '用户管理', '分组管理', '公司管理',
|
||||
'数据管理', '京东数据库', '京东工具台', '京东店铺数据采集', '京东商品上架',
|
||||
])
|
||||
const databaseRow = page.findAll('tbody tr')
|
||||
.find((row) => row.find('.menu-name-text').text() === '京东数据库')
|
||||
expect(databaseRow!.findAll('td')[4].text()).toBe('数据管理')
|
||||
expect(databaseRow!.find('.column-child-mark').exists()).toBe(true)
|
||||
})
|
||||
|
||||
it('从京东切回亚马逊,视频图片和密钥仍在,京东数据库及京东工具均消失', async () => {
|
||||
usePlatformTabStore().setActive('jd')
|
||||
const page = await mountMenus()
|
||||
usePlatformTabStore().setActive('amazon')
|
||||
await flushPromises()
|
||||
|
||||
expect(await allVisibleNames(page)).toEqual([
|
||||
'视频图片', '账号与权限管理', '菜单权限管理', '用户管理', '分组管理', '公司管理',
|
||||
'密钥管理', '密钥用量统计', '数据管理', '店铺管理', '外观专利管理',
|
||||
'相似ASIN管理', '跟价管理', '采集数据管理', '发布管理', '品牌管理', '生成记录管理',
|
||||
])
|
||||
expect(menuApi.loadMenuManageTree).toHaveBeenCalledTimes(1)
|
||||
})
|
||||
|
||||
it('带名称和类型筛选进入第二页后切平台,回到第一页并清空两项筛选', async () => {
|
||||
const page = await mountMenus()
|
||||
const nameInput = page.get<HTMLInputElement>('input[placeholder="输入菜单名称"]')
|
||||
await nameInput.setValue('管理')
|
||||
await pickMenuType(page, '后台')
|
||||
expect(page.findAll('.menus-filter-row .el-select__selected-item').map((item) => item.text())).toContain('后台')
|
||||
expect(page.findAll('tbody .menu-type-text').every((cell) => cell.text() === '后台')).toBe(true)
|
||||
await clickNextPage(page)
|
||||
expect(page.get('.page-cur').text()).toBe('第 2 / 2 页')
|
||||
expect(visibleNames(page).length).toBeGreaterThan(0)
|
||||
expect(visibleNames(page).every((name) => name.includes('管理'))).toBe(true)
|
||||
|
||||
usePlatformTabStore().setActive('jd')
|
||||
await flushPromises()
|
||||
|
||||
expect(nameInput.element.value).toBe('')
|
||||
expect(page.findAll('.menus-filter-row .el-select__selected-item').map((item) => item.text())).toContain('全部')
|
||||
expect(page.get('.page-cur').text()).toBe('第 1 / 1 页')
|
||||
expect(page.get('.page-total').text()).toBe('共 10 条')
|
||||
expect(visibleNames(page)).toEqual([
|
||||
'账号与权限管理', '菜单权限管理', '用户管理', '分组管理', '公司管理',
|
||||
'数据管理', '京东数据库', '京东工具台', '京东店铺数据采集', '京东商品上架',
|
||||
])
|
||||
expect(menuApi.loadMenuManageTree).toHaveBeenCalledTimes(1)
|
||||
})
|
||||
})
|
||||
@@ -60,12 +60,11 @@ test('menuKey 平台归属:京东独占即 [jd],双侧清单即两侧,其
|
||||
assert.deepEqual(platformsOfMenuKey(''), ['amazon'])
|
||||
})
|
||||
|
||||
test('京东 tab:账号与权限只余双侧六项(2026-11-18 平台隔离把三个账号域管理页也标双侧),数据管理只余京东独占页(2026-11-17 分类管理并入京东数据库页后只剩数据库一页);顺序与 route 原样透传', () => {
|
||||
test('京东 tab:账号与权限保留账号管理四项,隐藏密钥管理与用量统计;数据管理保留京东数据库', () => {
|
||||
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_columns', 'admin_users', 'admin_group_manage', 'admin_user_secrets',
|
||||
'admin_user_secret_usage', 'admin_companies'])
|
||||
['admin_columns', 'admin_users', 'admin_group_manage', 'admin_companies'])
|
||||
// 2026-11-17 晚用户口径「京东分类管理并到京东数据库分类编辑里」:分类管理子菜单
|
||||
// (V204)下线,京东侧数据管理组只剩京东数据库一页。
|
||||
assert.deepEqual(groupChildKeys(filtered, 'admin_group_data'), ['admin_jd_database'])
|
||||
@@ -125,8 +124,9 @@ test('平台 tab 定义与菜单清单钉死(防清单漂移):京东独占
|
||||
// 2026-11-17 晚分类管理(admin_jd_category_manage)并入京东数据库页后从清单摘除。
|
||||
assert.deepEqual([...JD_MENU_KEYS], ['admin_jd_database'])
|
||||
assert.deepEqual([...BOTH_PLATFORM_MENU_KEYS].sort(),
|
||||
['admin_columns', 'admin_companies', 'admin_group_manage', 'admin_user_secret_usage',
|
||||
'admin_user_secrets', 'admin_users'])
|
||||
['admin_columns', 'admin_companies', 'admin_group_manage', 'admin_users'])
|
||||
assert.deepEqual(platformsOfMenuKey('admin_user_secrets'), ['amazon'])
|
||||
assert.deepEqual(platformsOfMenuKey('admin_user_secret_usage'), ['amazon'])
|
||||
// 桌面端(app)清单与 JD_MENU_KEYS 分列:app 菜单没有 admin 路由,不得混进
|
||||
// 「与 routes.ts 对撞」的那份(下方护栏用例只扫 JD_MENU_KEYS/BOTH 两份是刻意的)。
|
||||
assert.deepEqual([...JD_APP_MENU_KEYS].sort(), ['jd-collect', 'jd-publish', 'jd_tools'])
|
||||
|
||||
@@ -2,13 +2,13 @@ import test from 'node:test'
|
||||
import assert from 'node:assert/strict'
|
||||
import { readSource } from './helpers.ts'
|
||||
|
||||
// module 13 task 243:壳层换皮成 admin.html 蓝白浅色 —— 侧栏 252px 浅底、顶栏 76px、
|
||||
// module 13 task 243:壳层换皮成 admin.html 蓝白浅色 —— 侧栏 252px 浅底、顶栏 56px、
|
||||
// 角色胶囊 + 次级退出按钮、去掉顶栏重复 logo、菜单激活态浅蓝渐变+左蓝条。
|
||||
|
||||
test('test_task_243_shell_normal_primary_path', () => {
|
||||
const css = readSource('src/styles/main.css')
|
||||
assert.match(css, /\.admin-sidebar\s*\{[^}]*flex:\s*0\s*0\s*252px/, '侧栏宽度应为 252px')
|
||||
assert.match(css, /\.admin-topbar\s*\{[^}]*min-height:\s*76px/, '顶栏高度应为 76px')
|
||||
assert.match(css, /\.admin-topbar\s*\{[^}]*min-height:\s*56px/, '顶栏高度应为 56px')
|
||||
assert.match(css, /linear-gradient\(180deg,\s*var\(--admin-sidebar\)\s*0%,/, '侧栏应为浅色渐变底')
|
||||
// 壳层锁视口高(2026-11-18「菜单加个滚动条」绊线):.admin-shell 必须 height:100vh +
|
||||
// overflow:hidden——侧边栏固定、菜单区 el-scrollbar 与内容区 overflow:auto 才能各自独立滚动;
|
||||
@@ -28,8 +28,8 @@ test('test_task_243_shell_normal_variant_input', () => {
|
||||
|
||||
test('test_task_243_shell_normal_repeated_operation_is_idempotent', () => {
|
||||
const css = readSource('src/styles/main.css')
|
||||
const first = /\.admin-topbar\s*\{[^}]*min-height:\s*76px/.test(css)
|
||||
const second = /\.admin-topbar\s*\{[^}]*min-height:\s*76px/.test(css)
|
||||
const first = /\.admin-topbar\s*\{[^}]*min-height:\s*56px/.test(css)
|
||||
const second = /\.admin-topbar\s*\{[^}]*min-height:\s*56px/.test(css)
|
||||
assert.equal(first, true)
|
||||
assert.equal(first, second)
|
||||
})
|
||||
|
||||
@@ -10,6 +10,12 @@ test('test_task_244_component_normal_primary_path', () => {
|
||||
assert.match(css, /--el-table-header-bg-color:\s*#edf4fa/, '表头底色应对齐 admin #edf4fa')
|
||||
assert.match(css, /--el-table-header-text-color:\s*#4e6479/, '表头文字色应对齐 admin')
|
||||
assert.match(css, /--el-table-row-hover-bg-color:\s*#f1f7fb/, '行 hover 应对齐 admin')
|
||||
assert.match(css, /\.admin-content\s*\{[^}]*padding:\s*12px 16px 20px/, '内容区应减少留白')
|
||||
assert.match(css, /\.admin-content :is\(\.panel-box, \.form-box\)\s*\{[^}]*padding:\s*12px 14px/, '列表卡片应紧凑')
|
||||
assert.match(css, /\.admin-content :is\(\.table-scroll, \.table-wrap\) :is\(th, td\)\s*\{[^}]*padding-top:\s*6px;\s*padding-bottom:\s*6px/, '普通列表应缩小行间距')
|
||||
assert.match(css, /\.admin-content \.el-select\.admin-filter \.el-select__wrapper\s*\{[^}]*min-height:\s*34px/, '筛选下拉应与紧凑输入同高')
|
||||
assert.match(css, /\.admin-content :is\(\.form-row, \.clean-filter-row, \.dedupe-filter-row, \.dedupe-filter-date-row, \.jd-filter-row\)\s*\{[^}]*display:\s*flex;\s*flex-wrap:\s*wrap/, '筛选栏必须随可用宽度换行')
|
||||
assert.equal(/\.admin-menu \.el-menu-item\s*\{\s*display:\s*none/.test(css), false, '窄屏菜单项不能被直接隐藏')
|
||||
})
|
||||
|
||||
test('test_task_244_component_normal_variant_input', () => {
|
||||
|
||||
Reference in New Issue
Block a user