]> Untitled Git - lemmy.git/blob - api_tests/src/follow.spec.ts
Merge branch 'remove-hardcoded-https-dess' into main
[lemmy.git] / api_tests / src / follow.spec.ts
1 jest.setTimeout(120000);
2 import {
3   alpha,
4   setupLogins,
5   searchForBetaCommunity,
6   followCommunity,
7   checkFollowedCommunities,
8   unfollowRemotes,
9   delay,
10   longDelay,
11 } from './shared';
12
13 beforeAll(async () => {
14   await setupLogins();
15 });
16
17 afterAll(async () => {
18   await unfollowRemotes(alpha);
19 });
20
21 test('Follow federated community', async () => {
22   let search = await searchForBetaCommunity(alpha); // TODO sometimes this is returning null?
23   let follow = await followCommunity(alpha, true, search.communities[0].id);
24
25   // Make sure the follow response went through
26   expect(follow.community.local).toBe(false);
27   expect(follow.community.name).toBe('main');
28   await longDelay();
29
30   // Check it from local
31   let followCheck = await checkFollowedCommunities(alpha);
32   await delay();
33   let remoteCommunityId = followCheck.communities.filter(
34     c => c.community_local == false
35   )[0].community_id;
36   expect(remoteCommunityId).toBeDefined();
37
38   // Test an unfollow
39   let unfollow = await followCommunity(alpha, false, remoteCommunityId);
40   expect(unfollow.community.local).toBe(false);
41   await delay();
42
43   // Make sure you are unsubbed locally
44   let unfollowCheck = await checkFollowedCommunities(alpha);
45   expect(unfollowCheck.communities.length).toBeGreaterThanOrEqual(1);
46 });