]> Untitled Git - lemmy.git/blob - api_tests/src/follow.spec.ts
Expose pending 2 (#2282)
[lemmy.git] / api_tests / src / follow.spec.ts
1 jest.setTimeout(120000);
2 import {SubscribedType} from 'lemmy-js-client';
3 import {
4   alpha,
5   setupLogins,
6   resolveBetaCommunity,
7   followCommunity,
8   unfollowRemotes,
9   getSite,
10 } from './shared';
11
12 beforeAll(async () => {
13   await setupLogins();
14 });
15
16 afterAll(async () => {
17   await unfollowRemotes(alpha);
18 });
19
20 test('Follow federated community', async () => {
21   let betaCommunity = (await resolveBetaCommunity(alpha)).community;
22   let follow = await followCommunity(
23     alpha,
24     true,
25     betaCommunity.community.id
26   );
27
28   // Make sure the follow response went through
29   expect(follow.community_view.community.local).toBe(false);
30   expect(follow.community_view.community.name).toBe('main');
31   expect(follow.community_view.subscribed).toBe(SubscribedType.Pending);
32
33   // Check it from local
34   let site = await getSite(alpha);
35   let remoteCommunityId = site.my_user.follows.find(
36     c => c.community.local == false
37   ).community.id;
38   expect(remoteCommunityId).toBeDefined();
39
40   // Test an unfollow
41   let unfollow = await followCommunity(alpha, false, remoteCommunityId);
42   expect(unfollow.community_view.subscribed).toBe(SubscribedType.NotSubscribed);
43
44   // Make sure you are unsubbed locally
45   let siteUnfollowCheck = await getSite(alpha);
46   expect(siteUnfollowCheck.my_user.follows.length).toBeGreaterThanOrEqual(1);
47 });