Refactor part 2

This commit is contained in:
Aslan 2026-01-07 17:13:56 -05:00
parent e21a807fb3
commit 80196b732a
9 changed files with 78 additions and 25 deletions

View file

@ -71,11 +71,13 @@ test("can create community", async () => {
assert.equal(responseCreate.name, state.communityName);
assert.equal(responseCreate.description, state.communityDescription);
assert.equal(responseCreate.ownerId, state.userId1);
assert.notEqual(responseCreate.creationDate, undefined);
const responseGet = await apiGet(`community/${state.communityId}`);
assert.equal(responseGet.name, state.communityName);
assert.equal(responseGet.description, state.communityDescription);
assert.equal(responseGet.ownerId, state.userId1);
assert.notEqual(responseGet.creationDate, undefined);
});
test("shouldn't be able to create invite", async () => {
@ -133,7 +135,7 @@ test("can accept invite", async () => {
assert.equal(responseGet.id, state.communityId);
assert.equal(responseGet.name, state.communityName);
assert.equal(responseGet.members.length === 2, true);
assert.equal(responseGet.members.length, 2);
});
test("can get user communities", async () => {
@ -143,7 +145,7 @@ test("can get user communities", async () => {
);
assert.equal(response.id, state.userId2);
assert.equal(response.communities.length === 1, true);
assert.equal(response.communities.length, 1);
assert.equal(response.communities[0].id, state.communityId);
assert.equal(response.communities[0].name, state.communityName);
assert.equal(
@ -193,11 +195,13 @@ test("shouldn't be able to get roles", async () => {
test("can create channel", async () => {
state.channelName = "Test Channel";
state.channelDescription = "Test Channel Desc";
const response = await apiPost(
`channel`,
{
name: state.channelName,
description: state.channelDescription,
communityId: state.communityId,
},
state.token1,
@ -205,18 +209,22 @@ test("can create channel", async () => {
assert.equal(validate(response.id), true);
assert.equal(response.name, state.channelName);
assert.equal(response.description, state.channelDescription);
assert.equal(response.communityId, state.communityId);
assert.notEqual(response.creationDate, undefined);
state.channelId = response.id;
});
test("can create role", async () => {
state.roleName = "Test Role";
state.roleDescription = "Test Role Desc";
const response = await apiPost(
`role`,
{
name: state.roleName,
description: state.roleDescription,
communityId: state.communityId,
permissions: ["MEMBERS_READ", "CHANNELS_READ", "ROLES_READ"],
},
@ -225,7 +233,10 @@ test("can create role", async () => {
assert.equal(validate(response.id), true);
assert.equal(response.name, state.roleName);
assert.equal(response.description, state.roleDescription);
assert.equal(response.communityId, state.communityId);
assert.equal(response.permissions.length, 3);
assert.notEqual(response.creationDate, undefined);
state.roleId = response.id;
});
@ -253,7 +264,7 @@ test("can get members", async () => {
assert.equal(response.id, state.communityId);
assert.equal(response.name, state.communityName);
assert.equal(response.members.length === 2, true);
assert.equal(response.members.length, 2);
});
test("can get channels", async () => {
@ -264,7 +275,7 @@ test("can get channels", async () => {
assert.equal(response.id, state.communityId);
assert.equal(response.name, state.communityName);
assert.equal(response.channels.length === 1, true);
assert.equal(response.channels.length, 1);
});
test("can get roles", async () => {
@ -275,7 +286,7 @@ test("can get roles", async () => {
assert.equal(response.id, state.communityId);
assert.equal(response.name, state.communityName);
assert.equal(response.roles.length === 1, true);
assert.equal(response.roles.length, 1);
});
test("can get permissions", async () => {
@ -283,8 +294,11 @@ test("can get permissions", async () => {
assert.equal(response.id, state.roleId);
assert.equal(response.name, state.roleName);
assert.equal(response.description, state.roleDescription);
assert.equal(response.communityId, state.communityId);
assert.equal(response.permissions.length === 3, true);
assert.equal(response.permissions.length, 3);
assert.equal(response.permissions[1], "CHANNELS_READ");
assert.notEqual(response.creationDate, undefined);
});
test("can unassign role from user", async () => {