Add role assign/unassign

This commit is contained in:
Aslan 2025-12-28 13:35:12 +01:00
parent 1f3a94cf38
commit 50348cc494
6 changed files with 235 additions and 10 deletions

View file

@ -200,14 +200,18 @@ test("can create role", async () => {
});
test("can assign role to user", async () => {
const response = await apiGet(
`community/${state.communityId}/members`,
state.token2,
const response = await apiPost(
`role/${state.roleId}/assign`,
{
userId: state.userId2,
},
state.token1,
);
assert.equal(response.id, state.communityId);
assert.equal(response.name, state.communityName);
assert.equal(response.members.length === 2, true);
assert.equal(response.id, state.roleId);
assert.equal(response.name, state.roleName);
assert.equal(response.communityId, state.communityId);
assert.equal(response.userId, state.userId2);
});
test("can get members", async () => {
@ -242,3 +246,27 @@ test("can get roles", async () => {
assert.equal(response.name, state.communityName);
assert.equal(response.roles.length === 1, true);
});
test("can unassign role from user", async () => {
const response = await apiPost(
`role/${state.roleId}/unassign`,
{
userId: state.userId2,
},
state.token1,
);
assert.equal(response.id, state.roleId);
assert.equal(response.name, state.roleName);
assert.equal(response.communityId, state.communityId);
assert.equal(response.userId, state.userId2);
});
test("shouldn't be able to get channels 2", async () => {
const response = await apiGet(
`community/${state.communityId}/channels`,
state.token2,
);
assert.equal(response.error, "ACCESS_DENIED");
});