2020-09-15 19:26:47 +00:00
|
|
|
jest.setTimeout(120000);
|
2022-10-27 09:24:07 +00:00
|
|
|
import { SubscribedType } from "lemmy-js-client";
|
|
|
|
|
2020-08-04 14:57:37 +00:00
|
|
|
import {
|
|
|
|
alpha,
|
|
|
|
setupLogins,
|
2021-08-23 15:25:39 +00:00
|
|
|
resolveBetaCommunity,
|
2020-08-04 14:57:37 +00:00
|
|
|
followCommunity,
|
|
|
|
unfollowRemotes,
|
2021-08-19 20:54:15 +00:00
|
|
|
getSite,
|
2022-10-27 09:24:07 +00:00
|
|
|
} from "./shared";
|
2020-08-04 14:57:37 +00:00
|
|
|
|
|
|
|
beforeAll(async () => {
|
|
|
|
await setupLogins();
|
|
|
|
});
|
|
|
|
|
|
|
|
afterAll(async () => {
|
|
|
|
await unfollowRemotes(alpha);
|
|
|
|
});
|
|
|
|
|
2022-10-27 09:24:07 +00:00
|
|
|
test("Follow federated community", async () => {
|
2022-07-30 03:55:59 +00:00
|
|
|
let betaCommunity = (await resolveBetaCommunity(alpha)).community.unwrap();
|
2022-11-28 14:29:33 +00:00
|
|
|
await followCommunity(alpha, true, betaCommunity.community.id);
|
|
|
|
betaCommunity = (await resolveBetaCommunity(alpha)).community.unwrap();
|
2020-08-04 14:57:37 +00:00
|
|
|
|
|
|
|
// Make sure the follow response went through
|
2022-11-28 14:29:33 +00:00
|
|
|
expect(betaCommunity.community.local).toBe(false);
|
|
|
|
expect(betaCommunity.community.name).toBe("main");
|
|
|
|
expect(betaCommunity.subscribed).toBe(SubscribedType.Subscribed);
|
2020-08-04 14:57:37 +00:00
|
|
|
|
|
|
|
// Check it from local
|
2021-08-19 20:54:15 +00:00
|
|
|
let site = await getSite(alpha);
|
2022-10-27 09:24:07 +00:00
|
|
|
let remoteCommunityId = site.my_user
|
|
|
|
.unwrap()
|
|
|
|
.follows.find(c => c.community.local == false).community.id;
|
2020-08-04 14:57:37 +00:00
|
|
|
expect(remoteCommunityId).toBeDefined();
|
2022-10-13 16:30:31 +00:00
|
|
|
expect(site.my_user.unwrap().follows.length).toBe(2);
|
2020-08-04 14:57:37 +00:00
|
|
|
|
|
|
|
// Test an unfollow
|
|
|
|
let unfollow = await followCommunity(alpha, false, remoteCommunityId);
|
2022-06-22 12:05:41 +00:00
|
|
|
expect(unfollow.community_view.subscribed).toBe(SubscribedType.NotSubscribed);
|
2020-08-04 14:57:37 +00:00
|
|
|
|
|
|
|
// Make sure you are unsubbed locally
|
2021-08-19 20:54:15 +00:00
|
|
|
let siteUnfollowCheck = await getSite(alpha);
|
2022-10-13 16:30:31 +00:00
|
|
|
expect(siteUnfollowCheck.my_user.unwrap().follows.length).toBe(1);
|
2020-08-04 14:57:37 +00:00
|
|
|
});
|