2020-09-15 19:26:47 +00:00
|
|
|
jest.setTimeout(120000);
|
2022-06-22 12:05:41 +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-06-22 19:38:27 +00:00
|
|
|
delay,
|
2020-08-04 14:57:37 +00:00
|
|
|
} from './shared';
|
|
|
|
|
|
|
|
beforeAll(async () => {
|
|
|
|
await setupLogins();
|
|
|
|
});
|
|
|
|
|
|
|
|
afterAll(async () => {
|
|
|
|
await unfollowRemotes(alpha);
|
|
|
|
});
|
|
|
|
|
|
|
|
test('Follow federated community', async () => {
|
2022-07-30 03:55:59 +00:00
|
|
|
let betaCommunity = (await resolveBetaCommunity(alpha)).community.unwrap();
|
2020-12-20 21:16:57 +00:00
|
|
|
let follow = await followCommunity(
|
|
|
|
alpha,
|
|
|
|
true,
|
2021-08-23 15:25:39 +00:00
|
|
|
betaCommunity.community.id
|
2020-12-20 21:16:57 +00:00
|
|
|
);
|
2020-08-04 14:57:37 +00:00
|
|
|
|
|
|
|
// Make sure the follow response went through
|
2022-05-26 15:17:04 +00:00
|
|
|
expect(follow.community_view.community.local).toBe(false);
|
|
|
|
expect(follow.community_view.community.name).toBe('main');
|
2022-07-20 14:10:29 +00:00
|
|
|
expect(follow.community_view.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-07-30 03:55:59 +00:00
|
|
|
let remoteCommunityId = site.my_user.unwrap().follows.find(
|
2020-12-20 21:16:57 +00:00
|
|
|
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
|
|
|
});
|