X-Git-Url: http://these/git/?a=blobdiff_plain;f=api_tests%2Fsrc%2Fcommunity.spec.ts;h=0ed50ec484672becec82ff5257c0ac288eaf4965;hb=235cc8b22897bfb3e71ba3dbd725d36863fea8ba;hp=381b546b306499dcf549ccb642b2ffec4c22d673;hpb=276a8c2bd3e4fd1323e66b808675cf14cf6f75c5;p=lemmy.git diff --git a/api_tests/src/community.spec.ts b/api_tests/src/community.spec.ts index 381b546b..0ed50ec4 100644 --- a/api_tests/src/community.spec.ts +++ b/api_tests/src/community.spec.ts @@ -1,5 +1,5 @@ jest.setTimeout(120000); -import { CommunityView } from 'lemmy-js-client'; +import { CommunityView } from "lemmy-js-client"; import { alpha, @@ -18,7 +18,7 @@ import { createPost, getPost, resolvePost, -} from './shared'; +} from "./shared"; beforeAll(async () => { await setupLogins(); @@ -34,8 +34,12 @@ function assertCommunityFederation( expect(communityOne.community.description.unwrapOr("none")).toBe( communityTwo.community.description.unwrapOr("none") ); - expect(communityOne.community.icon.unwrapOr("none")).toBe(communityTwo.community.icon.unwrapOr("none")); - expect(communityOne.community.banner.unwrapOr("none")).toBe(communityTwo.community.banner.unwrapOr("none")); + expect(communityOne.community.icon.unwrapOr("none")).toBe( + communityTwo.community.icon.unwrapOr("none") + ); + expect(communityOne.community.banner.unwrapOr("none")).toBe( + communityTwo.community.banner.unwrapOr("none") + ); expect(communityOne.community.published).toBe( communityTwo.community.published ); @@ -44,35 +48,35 @@ function assertCommunityFederation( expect(communityOne.community.deleted).toBe(communityTwo.community.deleted); } -test('Create community', async () => { +test("Create community", async () => { let communityRes = await createCommunity(alpha); expect(communityRes.community_view.community.name).toBeDefined(); // A dupe check let prevName = communityRes.community_view.community.name; let communityRes2: any = await createCommunity(alpha, prevName); - expect(communityRes2['error']).toBe('community_already_exists'); + expect(communityRes2["error"]).toBe("community_already_exists"); // Cache the community on beta, make sure it has the other fields let searchShort = `!${prevName}@lemmy-alpha:8541`; - let betaCommunity = (await resolveCommunity(beta, searchShort)).community.unwrap(); + let betaCommunity = ( + await resolveCommunity(beta, searchShort) + ).community.unwrap(); assertCommunityFederation(betaCommunity, communityRes.community_view); }); -test('Delete community', async () => { +test("Delete community", async () => { let communityRes = await createCommunity(beta); // Cache the community on Alpha let searchShort = `!${communityRes.community_view.community.name}@lemmy-beta:8551`; - let alphaCommunity = (await resolveCommunity(alpha, searchShort)).community.unwrap(); + let alphaCommunity = ( + await resolveCommunity(alpha, searchShort) + ).community.unwrap(); assertCommunityFederation(alphaCommunity, communityRes.community_view); // Follow the community from alpha - let follow = await followCommunity( - alpha, - true, - alphaCommunity.community.id - ); + let follow = await followCommunity(alpha, true, alphaCommunity.community.id); // Make sure the follow response went through expect(follow.community_view.community.local).toBe(false); @@ -83,7 +87,9 @@ test('Delete community', async () => { communityRes.community_view.community.id ); expect(deleteCommunityRes.community_view.community.deleted).toBe(true); - expect(deleteCommunityRes.community_view.community.title).toBe(communityRes.community_view.community.title); + expect(deleteCommunityRes.community_view.community.title).toBe( + communityRes.community_view.community.title + ); // Make sure it got deleted on A let communityOnAlphaDeleted = await getCommunity( @@ -110,20 +116,18 @@ test('Delete community', async () => { ); }); -test('Remove community', async () => { +test("Remove community", async () => { let communityRes = await createCommunity(beta); // Cache the community on Alpha let searchShort = `!${communityRes.community_view.community.name}@lemmy-beta:8551`; - let alphaCommunity = (await resolveCommunity(alpha, searchShort)).community.unwrap(); + let alphaCommunity = ( + await resolveCommunity(alpha, searchShort) + ).community.unwrap(); assertCommunityFederation(alphaCommunity, communityRes.community_view); // Follow the community from alpha - let follow = await followCommunity( - alpha, - true, - alphaCommunity.community.id - ); + let follow = await followCommunity(alpha, true, alphaCommunity.community.id); // Make sure the follow response went through expect(follow.community_view.community.local).toBe(false); @@ -134,7 +138,9 @@ test('Remove community', async () => { communityRes.community_view.community.id ); expect(removeCommunityRes.community_view.community.removed).toBe(true); - expect(removeCommunityRes.community_view.community.title).toBe(communityRes.community_view.community.title); + expect(removeCommunityRes.community_view.community.title).toBe( + communityRes.community_view.community.title + ); // Make sure it got Removed on A let communityOnAlphaRemoved = await getCommunity( @@ -161,34 +167,53 @@ test('Remove community', async () => { ); }); -test('Search for beta community', async () => { +test("Search for beta community", async () => { let communityRes = await createCommunity(beta); expect(communityRes.community_view.community.name).toBeDefined(); let searchShort = `!${communityRes.community_view.community.name}@lemmy-beta:8551`; - let alphaCommunity = (await resolveCommunity(alpha, searchShort)).community.unwrap(); + let alphaCommunity = ( + await resolveCommunity(alpha, searchShort) + ).community.unwrap(); assertCommunityFederation(alphaCommunity, communityRes.community_view); }); -test('Admin actions in remote community are not federated to origin', async () => { +test("Admin actions in remote community are not federated to origin", async () => { // create a community on alpha let communityRes = (await createCommunity(alpha)).community_view; expect(communityRes.community.name).toBeDefined(); // gamma follows community and posts in it - let gammaCommunity = (await resolveCommunity(gamma, communityRes.community.actor_id)).community.unwrap(); - let gammaFollow = (await followCommunity(gamma, true, gammaCommunity.community.id)); + let gammaCommunity = ( + await resolveCommunity(gamma, communityRes.community.actor_id) + ).community.unwrap(); + let gammaFollow = await followCommunity( + gamma, + true, + gammaCommunity.community.id + ); expect(gammaFollow.community_view.subscribed).toBe("Subscribed"); - let gammaPost = (await createPost(gamma, gammaCommunity.community.id)).post_view; + let gammaPost = (await createPost(gamma, gammaCommunity.community.id)) + .post_view; expect(gammaPost.post.id).toBeDefined(); expect(gammaPost.creator_banned_from_community).toBe(false); // admin of beta decides to ban gamma from community - let betaCommunity = (await resolveCommunity(beta, communityRes.community.actor_id)).community.unwrap(); - let bannedUserInfo1 = (await getSite(gamma)).my_user.unwrap().local_user_view.person; - let bannedUserInfo2 = (await resolvePerson(beta, bannedUserInfo1.actor_id)).person.unwrap(); - let banRes = (await banPersonFromCommunity(beta, bannedUserInfo2.person.id, betaCommunity.community.id, true, true)); - console.log(banRes); + let betaCommunity = ( + await resolveCommunity(beta, communityRes.community.actor_id) + ).community.unwrap(); + let bannedUserInfo1 = (await getSite(gamma)).my_user.unwrap().local_user_view + .person; + let bannedUserInfo2 = ( + await resolvePerson(beta, bannedUserInfo1.actor_id) + ).person.unwrap(); + let banRes = await banPersonFromCommunity( + beta, + bannedUserInfo2.person.id, + betaCommunity.community.id, + true, + true + ); expect(banRes.banned).toBe(true); // ban doesnt federate to community's origin instance alpha @@ -196,6 +221,6 @@ test('Admin actions in remote community are not federated to origin', async () = expect(alphaPost.creator_banned_from_community).toBe(false); // and neither to gamma - let gammaPost2 = (await getPost(gamma, gammaPost.post.id)); + let gammaPost2 = await getPost(gamma, gammaPost.post.id); expect(gammaPost2.post_view.creator_banned_from_community).toBe(false); });