This commit is contained in:
2026-08-12 15:10:37 +08:00
parent 1ee5a2dec7
commit a01d2bbc9a
@@ -508,7 +508,7 @@ describe('CustomersView', () => {
expect(document.querySelector('.el-table__fixed')).toBeNull()
})
it('keeps frequent actions visible and groups secondary customer actions under more', async () => {
it('keeps every permitted customer action visible without a more menu', async () => {
const auth = useAuthStore()
auth.permissions = [...auth.permissions, 'platform:customer:reset-password', 'platform:customer:impersonate', 'platform:customer:status', 'platform:customer:delete']
useAccessPreviewStore().initializeAfterLogin()
@@ -519,14 +519,15 @@ describe('CustomersView', () => {
expect(tableButtonByText('详情')).toBeDefined()
expect(tableButtonByText('编辑')).toBeDefined()
expect(document.querySelector('.el-table__body button[aria-label="更多客户操作:柏悦物流"]')).toBeTruthy()
expect(document.querySelector('.el-table__body button[aria-label^="更多客户操作:"]')).toBeNull()
expect(tableButtonByText('重置密码')).toBeDefined()
expect(tableButtonByText('跳转登录')).toBeUndefined()
await clickMoreAction('跳转登录')
expect(tableButtonByText('跳转登录')).toBeDefined()
tableButtonByText('跳转登录')?.click()
await flushPromises()
expect(document.body.textContent).toContain('代登录原因')
})
it('uses stable unique customer identities for multiple more-action buttons', async () => {
it('renders all permitted actions directly for multiple customers', async () => {
const auth = useAuthStore()
auth.permissions = [...auth.permissions, 'platform:customer:reset-password', 'platform:customer:impersonate', 'platform:customer:status', 'platform:customer:delete']
useAccessPreviewStore().initializeAfterLogin()
@@ -542,16 +543,11 @@ describe('CustomersView', () => {
mount(CustomersView, { attachTo: document.body, global: { plugins: [pinia, ElementPlus] } })
await flushPromises()
const buttons = [...document.querySelectorAll<HTMLButtonElement>('.el-table__body button[aria-label^="更多客户操作:"]')]
expect(buttons.map((button) => button.getAttribute('aria-label'))).toEqual([
'更多客户操作:客户甲',
'更多客户操作:TEN-B',
'更多客户操作:当前客户',
])
expect(buttons.map((button) => button.getAttribute('title'))).toEqual(buttons.map((button) => button.getAttribute('aria-label')))
expect(document.querySelectorAll('.el-table__body button[aria-label^="更多客户操作:"]').length).toBe(0)
expect(document.querySelectorAll('.el-table__body button').length).toBeGreaterThan(9)
})
it('falls back to the current customer when all row identifiers are missing', async () => {
it('keeps the action row usable when all customer identifiers are missing', async () => {
const auth = useAuthStore()
auth.permissions = [...auth.permissions, 'platform:customer:reset-password', 'platform:customer:impersonate', 'platform:customer:status', 'platform:customer:delete']
useAccessPreviewStore().initializeAfterLogin()
@@ -563,9 +559,7 @@ describe('CustomersView', () => {
mount(CustomersView, { attachTo: document.body, global: { plugins: [pinia, ElementPlus] } })
await flushPromises()
const button = document.querySelector<HTMLButtonElement>('.el-table__body button[aria-label^="更多客户操作:"]')
expect(button?.getAttribute('aria-label')).toBe('更多客户操作:当前客户')
expect(button?.getAttribute('title')).toBe('更多客户操作:当前客户')
expect(button?.getAttribute('aria-label')).not.toMatch(/undefined|null/)
expect(document.querySelector('.el-table__body button[aria-label^="更多客户操作:"]')).toBeNull()
expect(tableButtonByText('详情')).toBeDefined()
})
})