]> Untitled Git - lemmy.git/blob - api_tests/src/follow.spec.ts
Check user accepted before sending jwt in password reset (fixes #2591) (#2597)
[lemmy.git] / api_tests / src / follow.spec.ts
1 jest.setTimeout(120000);
2 import { SubscribedType } from "lemmy-js-client";
3
4 import {
5   alpha,
6   setupLogins,
7   resolveBetaCommunity,
8   followCommunity,
9   unfollowRemotes,
10   getSite,
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.unwrap();
23   let follow = await followCommunity(alpha, true, betaCommunity.community.id);
24
25   // Make sure the follow response went through
26   expect(follow.community_view.community.local).toBe(false);
27   expect(follow.community_view.community.name).toBe("main");
28   expect(follow.community_view.subscribed).toBe(SubscribedType.Subscribed);
29
30   // Check it from local
31   let site = await getSite(alpha);
32   let remoteCommunityId = site.my_user
33     .unwrap()
34     .follows.find(c => c.community.local == false).community.id;
35   expect(remoteCommunityId).toBeDefined();
36   expect(site.my_user.unwrap().follows.length).toBe(2);
37
38   // Test an unfollow
39   let unfollow = await followCommunity(alpha, false, remoteCommunityId);
40   expect(unfollow.community_view.subscribed).toBe(SubscribedType.NotSubscribed);
41
42   // Make sure you are unsubbed locally
43   let siteUnfollowCheck = await getSite(alpha);
44   expect(siteUnfollowCheck.my_user.unwrap().follows.length).toBe(1);
45 });