]> Untitled Git - lemmy.git/blob - api_tests/src/follow.spec.ts
Fixing drone tests.
[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(alpha, true, search.communities[0].id);
22
23   // Make sure the follow response went through
24   expect(follow.community.local).toBe(false);
25   expect(follow.community.name).toBe('main');
26
27   // Check it from local
28   let followCheck = await checkFollowedCommunities(alpha);
29   let remoteCommunityId = followCheck.communities.filter(
30     c => c.community_local == false
31   )[0].community_id;
32   expect(remoteCommunityId).toBeDefined();
33
34   // Test an unfollow
35   let unfollow = await followCommunity(alpha, false, remoteCommunityId);
36   expect(unfollow.community.local).toBe(false);
37
38   // Make sure you are unsubbed locally
39   let unfollowCheck = await checkFollowedCommunities(alpha);
40   expect(unfollowCheck.communities.length).toBeGreaterThanOrEqual(1);
41 });