2020-09-15 19:26:47 +00:00
|
|
|
jest.setTimeout(120000);
|
2022-10-27 09:24:07 +00:00
|
|
|
|
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,
|
2023-09-09 16:25:03 +00:00
|
|
|
waitUntil,
|
2022-10-27 09:24:07 +00:00
|
|
|
} from "./shared";
|
2020-08-04 14:57:37 +00:00
|
|
|
|
2023-11-17 04:43:40 +00:00
|
|
|
beforeAll(setupLogins);
|
2020-08-04 14:57:37 +00:00
|
|
|
|
2023-11-17 04:43:40 +00:00
|
|
|
afterAll(() => {
|
|
|
|
unfollowRemotes(alpha);
|
2020-08-04 14:57:37 +00:00
|
|
|
});
|
|
|
|
|
2022-10-27 09:24:07 +00:00
|
|
|
test("Follow federated community", async () => {
|
2023-01-04 15:59:26 +00:00
|
|
|
let betaCommunity = (await resolveBetaCommunity(alpha)).community;
|
|
|
|
if (!betaCommunity) {
|
|
|
|
throw "Missing beta community";
|
|
|
|
}
|
2022-11-28 14:29:33 +00:00
|
|
|
await followCommunity(alpha, true, betaCommunity.community.id);
|
2023-09-09 16:25:03 +00:00
|
|
|
betaCommunity = (
|
|
|
|
await waitUntil(
|
|
|
|
() => resolveBetaCommunity(alpha),
|
|
|
|
c => c.community?.subscribed === "Subscribed",
|
|
|
|
)
|
|
|
|
).community;
|
2020-08-04 14:57:37 +00:00
|
|
|
|
|
|
|
// Make sure the follow response went through
|
2023-01-04 15:59:26 +00:00
|
|
|
expect(betaCommunity?.community.local).toBe(false);
|
|
|
|
expect(betaCommunity?.community.name).toBe("main");
|
2023-04-26 04:26:10 +00:00
|
|
|
expect(betaCommunity?.subscribed).toBe("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);
|
2023-01-04 15:59:26 +00:00
|
|
|
let remoteCommunityId = site.my_user?.follows.find(
|
2023-07-06 13:10:38 +00:00
|
|
|
c => c.community.local == false,
|
2023-01-04 15:59:26 +00:00
|
|
|
)?.community.id;
|
2020-08-04 14:57:37 +00:00
|
|
|
expect(remoteCommunityId).toBeDefined();
|
2023-01-04 15:59:26 +00:00
|
|
|
expect(site.my_user?.follows.length).toBe(2);
|
|
|
|
|
|
|
|
if (!remoteCommunityId) {
|
|
|
|
throw "Missing remote community id";
|
|
|
|
}
|
2020-08-04 14:57:37 +00:00
|
|
|
|
|
|
|
// Test an unfollow
|
|
|
|
let unfollow = await followCommunity(alpha, false, remoteCommunityId);
|
2023-04-26 04:26:10 +00:00
|
|
|
expect(unfollow.community_view.subscribed).toBe("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);
|
2023-01-04 15:59:26 +00:00
|
|
|
expect(siteUnfollowCheck.my_user?.follows.length).toBe(1);
|
2020-08-04 14:57:37 +00:00
|
|
|
});
|