1 jest.setTimeout(120000);
6 searchForBetaCommunity,
15 } from 'lemmy-js-client';
17 beforeAll(async () => {
21 function assertCommunityFederation(
22 communityOne: Community,
23 communityTwo: Community) {
24 expect(communityOne.actor_id).toBe(communityTwo.actor_id);
25 expect(communityOne.name).toBe(communityTwo.name);
26 expect(communityOne.title).toBe(communityTwo.title);
27 expect(communityOne.description).toBe(communityTwo.description);
28 expect(communityOne.icon).toBe(communityTwo.icon);
29 expect(communityOne.banner).toBe(communityTwo.banner);
30 expect(communityOne.published).toBe(communityTwo.published);
31 expect(communityOne.creator_actor_id).toBe(communityTwo.creator_actor_id);
32 expect(communityOne.nsfw).toBe(communityTwo.nsfw);
33 expect(communityOne.category_id).toBe(communityTwo.category_id);
34 expect(communityOne.removed).toBe(communityTwo.removed);
35 expect(communityOne.deleted).toBe(communityTwo.deleted);
38 test('Create community', async () => {
39 let communityRes = await createCommunity(alpha);
40 expect(communityRes.community.name).toBeDefined();
43 let prevName = communityRes.community.name;
44 let communityRes2 = await createCommunity(alpha, prevName);
45 expect(communityRes2['error']).toBe('community_already_exists');
48 // Cache the community on beta, make sure it has the other fields
49 let searchShort = `!${prevName}@lemmy-alpha:8541`;
50 let search = await searchForCommunity(beta, searchShort);
51 let communityOnBeta = search.communities[0];
52 assertCommunityFederation(communityOnBeta, communityRes.community);
55 test('Delete community', async () => {
56 let communityRes = await createCommunity(beta);
58 let deleteCommunityRes = await deleteCommunity(
61 communityRes.community.id
63 expect(deleteCommunityRes.community.deleted).toBe(true);
66 // Make sure it got deleted on A
67 let search = await searchForBetaCommunity(alpha);
68 let communityA = search.communities[0];
69 // TODO this fails currently, because no updates are pushed
70 // expect(communityA.deleted).toBe(true);
71 // assertCommunityFederation(communityA, communityRes.community);
74 let undeleteCommunityRes = await deleteCommunity(
77 communityRes.community.id
79 expect(undeleteCommunityRes.community.deleted).toBe(false);
82 // Make sure it got undeleted on A
83 let search2 = await searchForBetaCommunity(alpha);
84 let communityA2 = search2.communities[0];
85 // TODO this fails currently, because no updates are pushed
86 // expect(communityA2.deleted).toBe(false);
87 // assertCommunityFederation(communityA2, undeleteCommunityRes.community);
90 test('Remove community', async () => {
91 let communityRes = await createCommunity(beta);
93 let removeCommunityRes = await removeCommunity(
96 communityRes.community.id
98 expect(removeCommunityRes.community.removed).toBe(true);
100 // Make sure it got removed on A
101 let search = await searchForBetaCommunity(alpha);
102 let communityA = search.communities[0];
103 // TODO this fails currently, because no updates are pushed
104 // expect(communityA.removed).toBe(true);
105 // assertCommunityFederation(communityA, communityRes.community);
109 let unremoveCommunityRes = await removeCommunity(
112 communityRes.community.id
114 expect(unremoveCommunityRes.community.removed).toBe(false);
117 // Make sure it got unremoved on A
118 let search2 = await searchForBetaCommunity(alpha);
119 let communityA2 = search2.communities[0];
120 // TODO this fails currently, because no updates are pushed
121 // expect(communityA2.removed).toBe(false);
122 // assertCommunityFederation(communityA2, unremoveCommunityRes.community);
125 test('Search for beta community', async () => {
126 let search = await searchForBetaCommunity(alpha);
127 expect(search.communities[0].name).toBe('main');