feat: complete admin API integration

This commit is contained in:
2026-07-31 13:43:16 +08:00
parent bb09c7d6a0
commit d0f94d95d7
24 changed files with 1834 additions and 113 deletions
+9 -2
View File
@@ -1,13 +1,18 @@
import { createPinia, setActivePinia } from 'pinia'
import { flushPromises, shallowMount } from '@vue/test-utils'
import { beforeEach, describe, expect, it, vi } from 'vitest'
import { createPlatformRole, listPlatformRoles, type PlatformRoleResource } from '@/api/platformIam'
import { createPlatformRole, listPlatformPermissions, listPlatformRoles, type PlatformRoleResource } from '@/api/platformIam'
import { useAuthStore } from '@/stores/auth'
import RolesView from './RolesView.vue'
vi.mock('@/api/platformIam', () => ({
createPlatformRole: vi.fn(),
listPlatformPermissions: vi.fn(),
listPlatformRoles: vi.fn(),
updatePlatformRole: vi.fn(),
changePlatformRoleStatus: vi.fn(),
deletePlatformRole: vi.fn(),
replacePlatformRolePermissions: vi.fn(),
}))
const platformRole: PlatformRoleResource = {
@@ -57,6 +62,8 @@ describe('RolesView', () => {
beforeEach(() => {
setActivePinia(createPinia())
vi.mocked(listPlatformRoles).mockReset()
vi.mocked(listPlatformPermissions).mockReset()
vi.mocked(listPlatformPermissions).mockResolvedValue([])
vi.mocked(createPlatformRole).mockReset()
})
@@ -78,7 +85,7 @@ describe('RolesView', () => {
await flushPromises()
expect(listPlatformRoles).toHaveBeenCalledTimes(1)
expect(wrapper.text()).toContain('角色列表和新增角色已接入 IAM')
expect(wrapper.text()).toContain('角色查询、新增、编辑、启停、删除及权限分配均使用 IAM 真实接口')
expect(wrapper.find('[data-testid="permission-tree"]').exists()).toBe(false)
})