This commit is contained in:
2026-08-04 13:32:08 +08:00
parent 6354f5ca66
commit 2192aed125
17 changed files with 711 additions and 354 deletions
+18 -13
View File
@@ -94,13 +94,13 @@ const managedUser: PlatformManagedUser = {
displayName: '张伟',
phone: '13800138000',
email: 'zhangwei@example.com',
tenantId: '10001',
tenantName: '华远贸易',
memberType: 'EMPLOYEE',
memberNo: 'MEMBER-3000002',
tenantId: '0',
tenantName: '平台',
memberType: 'INTERNAL',
memberNo: 'PLATFORM-3000002',
status: 'ACTIVE',
roleIds: ['40001'],
roleNames: ['租户管理员'],
roleNames: ['运营管理员'],
lastLoginAt: '2026-06-01T10:30:00',
protectedAccount: false,
}
@@ -204,32 +204,37 @@ describe('platform IAM roles', () => {
expect(http.put).toHaveBeenNthCalledWith(4, `/platform/v1/iam/internal-users/${internalUser.membershipId}/roles`, { roleIds: [4000001] })
})
it('maintains platform and tenant users through the unified user contract', async () => {
it('maintains paginated platform users through the unified user contract', async () => {
const userOptions = {
tenants: [{ id: '10001', name: '华远贸易', status: 'ACTIVE' }],
roles: [{ id: '40001', tenantId: '10001', name: '租户管理员', status: 'ACTIVE' }],
tenants: [{ id: '0', name: '平台', status: 'ACTIVE' }],
roles: [{ id: '40001', tenantId: '0', name: '运营管理员', status: 'ACTIVE' }],
}
const create = {
username: 'zhangwei', displayName: '张伟', phone: '13800138000', email: 'zhangwei@example.com',
tenantId: '10001', roleIds: ['40001'], password: 'Password1', status: 'ACTIVE' as const,
tenantId: '0', roleIds: ['40001'], password: 'Password1', status: 'ACTIVE' as const,
}
const update = {
displayName: '张伟', phone: '13800138000', email: 'zhangwei@example.com',
tenantId: '10001', roleIds: ['40001'],
tenantId: '0', roleIds: ['40001'],
}
vi.mocked(http.get).mockResolvedValueOnce({ code: '200', message: 'success', data: [managedUser] })
const userPage = { records: [managedUser], page: 2, size: 10, total: 11, pages: 2 }
vi.mocked(http.get).mockResolvedValueOnce({
code: '200', message: 'success', data: { ...userPage, page: '2', size: '10', total: '11', pages: '2' },
})
.mockResolvedValueOnce({ code: '200', message: 'success', data: userOptions })
vi.mocked(http.post).mockResolvedValue({ code: '200', message: 'success', data: managedUser })
vi.mocked(http.put).mockResolvedValue({ code: '200', message: 'success', data: managedUser })
await expect(listPlatformManagedUsers()).resolves.toEqual([managedUser])
await expect(listPlatformManagedUsers({ page: 2, size: 10, keyword: '张伟', status: 'ACTIVE' })).resolves.toEqual(userPage)
await expect(getPlatformUserOptions()).resolves.toEqual(userOptions)
await expect(createPlatformManagedUser(create)).resolves.toEqual(managedUser)
await expect(updatePlatformManagedUser(managedUser.membershipId, update)).resolves.toEqual(managedUser)
await expect(changePlatformManagedUserStatus(managedUser.membershipId, 'DISABLED')).resolves.toEqual(managedUser)
await expect(resetPlatformManagedUserPassword(managedUser.membershipId, 'ChangeMe123')).resolves.toEqual(managedUser)
expect(http.get).toHaveBeenNthCalledWith(1, '/platform/v1/iam/users')
expect(http.get).toHaveBeenNthCalledWith(1, '/platform/v1/iam/users', {
params: { page: 2, size: 10, keyword: '张伟', status: 'ACTIVE' },
})
expect(http.get).toHaveBeenNthCalledWith(2, '/platform/v1/iam/users/options')
expect(http.post).toHaveBeenCalledWith('/platform/v1/iam/users', create)
expect(http.put).toHaveBeenNthCalledWith(1, `/platform/v1/iam/users/${managedUser.membershipId}`, update)