mirror of
https://github.com/logto-io/logto.git
synced 2025-01-06 20:40:08 -05:00
162998f414
* chore(test): integration test update add dotenv * chore(core): update pnpm lock update pnpm lock * refactor(test): refactor integration test step 1 extract api, and orgnize test case following core/route structure * chore(test): update path update path * fix(test): update path update path * fix(test): cr update cr update
55 lines
1.6 KiB
TypeScript
55 lines
1.6 KiB
TypeScript
import { HTTPError } from 'got';
|
|
|
|
import { getUser, getUsers, updateUser, deleteUser, updateUserPassword } from '@/api';
|
|
import { createUser } from '@/helpers';
|
|
|
|
describe('admin console user management', () => {
|
|
it('should create user successfully', async () => {
|
|
const user = await createUser();
|
|
|
|
const userDetails = await getUser(user.id);
|
|
expect(userDetails.id).toBe(user.id);
|
|
});
|
|
|
|
it('should get user list successfully', async () => {
|
|
await createUser();
|
|
const users = await getUsers();
|
|
|
|
expect(users.length).not.toBeLessThan(1);
|
|
});
|
|
|
|
it('should update userinfo successfully', async () => {
|
|
const user = await createUser();
|
|
|
|
const newUserData = {
|
|
name: 'new name',
|
|
avatar: 'https://new.avatar.com/avatar.png',
|
|
customData: {
|
|
level: 1,
|
|
},
|
|
roleNames: ['admin'],
|
|
};
|
|
|
|
const updatedUser = await updateUser(user.id, newUserData);
|
|
|
|
expect(updatedUser).toMatchObject(newUserData);
|
|
});
|
|
|
|
it('should delete user successfully', async () => {
|
|
const user = await createUser();
|
|
|
|
const userEntity = await getUser(user.id);
|
|
expect(userEntity).toMatchObject(user);
|
|
|
|
await deleteUser(user.id);
|
|
|
|
const response = await getUser(user.id).catch((error: unknown) => error);
|
|
expect(response instanceof HTTPError && response.response.statusCode === 404).toBe(true);
|
|
});
|
|
|
|
it('should update user password successfully', async () => {
|
|
const user = await createUser();
|
|
const userEntity = await updateUserPassword(user.id, 'new_password');
|
|
expect(userEntity).toMatchObject(user);
|
|
});
|
|
});
|