Add more services; Version 0.3.3

This commit is contained in:
Aslan 2025-12-29 02:02:56 +01:00
parent 50348cc494
commit ddcc591d12
26 changed files with 887 additions and 38 deletions

View file

@ -44,7 +44,7 @@ test("can create community", async () => {
state.sessionId2 = responseLogin2.id;
state.token2 = responseLogin2.token;
const createResponse = await apiPost(
const responseCreate = await apiPost(
`community`,
{
name: state.communityName,
@ -52,15 +52,15 @@ test("can create community", async () => {
},
state.token1,
);
state.communityId = createResponse.id;
assert.equal(createResponse.name, state.communityName);
assert.equal(createResponse.description, state.communityDescription);
assert.equal(createResponse.ownerId, state.userId1);
state.communityId = responseCreate.id;
assert.equal(responseCreate.name, state.communityName);
assert.equal(responseCreate.description, state.communityDescription);
assert.equal(responseCreate.ownerId, state.userId1);
const getResponse = await apiGet(`community/${state.communityId}`);
assert.equal(getResponse.name, state.communityName);
assert.equal(getResponse.description, state.communityDescription);
assert.equal(getResponse.ownerId, state.userId1);
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);
});
test("shouldn't be able to create invite", async () => {
@ -111,14 +111,14 @@ test("can accept invite", async () => {
assert.equal(response.communityId, state.communityId);
assert.equal(response.communityName, state.communityName);
const getResponse = await apiGet(
const responseGet = await apiGet(
`community/${state.communityId}/members`,
state.token1,
);
assert.equal(getResponse.id, state.communityId);
assert.equal(getResponse.name, state.communityName);
assert.equal(getResponse.members.length === 2, true);
assert.equal(responseGet.id, state.communityId);
assert.equal(responseGet.name, state.communityName);
assert.equal(responseGet.members.length === 2, true);
});
test("can get invite", async () => {
@ -247,6 +247,18 @@ test("can get roles", async () => {
assert.equal(response.roles.length === 1, true);
});
test("can get permissions", async () => {
const response = await apiGet(
`role/${state.roleId}/permissions`,
state.token2,
);
assert.equal(response.id, state.roleId);
assert.equal(response.name, state.roleName);
assert.equal(response.communityId, state.communityId);
assert.equal(response.permissions.length === 3, true);
});
test("can unassign role from user", async () => {
const response = await apiPost(
`role/${state.roleId}/unassign`,
@ -270,3 +282,81 @@ test("shouldn't be able to get channels 2", async () => {
assert.equal(response.error, "ACCESS_DENIED");
});
test("can update channel", async () => {
state.channelName = "Test Channel Mod";
const responsePatch = await apiPatch(
`channel/${state.channelId}`,
{
name: state.channelName,
},
state.token1,
);
assert.equal(responsePatch.id, state.channelId);
assert.equal(responsePatch.name, state.channelName);
assert.equal(responsePatch.communityId, state.communityId);
const responseGet = await apiGet(
`channel/${state.channelId}`,
state.token1,
);
assert.equal(responseGet.name, state.channelName);
});
test("can delete channel", async () => {
const responseDelete = await apiDelete(
`channel/${state.channelId}`,
{},
state.token1,
);
assert.equal(responseDelete.id, state.channelId);
const responseGet = await apiGet(
`channel/${state.channelId}`,
state.token1,
);
assert.equal(responseGet.error, "ACCESS_DENIED");
});
test("can update role", async () => {
state.roleName = "Test Role Mod";
const responsePatch = await apiPatch(
`role/${state.roleId}`,
{
name: state.roleName,
},
state.token1,
);
assert.equal(responsePatch.id, state.roleId);
assert.equal(responsePatch.name, state.roleName);
assert.equal(responsePatch.communityId, state.communityId);
const responseGet = await apiGet(`role/${state.roleId}`, state.token1);
assert.equal(responseGet.name, state.roleName);
});
test("can delete role", async () => {
const responseDelete = await apiDelete(
`role/${state.roleId}`,
{},
state.token1,
);
assert.equal(responseDelete.id, state.roleId);
const responseGet = await apiGet(`role/${state.roleId}`, state.token1);
assert.equal(responseGet.error, "ACCESS_DENIED");
});
test("can delete community", async () => {
const responseDelete = await apiDelete(
`community/${state.communityId}`,
{},
state.token1,
);
assert.equal(responseDelete.id, state.communityId);
const responseGet = await apiGet(`community/${state.communityId}`);
assert.equal(responseGet.error, "NOT_FOUND");
});