]> Untitled Git - lemmy.git/blob - ui/src/api_tests/follow.spec.ts
routes.api: fix get_captcha endpoint (#1135)
[lemmy.git] / ui / src / api_tests / follow.spec.ts
1 import {
2   alpha,
3   setupLogins,
4   searchForBetaCommunity,
5   followCommunity,
6   checkFollowedCommunities,
7   unfollowRemotes,
8   delay,
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   await delay();
27
28   // Check it from local
29   let followCheck = await checkFollowedCommunities(alpha);
30   let remoteCommunityId = followCheck.communities.filter(
31     c => c.community_local == false
32   )[0].community_id;
33   expect(remoteCommunityId).toBeDefined();
34
35   // Test an unfollow
36   let unfollow = await followCommunity(alpha, false, remoteCommunityId);
37   expect(unfollow.community.local).toBe(false);
38   await delay();
39
40   // Make sure you are unsubbed locally
41   let unfollowCheck = await checkFollowedCommunities(alpha);
42   expect(unfollowCheck.communities.length).toBeGreaterThanOrEqual(1);
43 });