]> Untitled Git - lemmy.git/blob - api_tests/src/follow.spec.ts
d75735b00e402421ff050842b3974e606c8e075f
[lemmy.git] / api_tests / src / follow.spec.ts
1 jest.setTimeout(120000);
2 import {
3   alpha,
4   setupLogins,
5   resolveBetaCommunity,
6   followCommunity,
7   unfollowRemotes,
8   getSite,
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 betaCommunity = (await resolveBetaCommunity(alpha)).community;
21   let follow = await followCommunity(
22     alpha,
23     true,
24     betaCommunity.community.id
25   );
26
27   // Make sure the follow response went through
28   expect(follow.community_follower_view.community.local).toBe(false);
29   expect(follow.community_follower_view.community.name).toBe('main');
30   expect(follow.community_follower_view.pending).toBe(true);
31
32   // Check it from local
33   let site = await getSite(alpha);
34   let remoteCommunityId = site.my_user.follows.find(
35     c => c.community.local == false
36   ).community.id;
37   expect(remoteCommunityId).toBeDefined();
38
39   // Test an unfollow
40   let unfollow = await followCommunity(alpha, false, remoteCommunityId);
41   expect(unfollow.community_follower_view).toBeNull()
42
43   // Make sure you are unsubbed locally
44   let siteUnfollowCheck = await getSite(alpha);
45   expect(siteUnfollowCheck.my_user.follows.length).toBeGreaterThanOrEqual(1);
46 });