]> Untitled Git - lemmy.git/blob - api_tests/src/follow.spec.ts
Don't create or initially follow a default community. Fixes #2317 (#2328)
[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   delay,
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 betaCommunity = (await resolveBetaCommunity(alpha)).community;
23   let follow = await followCommunity(
24     alpha,
25     true,
26     betaCommunity.community.id
27   );
28
29   // Wait for it to accept on the alpha side ( follows are async )
30   await delay();
31
32   // Make sure the follow response went through
33   expect(follow.community_view.community.local).toBe(false);
34   expect(follow.community_view.community.name).toBe('main');
35   expect(follow.community_view.subscribed).toBe(SubscribedType.Pending);
36
37   // Check it from local
38   let site = await getSite(alpha);
39   let remoteCommunityId = site.my_user.follows.find(
40     c => c.community.local == false
41   ).community.id;
42   expect(remoteCommunityId).toBeDefined();
43   expect(site.my_user.follows.length).toBe(1);
44
45   // Test an unfollow
46   let unfollow = await followCommunity(alpha, false, remoteCommunityId);
47   expect(unfollow.community_view.subscribed).toBe(SubscribedType.NotSubscribed);
48
49   // Make sure you are unsubbed locally
50   let siteUnfollowCheck = await getSite(alpha);
51   expect(siteUnfollowCheck.my_user.follows.length).toBe(0);
52 });