feat(core): Add delete user functionality and necessary tests

This commit is contained in:
Philipp Kunz 2024-08-27 08:13:52 +02:00
parent 66a4bf6142
commit 6ab9ab2c59
5 changed files with 36 additions and 5 deletions

View File

@ -1,5 +1,12 @@
# Changelog
## 2024-08-27 - 1.1.0 - feat(core)
Add delete user functionality and necessary tests
- Implemented delete method in ZitadelUser class.
- Extended tests to cover user deletion functionality.
- Refactored createUser method to return a ZitadelUser instance.
## 2024-08-26 - 1.0.9 - fix(dependencies)
Update dependencies to latest versions

View File

@ -24,15 +24,24 @@ tap.test('should list users', async () => {
const users = await testZitadel.listUsers();
expect(users).toBeArray();
expect(users[0]).toBeInstanceOf(zitadel.ZitaldelUser);
console.log(users);
console.log(JSON.stringify(users, null, 2));
})
tap.test('should invite user', async () => {
await testZitadel.createUser({
const createUserTest = tap.test('should invite user', async (toolsArg) => {
const user = await testZitadel.createUser({
email: await testQenv.getEnvVarOnDemand('ZITADEL_TEST_EMAIL'),
firstName: 'firstname',
lastName: 'lastname',
})
await toolsArg.delayFor(5000);
return user;
})
tap.test('should delete user', async () => {
const createdUser: zitadel.ZitaldelUser = (await createUserTest.testResultPromise) as any;
expect(createdUser).toBeInstanceOf(zitadel.ZitaldelUser);
await createdUser.delete();
})
export default tap.start()

View File

@ -3,6 +3,6 @@
*/
export const commitinfo = {
name: '@apiclient.xyz/zitadel',
version: '1.0.9',
version: '1.1.0',
description: 'An unofficial client for interacting with Zitadel API, enabling user and project management functionalities.'
}

View File

@ -79,6 +79,12 @@ export class ZitaldelClient {
familyName: optionsArg.lastName,
}
});
console.log(response);
// const allUsers = await this.listUsers();
// console.log(JSON.stringify(allUsers, null, 2));
return new ZitaldelUser(this, {
id: response.userId,
lastLogin: null,
username: optionsArg.email,
});
}
}

View File

@ -64,4 +64,13 @@ export class ZitaldelUser {
userId: this.data.id,
});
}
/**
* deletes the user
*/
public async delete() {
const response = await this.zitadelclientRef.userClient.deleteUser({
userId: this.data.id,
});
}
}