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