mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-11-22 20:31:19 +00:00
fmt
This commit is contained in:
parent
0f7c9a6586
commit
ce013f9904
1 changed files with 38 additions and 33 deletions
|
@ -1,6 +1,6 @@
|
||||||
jest.setTimeout(120000);
|
jest.setTimeout(120000);
|
||||||
|
|
||||||
import { FollowCommunity } from "lemmy-js-client";
|
import { FollowCommunity, LemmyHttp } from "lemmy-js-client";
|
||||||
import {
|
import {
|
||||||
alpha,
|
alpha,
|
||||||
setupLogins,
|
setupLogins,
|
||||||
|
@ -50,7 +50,7 @@ test("Follow a private community", async () => {
|
||||||
await resolveCommunity(user, community.community_view.community.actor_id)
|
await resolveCommunity(user, community.community_view.community.actor_id)
|
||||||
).community;
|
).community;
|
||||||
expect(betaCommunity).toBeDefined();
|
expect(betaCommunity).toBeDefined();
|
||||||
expect(betaCommunity?.community.visibility).toBe('Private');
|
expect(betaCommunity?.community.visibility).toBe("Private");
|
||||||
const betaCommunityId = betaCommunity!.community.id;
|
const betaCommunityId = betaCommunity!.community.id;
|
||||||
const follow_form: FollowCommunity = {
|
const follow_form: FollowCommunity = {
|
||||||
community_id: betaCommunityId,
|
community_id: betaCommunityId,
|
||||||
|
@ -224,9 +224,8 @@ test("Follow a private community and receive activities", async () => {
|
||||||
const alphaCommunityId = community.community_view.community.id;
|
const alphaCommunityId = community.community_view.community.id;
|
||||||
|
|
||||||
// follow with users from beta and gamma
|
// follow with users from beta and gamma
|
||||||
const user = await registerUser(beta, betaUrl);
|
|
||||||
const betaCommunity = (
|
const betaCommunity = (
|
||||||
await resolveCommunity(user, community.community_view.community.actor_id)
|
await resolveCommunity(beta, community.community_view.community.actor_id)
|
||||||
).community;
|
).community;
|
||||||
expect(betaCommunity).toBeDefined();
|
expect(betaCommunity).toBeDefined();
|
||||||
const betaCommunityId = betaCommunity!.community.id;
|
const betaCommunityId = betaCommunity!.community.id;
|
||||||
|
@ -234,7 +233,8 @@ test("Follow a private community and receive activities", async () => {
|
||||||
community_id: betaCommunityId,
|
community_id: betaCommunityId,
|
||||||
follow: true,
|
follow: true,
|
||||||
};
|
};
|
||||||
await user.followCommunity(follow_form_beta);
|
await beta.followCommunity(follow_form_beta);
|
||||||
|
await approveFollower(alpha, alphaCommunityId);
|
||||||
|
|
||||||
const gammaCommunityId = (
|
const gammaCommunityId = (
|
||||||
await resolveCommunity(gamma, community.community_view.community.actor_id)
|
await resolveCommunity(gamma, community.community_view.community.actor_id)
|
||||||
|
@ -244,31 +244,11 @@ test("Follow a private community and receive activities", async () => {
|
||||||
follow: true,
|
follow: true,
|
||||||
};
|
};
|
||||||
await gamma.followCommunity(follow_form_gamma);
|
await gamma.followCommunity(follow_form_gamma);
|
||||||
|
await approveFollower(alpha, alphaCommunityId);
|
||||||
|
|
||||||
// Wait for follow to federate, shown as pending
|
|
||||||
let pendingFollows1 = await waitUntil(
|
|
||||||
() => listCommunityPendingFollows(alpha),
|
|
||||||
f => f.items.length == 2,
|
|
||||||
);
|
|
||||||
|
|
||||||
// Approve the follow
|
|
||||||
const approve1 = await approveCommunityPendingFollow(
|
|
||||||
alpha,
|
|
||||||
alphaCommunityId,
|
|
||||||
pendingFollows1.items[0].person.id,
|
|
||||||
);
|
|
||||||
expect(approve1.success).toBe(true);
|
|
||||||
const approve2 = await approveCommunityPendingFollow(
|
|
||||||
alpha,
|
|
||||||
alphaCommunityId,
|
|
||||||
pendingFollows1.items[1].person.id,
|
|
||||||
);
|
|
||||||
expect(approve2.success).toBe(true);
|
|
||||||
|
|
||||||
// Follow is confirmed
|
|
||||||
// Follow is confirmed
|
// Follow is confirmed
|
||||||
await waitUntil(
|
await waitUntil(
|
||||||
() => getCommunity(user, betaCommunityId),
|
() => getCommunity(beta, betaCommunityId),
|
||||||
c => c.community_view.subscribed == "Subscribed",
|
c => c.community_view.subscribed == "Subscribed",
|
||||||
);
|
);
|
||||||
await waitUntil(
|
await waitUntil(
|
||||||
|
@ -286,17 +266,21 @@ test("Follow a private community and receive activities", async () => {
|
||||||
|
|
||||||
// post and comment were federated to beta
|
// post and comment were federated to beta
|
||||||
let posts = await waitUntil(
|
let posts = await waitUntil(
|
||||||
() => getPosts(user, 'All', betaCommunityId),
|
() => getPosts(beta, "All", betaCommunityId),
|
||||||
c => c.posts.length == 1,
|
c => c.posts.length == 1,
|
||||||
);
|
);
|
||||||
expect(posts.posts[0].post.ap_id).toBe(post.post_view.post.ap_id);
|
expect(posts.posts[0].post.ap_id).toBe(post.post_view.post.ap_id);
|
||||||
expect(posts.posts[0].post.name).toBe(post.post_view.post.name);
|
expect(posts.posts[0].post.name).toBe(post.post_view.post.name);
|
||||||
let comments = await waitUntil(
|
let comments = await waitUntil(
|
||||||
() => getComments(user, posts.posts[0].post.id),
|
() => getComments(beta, posts.posts[0].post.id),
|
||||||
c => c.comments.length == 1,
|
c => c.comments.length == 1,
|
||||||
);
|
);
|
||||||
expect(comments.comments[0].comment.ap_id).toBe(comment.comment_view.comment.ap_id);
|
expect(comments.comments[0].comment.ap_id).toBe(
|
||||||
expect(comments.comments[0].comment.content).toBe(comment.comment_view.comment.content);
|
comment.comment_view.comment.ap_id,
|
||||||
|
);
|
||||||
|
expect(comments.comments[0].comment.content).toBe(
|
||||||
|
comment.comment_view.comment.content,
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("Fetch remote content in private community", async () => {
|
test("Fetch remote content in private community", async () => {
|
||||||
|
@ -305,10 +289,16 @@ test("Fetch remote content in private community", async () => {
|
||||||
expect(community.community_view.community.visibility).toBe("Private");
|
expect(community.community_view.community.visibility).toBe("Private");
|
||||||
const alphaCommunityId = community.community_view.community.id;
|
const alphaCommunityId = community.community_view.community.id;
|
||||||
|
|
||||||
// create post and comment
|
|
||||||
const betaCommunityId = (
|
const betaCommunityId = (
|
||||||
await resolveCommunity(beta, community.community_view.community.actor_id)
|
await resolveCommunity(beta, community.community_view.community.actor_id)
|
||||||
).community!.community.id;
|
).community!.community.id;
|
||||||
|
const follow_form_beta: FollowCommunity = {
|
||||||
|
community_id: betaCommunityId,
|
||||||
|
follow: true,
|
||||||
|
};
|
||||||
|
await beta.followCommunity(follow_form_beta);
|
||||||
|
|
||||||
|
// beta creates post and comment
|
||||||
const post = await createPost(beta, betaCommunityId);
|
const post = await createPost(beta, betaCommunityId);
|
||||||
const post_id = post.post_view.post.id;
|
const post_id = post.post_view.post.id;
|
||||||
expect(post_id).toBeDefined();
|
expect(post_id).toBeDefined();
|
||||||
|
@ -316,7 +306,7 @@ test("Fetch remote content in private community", async () => {
|
||||||
const comment_id = comment.comment_view.comment.id;
|
const comment_id = comment.comment_view.comment.id;
|
||||||
expect(comment_id).toBeDefined();
|
expect(comment_id).toBeDefined();
|
||||||
|
|
||||||
// user is not following the community and cannot view nor create posts
|
// gamma is not following the community and cannot view nor create posts
|
||||||
const user = await registerUser(gamma, betaUrl);
|
const user = await registerUser(gamma, betaUrl);
|
||||||
const gammaCommunityId = (
|
const gammaCommunityId = (
|
||||||
await resolveCommunity(user, community.community_view.community.actor_id)
|
await resolveCommunity(user, community.community_view.community.actor_id)
|
||||||
|
@ -340,12 +330,27 @@ test("Fetch remote content in private community", async () => {
|
||||||
expect(approve.success).toBe(true);
|
expect(approve.success).toBe(true);
|
||||||
|
|
||||||
// now user can fetch posts and comments in community (using signed fetch), and create posts
|
// now user can fetch posts and comments in community (using signed fetch), and create posts
|
||||||
|
console.log(1);
|
||||||
await waitUntil(
|
await waitUntil(
|
||||||
() => resolvePost(user, post.post_view.post),
|
() => resolvePost(user, post.post_view.post),
|
||||||
p => p?.post?.post.id != undefined,
|
p => p?.post?.post.id != undefined,
|
||||||
);
|
);
|
||||||
|
console.log(2);
|
||||||
const resolvedComment = (
|
const resolvedComment = (
|
||||||
await resolveComment(user, comment.comment_view.comment)
|
await resolveComment(user, comment.comment_view.comment)
|
||||||
).comment;
|
).comment;
|
||||||
expect(resolvedComment?.comment.id).toBeDefined();
|
expect(resolvedComment?.comment.id).toBeDefined();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
async function approveFollower(user: LemmyHttp, community_id: number) {
|
||||||
|
let pendingFollows1 = await waitUntil(
|
||||||
|
() => listCommunityPendingFollows(user),
|
||||||
|
f => f.items.length == 1,
|
||||||
|
);
|
||||||
|
const approve = await approveCommunityPendingFollow(
|
||||||
|
alpha,
|
||||||
|
community_id,
|
||||||
|
pendingFollows1.items[0].person.id,
|
||||||
|
);
|
||||||
|
expect(approve.success).toBe(true);
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue