feat(admin): 为支持单删的管理列表补齐批量删除
This commit is contained in:
@@ -28,6 +28,22 @@ const secretsApi = vi.hoisted(() => ({
|
||||
}))
|
||||
|
||||
vi.mock('@/api/user-secrets', () => secretsApi)
|
||||
const confirmBatch = vi.hoisted(() => vi.fn())
|
||||
vi.mock('@/components/admin-confirm', () => ({ openAdminConfirm: confirmBatch }))
|
||||
|
||||
it('批量清空点名全部密钥与代理,只调用用户级清空接口', async () => {
|
||||
const wrapper = await mountWith([row(7), row(8)])
|
||||
confirmBatch.mockResolvedValue(true)
|
||||
secretsApi.deleteUserSecret.mockResolvedValue(undefined)
|
||||
await wrapper.get('thead .batch-delete-checkbox').setValue(true)
|
||||
await wrapper.get('.batch-delete-actions .btn-danger').trigger('click')
|
||||
await flushPromises()
|
||||
expect(confirmBatch).toHaveBeenCalledWith(expect.objectContaining({ danger: true, message: expect.stringContaining('全部密钥与代理配置') }))
|
||||
expect(secretsApi.deleteUserSecret.mock.calls).toEqual([[7], [8]])
|
||||
expect(secretsApi.clearUserSecretModule).not.toHaveBeenCalled()
|
||||
expect(wrapper.get('.batch-delete-actions .btn-danger').text()).toBe('批量清空(0)')
|
||||
wrapper.unmount()
|
||||
})
|
||||
|
||||
function moduleCell(moduleKey: string, over: Record<string, unknown> = {}) {
|
||||
return {
|
||||
@@ -122,7 +138,7 @@ describe('余额两列接在密钥管理列表上', () => {
|
||||
const headerCount = wrapper.findAll('thead th').length
|
||||
const cellCount = wrapper.findAll('tbody tr')[0].findAll('td').length
|
||||
expect(cellCount, '每行的 td 数必须等于表头列数').toBe(headerCount)
|
||||
expect(headerCount).toBe(12)
|
||||
expect(headerCount).toBe(13)
|
||||
|
||||
const emptyWrapper = await mountWith([])
|
||||
const colspan = Number(emptyWrapper.find('tbody td').attributes('colspan'))
|
||||
@@ -133,7 +149,7 @@ describe('余额两列接在密钥管理列表上', () => {
|
||||
useAdminSessionStore().user = { id: 2, username: 'leader', role: 'admin' }
|
||||
const wrapper = await mountWith([row(7)])
|
||||
const headerCount = wrapper.findAll('thead th').length
|
||||
expect(headerCount).toBe(11)
|
||||
expect(headerCount).toBe(12)
|
||||
expect(wrapper.findAll('tbody tr')[0].findAll('td').length).toBe(headerCount)
|
||||
|
||||
const emptyWrapper = await mountWith([])
|
||||
|
||||
Reference in New Issue
Block a user