mirror of
https://github.com/LemmyNet/lemmy
synced 2024-11-10 06:54:12 +00:00
Removing sniptt/monads for lemmy-js-client. (#2644)
* Removing sniptt/monads for lemmy-js-client. * Fix tests.
This commit is contained in:
parent
b7d5b37ac9
commit
0630d214e3
12 changed files with 564 additions and 649 deletions
|
@ -16,14 +16,9 @@
|
|||
"warnOnUnsupportedTypeScriptVersion": false
|
||||
},
|
||||
"rules": {
|
||||
"@typescript-eslint/camelcase": 0,
|
||||
"@typescript-eslint/member-delimiter-style": 0,
|
||||
"@typescript-eslint/no-empty-interface": 0,
|
||||
"@typescript-eslint/ban-ts-comment": 0,
|
||||
"@typescript-eslint/no-explicit-any": 0,
|
||||
"@typescript-eslint/no-this-alias": 0,
|
||||
"@typescript-eslint/no-unused-vars": 0,
|
||||
"@typescript-eslint/no-use-before-define": 0,
|
||||
"@typescript-eslint/no-useless-constructor": 0,
|
||||
"@typescript-eslint/explicit-module-boundary-types": 0,
|
||||
"arrow-body-style": 0,
|
||||
"curly": 0,
|
||||
"eol-last": 0,
|
||||
|
|
|
@ -1,4 +0,0 @@
|
|||
module.exports = Object.assign(require("eslint-plugin-prettier"), {
|
||||
arrowParens: "avoid",
|
||||
semi: true,
|
||||
});
|
4
api_tests/.prettierrc.json
Normal file
4
api_tests/.prettierrc.json
Normal file
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"arrowParens": "avoid",
|
||||
"semi": true
|
||||
}
|
|
@ -7,23 +7,20 @@
|
|||
"author": "Dessalines",
|
||||
"license": "AGPL-3.0",
|
||||
"scripts": {
|
||||
"lint": "tsc --noEmit && eslint --report-unused-disable-directives --ext .js,.ts,.tsx src",
|
||||
"lint": "tsc --noEmit && eslint --report-unused-disable-directives --ext .js,.ts,.tsx src && prettier --check 'src/**/*.ts'",
|
||||
"fix": "prettier --write src && eslint --fix src",
|
||||
"api-test": "jest -i follow.spec.ts && jest -i src/post.spec.ts && jest -i comment.spec.ts && jest -i private_message.spec.ts && jest -i user.spec.ts && jest -i community.spec.ts"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@sniptt/monads": "^0.5.10",
|
||||
"@types/jest": "^26.0.23",
|
||||
"@typescript-eslint/eslint-plugin": "^5.21.0",
|
||||
"@typescript-eslint/parser": "^5.21.0",
|
||||
"class-transformer": "^0.5.1",
|
||||
"eslint": "^8.25.0",
|
||||
"eslint-plugin-prettier": "^4.0.0",
|
||||
"jest": "^27.0.6",
|
||||
"lemmy-js-client": "0.17.0-rc.56",
|
||||
"lemmy-js-client": "0.17.0-rc.60",
|
||||
"node-fetch": "^2.6.1",
|
||||
"prettier": "^2.7.1",
|
||||
"reflect-metadata": "^0.1.13",
|
||||
"ts-jest": "^27.0.3",
|
||||
"typescript": "^4.8.4"
|
||||
}
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
jest.setTimeout(180000);
|
||||
import { None, Some } from "@sniptt/monads";
|
||||
import { CommentView } from "lemmy-js-client";
|
||||
import { PostResponse } from "lemmy-js-client";
|
||||
|
||||
|
@ -41,7 +40,9 @@ beforeAll(async () => {
|
|||
await followBeta(alpha);
|
||||
await followBeta(gamma);
|
||||
let betaCommunity = (await resolveBetaCommunity(alpha)).community;
|
||||
postRes = await createPost(alpha, betaCommunity.unwrap().community.id);
|
||||
if (betaCommunity) {
|
||||
postRes = await createPost(alpha, betaCommunity.community.id);
|
||||
}
|
||||
});
|
||||
|
||||
afterAll(async () => {
|
||||
|
@ -49,21 +50,21 @@ afterAll(async () => {
|
|||
});
|
||||
|
||||
function assertCommentFederation(
|
||||
commentOne: CommentView,
|
||||
commentTwo: CommentView
|
||||
commentOne?: CommentView,
|
||||
commentTwo?: CommentView
|
||||
) {
|
||||
expect(commentOne.comment.ap_id).toBe(commentOne.comment.ap_id);
|
||||
expect(commentOne.comment.content).toBe(commentTwo.comment.content);
|
||||
expect(commentOne.creator.name).toBe(commentTwo.creator.name);
|
||||
expect(commentOne.community.actor_id).toBe(commentTwo.community.actor_id);
|
||||
expect(commentOne.comment.published).toBe(commentTwo.comment.published);
|
||||
expect(commentOne.comment.updated).toBe(commentOne.comment.updated);
|
||||
expect(commentOne.comment.deleted).toBe(commentOne.comment.deleted);
|
||||
expect(commentOne.comment.removed).toBe(commentOne.comment.removed);
|
||||
expect(commentOne?.comment.ap_id).toBe(commentTwo?.comment.ap_id);
|
||||
expect(commentOne?.comment.content).toBe(commentTwo?.comment.content);
|
||||
expect(commentOne?.creator.name).toBe(commentTwo?.creator.name);
|
||||
expect(commentOne?.community.actor_id).toBe(commentTwo?.community.actor_id);
|
||||
expect(commentOne?.comment.published).toBe(commentTwo?.comment.published);
|
||||
expect(commentOne?.comment.updated).toBe(commentOne?.comment.updated);
|
||||
expect(commentOne?.comment.deleted).toBe(commentOne?.comment.deleted);
|
||||
expect(commentOne?.comment.removed).toBe(commentOne?.comment.removed);
|
||||
}
|
||||
|
||||
test("Create a comment", async () => {
|
||||
let commentRes = await createComment(alpha, postRes.post_view.post.id, None);
|
||||
let commentRes = await createComment(alpha, postRes.post_view.post.id);
|
||||
expect(commentRes.comment_view.comment.content).toBeDefined();
|
||||
expect(commentRes.comment_view.community.local).toBe(false);
|
||||
expect(commentRes.comment_view.creator.local).toBe(true);
|
||||
|
@ -72,26 +73,26 @@ test("Create a comment", async () => {
|
|||
// Make sure that comment is liked on beta
|
||||
let betaComment = (
|
||||
await resolveComment(beta, commentRes.comment_view.comment)
|
||||
).comment.unwrap();
|
||||
).comment;
|
||||
expect(betaComment).toBeDefined();
|
||||
expect(betaComment.community.local).toBe(true);
|
||||
expect(betaComment.creator.local).toBe(false);
|
||||
expect(betaComment.counts.score).toBe(1);
|
||||
expect(betaComment?.community.local).toBe(true);
|
||||
expect(betaComment?.creator.local).toBe(false);
|
||||
expect(betaComment?.counts.score).toBe(1);
|
||||
assertCommentFederation(betaComment, commentRes.comment_view);
|
||||
});
|
||||
|
||||
test("Create a comment in a non-existent post", async () => {
|
||||
let commentRes = (await createComment(alpha, -1, None)) as any;
|
||||
let commentRes = (await createComment(alpha, -1)) as any;
|
||||
expect(commentRes.error).toBe("couldnt_find_post");
|
||||
});
|
||||
|
||||
test("Update a comment", async () => {
|
||||
let commentRes = await createComment(alpha, postRes.post_view.post.id, None);
|
||||
let commentRes = await createComment(alpha, postRes.post_view.post.id);
|
||||
// Federate the comment first
|
||||
let betaComment = (
|
||||
await resolveComment(beta, commentRes.comment_view.comment)
|
||||
).comment;
|
||||
assertCommentFederation(betaComment.unwrap(), commentRes.comment_view);
|
||||
assertCommentFederation(betaComment, commentRes.comment_view);
|
||||
|
||||
let updateCommentRes = await editComment(
|
||||
alpha,
|
||||
|
@ -106,12 +107,12 @@ test("Update a comment", async () => {
|
|||
// Make sure that post is updated on beta
|
||||
let betaCommentUpdated = (
|
||||
await resolveComment(beta, commentRes.comment_view.comment)
|
||||
).comment.unwrap();
|
||||
).comment;
|
||||
assertCommentFederation(betaCommentUpdated, updateCommentRes.comment_view);
|
||||
});
|
||||
|
||||
test("Delete a comment", async () => {
|
||||
let commentRes = await createComment(alpha, postRes.post_view.post.id, None);
|
||||
let commentRes = await createComment(alpha, postRes.post_view.post.id);
|
||||
|
||||
let deleteCommentRes = await deleteComment(
|
||||
alpha,
|
||||
|
@ -138,18 +139,22 @@ test("Delete a comment", async () => {
|
|||
// Make sure that comment is undeleted on beta
|
||||
let betaComment2 = (
|
||||
await resolveComment(beta, commentRes.comment_view.comment)
|
||||
).comment.unwrap();
|
||||
expect(betaComment2.comment.deleted).toBe(false);
|
||||
).comment;
|
||||
expect(betaComment2?.comment.deleted).toBe(false);
|
||||
assertCommentFederation(betaComment2, undeleteCommentRes.comment_view);
|
||||
});
|
||||
|
||||
test("Remove a comment from admin and community on the same instance", async () => {
|
||||
let commentRes = await createComment(alpha, postRes.post_view.post.id, None);
|
||||
let commentRes = await createComment(alpha, postRes.post_view.post.id);
|
||||
|
||||
// Get the id for beta
|
||||
let betaCommentId = (
|
||||
await resolveComment(beta, commentRes.comment_view.comment)
|
||||
).comment.unwrap().comment.id;
|
||||
).comment?.comment.id;
|
||||
|
||||
if (!betaCommentId) {
|
||||
throw "beta comment id is missing";
|
||||
}
|
||||
|
||||
// The beta admin removes it (the community lives on beta)
|
||||
let removeCommentRes = await removeComment(beta, true, betaCommentId);
|
||||
|
@ -182,7 +187,7 @@ test("Remove a comment from admin and community on different instance", async ()
|
|||
let alpha_user = await registerUser(alpha);
|
||||
let newAlphaApi: API = {
|
||||
client: alpha.client,
|
||||
auth: alpha_user.jwt,
|
||||
auth: alpha_user.jwt ?? "",
|
||||
};
|
||||
|
||||
// New alpha user creates a community, post, and comment.
|
||||
|
@ -191,17 +196,18 @@ test("Remove a comment from admin and community on different instance", async ()
|
|||
newAlphaApi,
|
||||
newCommunity.community_view.community.id
|
||||
);
|
||||
let commentRes = await createComment(
|
||||
newAlphaApi,
|
||||
newPost.post_view.post.id,
|
||||
None
|
||||
);
|
||||
let commentRes = await createComment(newAlphaApi, newPost.post_view.post.id);
|
||||
expect(commentRes.comment_view.comment.content).toBeDefined();
|
||||
|
||||
// Beta searches that to cache it, then removes it
|
||||
let betaComment = (
|
||||
await resolveComment(beta, commentRes.comment_view.comment)
|
||||
).comment.unwrap();
|
||||
).comment;
|
||||
|
||||
if (!betaComment) {
|
||||
throw "beta comment missing";
|
||||
}
|
||||
|
||||
let removeCommentRes = await removeComment(
|
||||
beta,
|
||||
true,
|
||||
|
@ -222,27 +228,31 @@ test("Remove a comment from admin and community on different instance", async ()
|
|||
});
|
||||
|
||||
test("Unlike a comment", async () => {
|
||||
let commentRes = await createComment(alpha, postRes.post_view.post.id, None);
|
||||
let commentRes = await createComment(alpha, postRes.post_view.post.id);
|
||||
let unlike = await likeComment(alpha, 0, commentRes.comment_view.comment);
|
||||
expect(unlike.comment_view.counts.score).toBe(0);
|
||||
|
||||
// Make sure that post is unliked on beta
|
||||
let betaComment = (
|
||||
await resolveComment(beta, commentRes.comment_view.comment)
|
||||
).comment.unwrap();
|
||||
).comment;
|
||||
expect(betaComment).toBeDefined();
|
||||
expect(betaComment.community.local).toBe(true);
|
||||
expect(betaComment.creator.local).toBe(false);
|
||||
expect(betaComment.counts.score).toBe(0);
|
||||
expect(betaComment?.community.local).toBe(true);
|
||||
expect(betaComment?.creator.local).toBe(false);
|
||||
expect(betaComment?.counts.score).toBe(0);
|
||||
});
|
||||
|
||||
test("Federated comment like", async () => {
|
||||
let commentRes = await createComment(alpha, postRes.post_view.post.id, None);
|
||||
let commentRes = await createComment(alpha, postRes.post_view.post.id);
|
||||
|
||||
// Find the comment on beta
|
||||
let betaComment = (
|
||||
await resolveComment(beta, commentRes.comment_view.comment)
|
||||
).comment.unwrap();
|
||||
).comment;
|
||||
|
||||
if (!betaComment) {
|
||||
throw "Missing beta comment";
|
||||
}
|
||||
|
||||
let like = await likeComment(beta, 1, betaComment.comment);
|
||||
expect(like.comment_view.counts.score).toBe(2);
|
||||
|
@ -254,10 +264,14 @@ test("Federated comment like", async () => {
|
|||
|
||||
test("Reply to a comment", async () => {
|
||||
// Create a comment on alpha, find it on beta
|
||||
let commentRes = await createComment(alpha, postRes.post_view.post.id, None);
|
||||
let commentRes = await createComment(alpha, postRes.post_view.post.id);
|
||||
let betaComment = (
|
||||
await resolveComment(beta, commentRes.comment_view.comment)
|
||||
).comment.unwrap();
|
||||
).comment;
|
||||
|
||||
if (!betaComment) {
|
||||
throw "Missing beta comment";
|
||||
}
|
||||
|
||||
// find that comment id on beta
|
||||
|
||||
|
@ -265,12 +279,12 @@ test("Reply to a comment", async () => {
|
|||
let replyRes = await createComment(
|
||||
beta,
|
||||
betaComment.post.id,
|
||||
Some(betaComment.comment.id)
|
||||
betaComment.comment.id
|
||||
);
|
||||
expect(replyRes.comment_view.comment.content).toBeDefined();
|
||||
expect(replyRes.comment_view.community.local).toBe(true);
|
||||
expect(replyRes.comment_view.creator.local).toBe(true);
|
||||
expect(getCommentParentId(replyRes.comment_view.comment).unwrap()).toBe(
|
||||
expect(getCommentParentId(replyRes.comment_view.comment)).toBe(
|
||||
betaComment.comment.id
|
||||
);
|
||||
expect(replyRes.comment_view.counts.score).toBe(1);
|
||||
|
@ -282,7 +296,7 @@ test("Reply to a comment", async () => {
|
|||
let postComments = await getComments(alpha, postRes.post_view.post.id);
|
||||
let alphaComment = postComments.comments[0];
|
||||
expect(alphaComment.comment.content).toBeDefined();
|
||||
expect(getCommentParentId(alphaComment.comment).unwrap()).toBe(
|
||||
expect(getCommentParentId(alphaComment.comment)).toBe(
|
||||
postComments.comments[1].comment.id
|
||||
);
|
||||
expect(alphaComment.community.local).toBe(false);
|
||||
|
@ -294,11 +308,11 @@ test("Reply to a comment", async () => {
|
|||
test("Mention beta", async () => {
|
||||
// Create a mention on alpha
|
||||
let mentionContent = "A test mention of @lemmy_beta@lemmy-beta:8551";
|
||||
let commentRes = await createComment(alpha, postRes.post_view.post.id, None);
|
||||
let commentRes = await createComment(alpha, postRes.post_view.post.id);
|
||||
let mentionRes = await createComment(
|
||||
alpha,
|
||||
postRes.post_view.post.id,
|
||||
Some(commentRes.comment_view.comment.id),
|
||||
commentRes.comment_view.comment.id,
|
||||
mentionContent
|
||||
);
|
||||
expect(mentionRes.comment_view.comment.content).toBeDefined();
|
||||
|
@ -314,32 +328,38 @@ test("Mention beta", async () => {
|
|||
});
|
||||
|
||||
test("Comment Search", async () => {
|
||||
let commentRes = await createComment(alpha, postRes.post_view.post.id, None);
|
||||
let commentRes = await createComment(alpha, postRes.post_view.post.id);
|
||||
let betaComment = (
|
||||
await resolveComment(beta, commentRes.comment_view.comment)
|
||||
).comment.unwrap();
|
||||
).comment;
|
||||
assertCommentFederation(betaComment, commentRes.comment_view);
|
||||
});
|
||||
|
||||
test("A and G subscribe to B (center) A posts, G mentions B, it gets announced to A", async () => {
|
||||
// Create a local post
|
||||
let alphaCommunity = (
|
||||
await resolveCommunity(alpha, "!main@lemmy-alpha:8541")
|
||||
).community.unwrap();
|
||||
let alphaCommunity = (await resolveCommunity(alpha, "!main@lemmy-alpha:8541"))
|
||||
.community;
|
||||
|
||||
if (!alphaCommunity) {
|
||||
throw "Missing alpha community";
|
||||
}
|
||||
|
||||
let alphaPost = await createPost(alpha, alphaCommunity.community.id);
|
||||
expect(alphaPost.post_view.community.local).toBe(true);
|
||||
|
||||
// Make sure gamma sees it
|
||||
let gammaPost = (
|
||||
await resolvePost(gamma, alphaPost.post_view.post)
|
||||
).post.unwrap();
|
||||
let gammaPost = (await resolvePost(gamma, alphaPost.post_view.post)).post;
|
||||
|
||||
if (!gammaPost) {
|
||||
throw "Missing gamma post";
|
||||
}
|
||||
|
||||
let commentContent =
|
||||
"A jest test federated comment announce, lets mention @lemmy_beta@lemmy-beta:8551";
|
||||
let commentRes = await createComment(
|
||||
gamma,
|
||||
gammaPost.post.id,
|
||||
None,
|
||||
undefined,
|
||||
commentContent
|
||||
);
|
||||
expect(commentRes.comment_view.comment.content).toBe(commentContent);
|
||||
|
@ -385,13 +405,16 @@ test("Check that activity from another instance is sent to third instance", asyn
|
|||
expect(betaPost.post_view.community.local).toBe(true);
|
||||
|
||||
// Make sure gamma and alpha see it
|
||||
let gammaPost = (
|
||||
await resolvePost(gamma, betaPost.post_view.post)
|
||||
).post.unwrap();
|
||||
let gammaPost = (await resolvePost(gamma, betaPost.post_view.post)).post;
|
||||
if (!gammaPost) {
|
||||
throw "Missing gamma post";
|
||||
}
|
||||
expect(gammaPost.post).toBeDefined();
|
||||
let alphaPost = (
|
||||
await resolvePost(alpha, betaPost.post_view.post)
|
||||
).post.unwrap();
|
||||
|
||||
let alphaPost = (await resolvePost(alpha, betaPost.post_view.post)).post;
|
||||
if (!alphaPost) {
|
||||
throw "Missing alpha post";
|
||||
}
|
||||
expect(alphaPost.post).toBeDefined();
|
||||
|
||||
// The bug: gamma comments, and alpha should see it.
|
||||
|
@ -399,7 +422,7 @@ test("Check that activity from another instance is sent to third instance", asyn
|
|||
let commentRes = await createComment(
|
||||
gamma,
|
||||
gammaPost.post.id,
|
||||
None,
|
||||
undefined,
|
||||
commentContent
|
||||
);
|
||||
expect(commentRes.comment_view.comment.content).toBe(commentContent);
|
||||
|
@ -426,7 +449,7 @@ test("Fetch in_reply_tos: A is unsubbed from B, B makes a post, and some embedde
|
|||
// Unfollow all remote communities
|
||||
let site = await unfollowRemotes(alpha);
|
||||
expect(
|
||||
site.my_user.unwrap().follows.filter(c => c.community.local == false).length
|
||||
site.my_user?.follows.filter(c => c.community.local == false).length
|
||||
).toBe(0);
|
||||
|
||||
// B creates a post, and two comments, should be invisible to A
|
||||
|
@ -437,7 +460,7 @@ test("Fetch in_reply_tos: A is unsubbed from B, B makes a post, and some embedde
|
|||
let parentCommentRes = await createComment(
|
||||
beta,
|
||||
postRes.post_view.post.id,
|
||||
None,
|
||||
undefined,
|
||||
parentCommentContent
|
||||
);
|
||||
expect(parentCommentRes.comment_view.comment.content).toBe(
|
||||
|
@ -449,7 +472,7 @@ test("Fetch in_reply_tos: A is unsubbed from B, B makes a post, and some embedde
|
|||
let childCommentRes = await createComment(
|
||||
beta,
|
||||
postRes.post_view.post.id,
|
||||
Some(parentCommentRes.comment_view.comment.id),
|
||||
parentCommentRes.comment_view.comment.id,
|
||||
childCommentContent
|
||||
);
|
||||
expect(childCommentRes.comment_view.comment.content).toBe(
|
||||
|
@ -462,20 +485,19 @@ test("Fetch in_reply_tos: A is unsubbed from B, B makes a post, and some embedde
|
|||
expect(follow.community_view.community.name).toBe("main");
|
||||
|
||||
// An update to the child comment on beta, should push the post, parent, and child to alpha now
|
||||
let updatedCommentContent = Some("An update child comment from beta");
|
||||
let updatedCommentContent = "An update child comment from beta";
|
||||
let updateRes = await editComment(
|
||||
beta,
|
||||
childCommentRes.comment_view.comment.id,
|
||||
updatedCommentContent
|
||||
);
|
||||
expect(updateRes.comment_view.comment.content).toBe(
|
||||
updatedCommentContent.unwrap()
|
||||
);
|
||||
expect(updateRes.comment_view.comment.content).toBe(updatedCommentContent);
|
||||
|
||||
// Get the post from alpha
|
||||
let alphaPostB = (
|
||||
await resolvePost(alpha, postRes.post_view.post)
|
||||
).post.unwrap();
|
||||
let alphaPostB = (await resolvePost(alpha, postRes.post_view.post)).post;
|
||||
if (!alphaPostB) {
|
||||
throw "Missing alpha post B";
|
||||
}
|
||||
|
||||
let alphaPost = await getPost(alpha, alphaPostB.post.id);
|
||||
let alphaPostComments = await getComments(alpha, alphaPostB.post.id);
|
||||
|
@ -495,16 +517,21 @@ test("Fetch in_reply_tos: A is unsubbed from B, B makes a post, and some embedde
|
|||
});
|
||||
|
||||
test("Report a comment", async () => {
|
||||
let betaCommunity = (await resolveBetaCommunity(beta)).community.unwrap();
|
||||
let betaCommunity = (await resolveBetaCommunity(beta)).community;
|
||||
if (!betaCommunity) {
|
||||
throw "Missing beta community";
|
||||
}
|
||||
let postRes = (await createPost(beta, betaCommunity.community.id)).post_view
|
||||
.post;
|
||||
expect(postRes).toBeDefined();
|
||||
let commentRes = (await createComment(beta, postRes.id, None)).comment_view
|
||||
.comment;
|
||||
let commentRes = (await createComment(beta, postRes.id)).comment_view.comment;
|
||||
expect(commentRes).toBeDefined();
|
||||
|
||||
let alphaComment = (await resolveComment(alpha, commentRes)).comment.unwrap()
|
||||
.comment;
|
||||
let alphaComment = (await resolveComment(alpha, commentRes)).comment?.comment;
|
||||
if (!alphaComment) {
|
||||
throw "Missing alpha comment";
|
||||
}
|
||||
|
||||
let alphaReport = (
|
||||
await reportComment(alpha, alphaComment.id, randomString(10))
|
||||
).comment_report_view.comment_report;
|
||||
|
|
|
@ -25,27 +25,25 @@ beforeAll(async () => {
|
|||
});
|
||||
|
||||
function assertCommunityFederation(
|
||||
communityOne: CommunityView,
|
||||
communityTwo: CommunityView
|
||||
communityOne?: CommunityView,
|
||||
communityTwo?: CommunityView
|
||||
) {
|
||||
expect(communityOne.community.actor_id).toBe(communityTwo.community.actor_id);
|
||||
expect(communityOne.community.name).toBe(communityTwo.community.name);
|
||||
expect(communityOne.community.title).toBe(communityTwo.community.title);
|
||||
expect(communityOne.community.description.unwrapOr("none")).toBe(
|
||||
communityTwo.community.description.unwrapOr("none")
|
||||
expect(communityOne?.community.actor_id).toBe(
|
||||
communityTwo?.community.actor_id
|
||||
);
|
||||
expect(communityOne.community.icon.unwrapOr("none")).toBe(
|
||||
communityTwo.community.icon.unwrapOr("none")
|
||||
expect(communityOne?.community.name).toBe(communityTwo?.community.name);
|
||||
expect(communityOne?.community.title).toBe(communityTwo?.community.title);
|
||||
expect(communityOne?.community.description).toBe(
|
||||
communityTwo?.community.description
|
||||
);
|
||||
expect(communityOne.community.banner.unwrapOr("none")).toBe(
|
||||
communityTwo.community.banner.unwrapOr("none")
|
||||
expect(communityOne?.community.icon).toBe(communityTwo?.community.icon);
|
||||
expect(communityOne?.community.banner).toBe(communityTwo?.community.banner);
|
||||
expect(communityOne?.community.published).toBe(
|
||||
communityTwo?.community.published
|
||||
);
|
||||
expect(communityOne.community.published).toBe(
|
||||
communityTwo.community.published
|
||||
);
|
||||
expect(communityOne.community.nsfw).toBe(communityTwo.community.nsfw);
|
||||
expect(communityOne.community.removed).toBe(communityTwo.community.removed);
|
||||
expect(communityOne.community.deleted).toBe(communityTwo.community.deleted);
|
||||
expect(communityOne?.community.nsfw).toBe(communityTwo?.community.nsfw);
|
||||
expect(communityOne?.community.removed).toBe(communityTwo?.community.removed);
|
||||
expect(communityOne?.community.deleted).toBe(communityTwo?.community.deleted);
|
||||
}
|
||||
|
||||
test("Create community", async () => {
|
||||
|
@ -59,9 +57,7 @@ test("Create community", async () => {
|
|||
|
||||
// Cache the community on beta, make sure it has the other fields
|
||||
let searchShort = `!${prevName}@lemmy-alpha:8541`;
|
||||
let betaCommunity = (
|
||||
await resolveCommunity(beta, searchShort)
|
||||
).community.unwrap();
|
||||
let betaCommunity = (await resolveCommunity(beta, searchShort)).community;
|
||||
assertCommunityFederation(betaCommunity, communityRes.community_view);
|
||||
});
|
||||
|
||||
|
@ -70,9 +66,10 @@ test("Delete community", async () => {
|
|||
|
||||
// Cache the community on Alpha
|
||||
let searchShort = `!${communityRes.community_view.community.name}@lemmy-beta:8551`;
|
||||
let alphaCommunity = (
|
||||
await resolveCommunity(alpha, searchShort)
|
||||
).community.unwrap();
|
||||
let alphaCommunity = (await resolveCommunity(alpha, searchShort)).community;
|
||||
if (!alphaCommunity) {
|
||||
throw "Missing alpha community";
|
||||
}
|
||||
assertCommunityFederation(alphaCommunity, communityRes.community_view);
|
||||
|
||||
// Follow the community from alpha
|
||||
|
@ -121,9 +118,10 @@ test("Remove community", async () => {
|
|||
|
||||
// Cache the community on Alpha
|
||||
let searchShort = `!${communityRes.community_view.community.name}@lemmy-beta:8551`;
|
||||
let alphaCommunity = (
|
||||
await resolveCommunity(alpha, searchShort)
|
||||
).community.unwrap();
|
||||
let alphaCommunity = (await resolveCommunity(alpha, searchShort)).community;
|
||||
if (!alphaCommunity) {
|
||||
throw "Missing alpha community";
|
||||
}
|
||||
assertCommunityFederation(alphaCommunity, communityRes.community_view);
|
||||
|
||||
// Follow the community from alpha
|
||||
|
@ -172,9 +170,7 @@ test("Search for beta community", async () => {
|
|||
expect(communityRes.community_view.community.name).toBeDefined();
|
||||
|
||||
let searchShort = `!${communityRes.community_view.community.name}@lemmy-beta:8551`;
|
||||
let alphaCommunity = (
|
||||
await resolveCommunity(alpha, searchShort)
|
||||
).community.unwrap();
|
||||
let alphaCommunity = (await resolveCommunity(alpha, searchShort)).community;
|
||||
assertCommunityFederation(alphaCommunity, communityRes.community_view);
|
||||
});
|
||||
|
||||
|
@ -186,15 +182,17 @@ test("Admin actions in remote community are not federated to origin", async () =
|
|||
// gamma follows community and posts in it
|
||||
let gammaCommunity = (
|
||||
await resolveCommunity(gamma, communityRes.community.actor_id)
|
||||
).community.unwrap();
|
||||
await followCommunity(
|
||||
gamma,
|
||||
true,
|
||||
gammaCommunity.community.id
|
||||
);
|
||||
).community;
|
||||
if (!gammaCommunity) {
|
||||
throw "Missing gamma community";
|
||||
}
|
||||
await followCommunity(gamma, true, gammaCommunity.community.id);
|
||||
gammaCommunity = (
|
||||
await resolveCommunity(gamma, communityRes.community.actor_id)
|
||||
).community.unwrap();
|
||||
).community;
|
||||
if (!gammaCommunity) {
|
||||
throw "Missing gamma community";
|
||||
}
|
||||
expect(gammaCommunity.subscribed).toBe("Subscribed");
|
||||
let gammaPost = (await createPost(gamma, gammaCommunity.community.id))
|
||||
.post_view;
|
||||
|
@ -204,12 +202,19 @@ test("Admin actions in remote community are not federated to origin", async () =
|
|||
// admin of beta decides to ban gamma from community
|
||||
let betaCommunity = (
|
||||
await resolveCommunity(beta, communityRes.community.actor_id)
|
||||
).community.unwrap();
|
||||
let bannedUserInfo1 = (await getSite(gamma)).my_user.unwrap().local_user_view
|
||||
).community;
|
||||
if (!betaCommunity) {
|
||||
throw "Missing beta community";
|
||||
}
|
||||
let bannedUserInfo1 = (await getSite(gamma)).my_user?.local_user_view.person;
|
||||
if (!bannedUserInfo1) {
|
||||
throw "Missing banned user 1";
|
||||
}
|
||||
let bannedUserInfo2 = (await resolvePerson(beta, bannedUserInfo1.actor_id))
|
||||
.person;
|
||||
let bannedUserInfo2 = (
|
||||
await resolvePerson(beta, bannedUserInfo1.actor_id)
|
||||
).person.unwrap();
|
||||
if (!bannedUserInfo2) {
|
||||
throw "Missing banned user 2";
|
||||
}
|
||||
let banRes = await banPersonFromCommunity(
|
||||
beta,
|
||||
bannedUserInfo2.person.id,
|
||||
|
@ -220,8 +225,8 @@ test("Admin actions in remote community are not federated to origin", async () =
|
|||
expect(banRes.banned).toBe(true);
|
||||
|
||||
// ban doesnt federate to community's origin instance alpha
|
||||
let alphaPost = (await resolvePost(alpha, gammaPost.post)).post.unwrap();
|
||||
expect(alphaPost.creator_banned_from_community).toBe(false);
|
||||
let alphaPost = (await resolvePost(alpha, gammaPost.post)).post;
|
||||
expect(alphaPost?.creator_banned_from_community).toBe(false);
|
||||
|
||||
// and neither to gamma
|
||||
let gammaPost2 = await getPost(gamma, gammaPost.post.id);
|
||||
|
|
|
@ -19,22 +19,29 @@ afterAll(async () => {
|
|||
});
|
||||
|
||||
test("Follow federated community", async () => {
|
||||
let betaCommunity = (await resolveBetaCommunity(alpha)).community.unwrap();
|
||||
let betaCommunity = (await resolveBetaCommunity(alpha)).community;
|
||||
if (!betaCommunity) {
|
||||
throw "Missing beta community";
|
||||
}
|
||||
await followCommunity(alpha, true, betaCommunity.community.id);
|
||||
betaCommunity = (await resolveBetaCommunity(alpha)).community.unwrap();
|
||||
betaCommunity = (await resolveBetaCommunity(alpha)).community;
|
||||
|
||||
// Make sure the follow response went through
|
||||
expect(betaCommunity.community.local).toBe(false);
|
||||
expect(betaCommunity.community.name).toBe("main");
|
||||
expect(betaCommunity.subscribed).toBe(SubscribedType.Subscribed);
|
||||
expect(betaCommunity?.community.local).toBe(false);
|
||||
expect(betaCommunity?.community.name).toBe("main");
|
||||
expect(betaCommunity?.subscribed).toBe(SubscribedType.Subscribed);
|
||||
|
||||
// Check it from local
|
||||
let site = await getSite(alpha);
|
||||
let remoteCommunityId = site.my_user
|
||||
.unwrap()
|
||||
.follows.find(c => c.community.local == false).community.id;
|
||||
let remoteCommunityId = site.my_user?.follows.find(
|
||||
c => c.community.local == false
|
||||
)?.community.id;
|
||||
expect(remoteCommunityId).toBeDefined();
|
||||
expect(site.my_user.unwrap().follows.length).toBe(2);
|
||||
expect(site.my_user?.follows.length).toBe(2);
|
||||
|
||||
if (!remoteCommunityId) {
|
||||
throw "Missing remote community id";
|
||||
}
|
||||
|
||||
// Test an unfollow
|
||||
let unfollow = await followCommunity(alpha, false, remoteCommunityId);
|
||||
|
@ -42,5 +49,5 @@ test("Follow federated community", async () => {
|
|||
|
||||
// Make sure you are unsubbed locally
|
||||
let siteUnfollowCheck = await getSite(alpha);
|
||||
expect(siteUnfollowCheck.my_user.unwrap().follows.length).toBe(1);
|
||||
expect(siteUnfollowCheck.my_user?.follows.length).toBe(1);
|
||||
});
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
jest.setTimeout(120000);
|
||||
import { None } from "@sniptt/monads";
|
||||
import { PostView, CommunityView } from "lemmy-js-client";
|
||||
|
||||
import {
|
||||
|
@ -37,11 +36,11 @@ import {
|
|||
resolveCommunity,
|
||||
} from "./shared";
|
||||
|
||||
let betaCommunity: CommunityView;
|
||||
let betaCommunity: CommunityView | undefined;
|
||||
|
||||
beforeAll(async () => {
|
||||
await setupLogins();
|
||||
betaCommunity = (await resolveBetaCommunity(alpha)).community.unwrap();
|
||||
betaCommunity = (await resolveBetaCommunity(alpha)).community;
|
||||
expect(betaCommunity).toBeDefined();
|
||||
await unfollows();
|
||||
});
|
||||
|
@ -50,33 +49,28 @@ afterAll(async () => {
|
|||
await unfollows();
|
||||
});
|
||||
|
||||
function assertPostFederation(postOne: PostView, postTwo: PostView) {
|
||||
expect(postOne.post.ap_id).toBe(postTwo.post.ap_id);
|
||||
expect(postOne.post.name).toBe(postTwo.post.name);
|
||||
expect(postOne.post.body.unwrapOr("none")).toBe(
|
||||
postTwo.post.body.unwrapOr("none")
|
||||
);
|
||||
expect(postOne.post.url.unwrapOr("https://google.com/")).toBe(
|
||||
postTwo.post.url.unwrapOr("https://google.com/")
|
||||
);
|
||||
expect(postOne.post.nsfw).toBe(postTwo.post.nsfw);
|
||||
expect(postOne.post.embed_title.unwrapOr("none")).toBe(
|
||||
postTwo.post.embed_title.unwrapOr("none")
|
||||
);
|
||||
expect(postOne.post.embed_description.unwrapOr("none")).toBe(
|
||||
postTwo.post.embed_description.unwrapOr("none")
|
||||
);
|
||||
expect(postOne.post.embed_video_url.unwrapOr("none")).toBe(
|
||||
postTwo.post.embed_video_url.unwrapOr("none")
|
||||
);
|
||||
expect(postOne.post.published).toBe(postTwo.post.published);
|
||||
expect(postOne.community.actor_id).toBe(postTwo.community.actor_id);
|
||||
expect(postOne.post.locked).toBe(postTwo.post.locked);
|
||||
expect(postOne.post.removed).toBe(postTwo.post.removed);
|
||||
expect(postOne.post.deleted).toBe(postTwo.post.deleted);
|
||||
function assertPostFederation(postOne?: PostView, postTwo?: PostView) {
|
||||
expect(postOne?.post.ap_id).toBe(postTwo?.post.ap_id);
|
||||
expect(postOne?.post.name).toBe(postTwo?.post.name);
|
||||
expect(postOne?.post.body).toBe(postTwo?.post.body);
|
||||
// TODO url clears arent working
|
||||
// expect(postOne?.post.url).toBe(postTwo?.post.url);
|
||||
expect(postOne?.post.nsfw).toBe(postTwo?.post.nsfw);
|
||||
expect(postOne?.post.embed_title).toBe(postTwo?.post.embed_title);
|
||||
expect(postOne?.post.embed_description).toBe(postTwo?.post.embed_description);
|
||||
expect(postOne?.post.embed_video_url).toBe(postTwo?.post.embed_video_url);
|
||||
expect(postOne?.post.published).toBe(postTwo?.post.published);
|
||||
expect(postOne?.community.actor_id).toBe(postTwo?.community.actor_id);
|
||||
expect(postOne?.post.locked).toBe(postTwo?.post.locked);
|
||||
expect(postOne?.post.removed).toBe(postTwo?.post.removed);
|
||||
expect(postOne?.post.deleted).toBe(postTwo?.post.deleted);
|
||||
}
|
||||
|
||||
test("Create a post", async () => {
|
||||
if (!betaCommunity) {
|
||||
throw "Missing beta community";
|
||||
}
|
||||
|
||||
let postRes = await createPost(alpha, betaCommunity.community.id);
|
||||
expect(postRes.post_view.post).toBeDefined();
|
||||
expect(postRes.post_view.community.local).toBe(false);
|
||||
|
@ -84,23 +78,21 @@ test("Create a post", async () => {
|
|||
expect(postRes.post_view.counts.score).toBe(1);
|
||||
|
||||
// Make sure that post is liked on beta
|
||||
let betaPost = (
|
||||
await resolvePost(beta, postRes.post_view.post)
|
||||
).post.unwrap();
|
||||
let betaPost = (await resolvePost(beta, postRes.post_view.post)).post;
|
||||
|
||||
expect(betaPost).toBeDefined();
|
||||
expect(betaPost.community.local).toBe(true);
|
||||
expect(betaPost.creator.local).toBe(false);
|
||||
expect(betaPost.counts.score).toBe(1);
|
||||
expect(betaPost?.community.local).toBe(true);
|
||||
expect(betaPost?.creator.local).toBe(false);
|
||||
expect(betaPost?.counts.score).toBe(1);
|
||||
assertPostFederation(betaPost, postRes.post_view);
|
||||
|
||||
// Delta only follows beta, so it should not see an alpha ap_id
|
||||
let deltaPost = (await resolvePost(delta, postRes.post_view.post)).post;
|
||||
expect(deltaPost.isNone()).toBe(true);
|
||||
expect(deltaPost).toBeUndefined();
|
||||
|
||||
// Epsilon has alpha blocked, it should not see the alpha post
|
||||
let epsilonPost = (await resolvePost(epsilon, postRes.post_view.post)).post;
|
||||
expect(epsilonPost.isNone()).toBe(true);
|
||||
expect(epsilonPost).toBeUndefined();
|
||||
});
|
||||
|
||||
test("Create a post in a non-existent community", async () => {
|
||||
|
@ -109,6 +101,9 @@ test("Create a post in a non-existent community", async () => {
|
|||
});
|
||||
|
||||
test("Unlike a post", async () => {
|
||||
if (!betaCommunity) {
|
||||
throw "Missing beta community";
|
||||
}
|
||||
let postRes = await createPost(alpha, betaCommunity.community.id);
|
||||
let unlike = await likePost(alpha, 0, postRes.post_view.post);
|
||||
expect(unlike.post_view.counts.score).toBe(0);
|
||||
|
@ -118,17 +113,18 @@ test("Unlike a post", async () => {
|
|||
expect(unlike2.post_view.counts.score).toBe(0);
|
||||
|
||||
// Make sure that post is unliked on beta
|
||||
let betaPost = (
|
||||
await resolvePost(beta, postRes.post_view.post)
|
||||
).post.unwrap();
|
||||
let betaPost = (await resolvePost(beta, postRes.post_view.post)).post;
|
||||
expect(betaPost).toBeDefined();
|
||||
expect(betaPost.community.local).toBe(true);
|
||||
expect(betaPost.creator.local).toBe(false);
|
||||
expect(betaPost.counts.score).toBe(0);
|
||||
expect(betaPost?.community.local).toBe(true);
|
||||
expect(betaPost?.creator.local).toBe(false);
|
||||
expect(betaPost?.counts.score).toBe(0);
|
||||
assertPostFederation(betaPost, postRes.post_view);
|
||||
});
|
||||
|
||||
test("Update a post", async () => {
|
||||
if (!betaCommunity) {
|
||||
throw "Missing beta community";
|
||||
}
|
||||
let postRes = await createPost(alpha, betaCommunity.community.id);
|
||||
|
||||
let updatedName = "A jest test federated post, updated";
|
||||
|
@ -138,9 +134,10 @@ test("Update a post", async () => {
|
|||
expect(updatedPost.post_view.creator.local).toBe(true);
|
||||
|
||||
// Make sure that post is updated on beta
|
||||
let betaPost = (
|
||||
await resolvePost(beta, postRes.post_view.post)
|
||||
).post.unwrap();
|
||||
let betaPost = (await resolvePost(beta, postRes.post_view.post)).post;
|
||||
if (!betaPost) {
|
||||
throw "Missing beta post";
|
||||
}
|
||||
expect(betaPost.community.local).toBe(true);
|
||||
expect(betaPost.creator.local).toBe(false);
|
||||
expect(betaPost.post.name).toBe(updatedName);
|
||||
|
@ -152,54 +149,57 @@ test("Update a post", async () => {
|
|||
});
|
||||
|
||||
test("Sticky a post", async () => {
|
||||
if (!betaCommunity) {
|
||||
throw "Missing beta community";
|
||||
}
|
||||
let postRes = await createPost(alpha, betaCommunity.community.id);
|
||||
|
||||
let betaPost1 = (
|
||||
await resolvePost(beta, postRes.post_view.post)
|
||||
).post.unwrap();
|
||||
let betaPost1 = (await resolvePost(beta, postRes.post_view.post)).post;
|
||||
if (!betaPost1) {
|
||||
throw "Missing beta post1";
|
||||
}
|
||||
let stickiedPostRes = await featurePost(beta, true, betaPost1.post);
|
||||
expect(stickiedPostRes.post_view.post.featured_community).toBe(true);
|
||||
|
||||
// Make sure that post is stickied on beta
|
||||
let betaPost = (
|
||||
await resolvePost(beta, postRes.post_view.post)
|
||||
).post.unwrap();
|
||||
expect(betaPost.community.local).toBe(true);
|
||||
expect(betaPost.creator.local).toBe(false);
|
||||
expect(betaPost.post.featured_community).toBe(true);
|
||||
let betaPost = (await resolvePost(beta, postRes.post_view.post)).post;
|
||||
expect(betaPost?.community.local).toBe(true);
|
||||
expect(betaPost?.creator.local).toBe(false);
|
||||
expect(betaPost?.post.featured_community).toBe(true);
|
||||
|
||||
// Unsticky a post
|
||||
let unstickiedPost = await featurePost(beta, false, betaPost1.post);
|
||||
expect(unstickiedPost.post_view.post.featured_community).toBe(false);
|
||||
|
||||
// Make sure that post is unstickied on beta
|
||||
let betaPost2 = (
|
||||
await resolvePost(beta, postRes.post_view.post)
|
||||
).post.unwrap();
|
||||
expect(betaPost2.community.local).toBe(true);
|
||||
expect(betaPost2.creator.local).toBe(false);
|
||||
expect(betaPost2.post.featured_community).toBe(false);
|
||||
let betaPost2 = (await resolvePost(beta, postRes.post_view.post)).post;
|
||||
expect(betaPost2?.community.local).toBe(true);
|
||||
expect(betaPost2?.creator.local).toBe(false);
|
||||
expect(betaPost2?.post.featured_community).toBe(false);
|
||||
|
||||
// Make sure that gamma cannot sticky the post on beta
|
||||
let gammaPost = (
|
||||
await resolvePost(gamma, postRes.post_view.post)
|
||||
).post.unwrap();
|
||||
let gammaPost = (await resolvePost(gamma, postRes.post_view.post)).post;
|
||||
if (!gammaPost) {
|
||||
throw "Missing gamma post";
|
||||
}
|
||||
let gammaTrySticky = await featurePost(gamma, true, gammaPost.post);
|
||||
let betaPost3 = (
|
||||
await resolvePost(beta, postRes.post_view.post)
|
||||
).post.unwrap();
|
||||
let betaPost3 = (await resolvePost(beta, postRes.post_view.post)).post;
|
||||
expect(gammaTrySticky.post_view.post.featured_community).toBe(true);
|
||||
expect(betaPost3.post.featured_community).toBe(false);
|
||||
expect(betaPost3?.post.featured_community).toBe(false);
|
||||
});
|
||||
|
||||
test("Lock a post", async () => {
|
||||
if (!betaCommunity) {
|
||||
throw "Missing beta community";
|
||||
}
|
||||
await followCommunity(alpha, true, betaCommunity.community.id);
|
||||
let postRes = await createPost(alpha, betaCommunity.community.id);
|
||||
|
||||
// Lock the post
|
||||
let betaPost1 = (
|
||||
await resolvePost(beta, postRes.post_view.post)
|
||||
).post.unwrap();
|
||||
let betaPost1 = (await resolvePost(beta, postRes.post_view.post)).post;
|
||||
if (!betaPost1) {
|
||||
throw "Missing beta post1";
|
||||
}
|
||||
let lockedPostRes = await lockPost(beta, true, betaPost1.post);
|
||||
expect(lockedPostRes.post_view.post.locked).toBe(true);
|
||||
|
||||
|
@ -209,7 +209,7 @@ test("Lock a post", async () => {
|
|||
expect(alphaPost1.post.locked).toBe(true);
|
||||
|
||||
// Try to make a new comment there, on alpha
|
||||
let comment: any = await createComment(alpha, alphaPost1.post.id, None);
|
||||
let comment: any = await createComment(alpha, alphaPost1.post.id);
|
||||
expect(comment["error"]).toBe("locked");
|
||||
|
||||
// Unlock a post
|
||||
|
@ -224,11 +224,15 @@ test("Lock a post", async () => {
|
|||
expect(alphaPost2.post.locked).toBe(false);
|
||||
|
||||
// Try to create a new comment, on alpha
|
||||
let commentAlpha = await createComment(alpha, alphaPost1.post.id, None);
|
||||
let commentAlpha = await createComment(alpha, alphaPost1.post.id);
|
||||
expect(commentAlpha).toBeDefined();
|
||||
});
|
||||
|
||||
test("Delete a post", async () => {
|
||||
if (!betaCommunity) {
|
||||
throw "Missing beta community";
|
||||
}
|
||||
|
||||
let postRes = await createPost(alpha, betaCommunity.community.id);
|
||||
expect(postRes.post_view.post).toBeDefined();
|
||||
|
||||
|
@ -239,16 +243,17 @@ test("Delete a post", async () => {
|
|||
// Make sure lemmy beta sees post is deleted
|
||||
let betaPost = (await resolvePost(beta, postRes.post_view.post)).post;
|
||||
// This will be undefined because of the tombstone
|
||||
expect(betaPost.isNone()).toBe(true);
|
||||
expect(betaPost).toBeUndefined();
|
||||
|
||||
// Undelete
|
||||
let undeletedPost = await deletePost(alpha, false, postRes.post_view.post);
|
||||
expect(undeletedPost.post_view.post.deleted).toBe(false);
|
||||
|
||||
// Make sure lemmy beta sees post is undeleted
|
||||
let betaPost2 = (
|
||||
await resolvePost(beta, postRes.post_view.post)
|
||||
).post.unwrap();
|
||||
let betaPost2 = (await resolvePost(beta, postRes.post_view.post)).post;
|
||||
if (!betaPost2) {
|
||||
throw "Missing beta post 2";
|
||||
}
|
||||
expect(betaPost2.post.deleted).toBe(false);
|
||||
assertPostFederation(betaPost2, undeletedPost.post_view);
|
||||
|
||||
|
@ -258,26 +263,31 @@ test("Delete a post", async () => {
|
|||
});
|
||||
|
||||
test("Remove a post from admin and community on different instance", async () => {
|
||||
let gammaCommunity = await resolveCommunity(
|
||||
gamma,
|
||||
betaCommunity.community.actor_id
|
||||
);
|
||||
let postRes = await createPost(
|
||||
gamma,
|
||||
gammaCommunity.community.unwrap().community.id
|
||||
);
|
||||
if (!betaCommunity) {
|
||||
throw "Missing beta community";
|
||||
}
|
||||
|
||||
let alphaPost = (
|
||||
await resolvePost(alpha, postRes.post_view.post)
|
||||
).post.unwrap();
|
||||
let gammaCommunity = (
|
||||
await resolveCommunity(gamma, betaCommunity.community.actor_id)
|
||||
).community?.community;
|
||||
if (!gammaCommunity) {
|
||||
throw "Missing gamma community";
|
||||
}
|
||||
let postRes = await createPost(gamma, gammaCommunity.id);
|
||||
|
||||
let alphaPost = (await resolvePost(alpha, postRes.post_view.post)).post;
|
||||
if (!alphaPost) {
|
||||
throw "Missing alpha post";
|
||||
}
|
||||
let removedPost = await removePost(alpha, true, alphaPost.post);
|
||||
expect(removedPost.post_view.post.removed).toBe(true);
|
||||
expect(removedPost.post_view.post.name).toBe(postRes.post_view.post.name);
|
||||
|
||||
// Make sure lemmy beta sees post is NOT removed
|
||||
let betaPost = (
|
||||
await resolvePost(beta, postRes.post_view.post)
|
||||
).post.unwrap();
|
||||
let betaPost = (await resolvePost(beta, postRes.post_view.post)).post;
|
||||
if (!betaPost) {
|
||||
throw "Missing beta post";
|
||||
}
|
||||
expect(betaPost.post.removed).toBe(false);
|
||||
|
||||
// Undelete
|
||||
|
@ -285,14 +295,15 @@ test("Remove a post from admin and community on different instance", async () =>
|
|||
expect(undeletedPost.post_view.post.removed).toBe(false);
|
||||
|
||||
// Make sure lemmy beta sees post is undeleted
|
||||
let betaPost2 = (
|
||||
await resolvePost(beta, postRes.post_view.post)
|
||||
).post.unwrap();
|
||||
expect(betaPost2.post.removed).toBe(false);
|
||||
let betaPost2 = (await resolvePost(beta, postRes.post_view.post)).post;
|
||||
expect(betaPost2?.post.removed).toBe(false);
|
||||
assertPostFederation(betaPost2, undeletedPost.post_view);
|
||||
});
|
||||
|
||||
test("Remove a post from admin and community on same instance", async () => {
|
||||
if (!betaCommunity) {
|
||||
throw "Missing beta community";
|
||||
}
|
||||
await followBeta(alpha);
|
||||
let postRes = await createPost(alpha, betaCommunity.community.id);
|
||||
expect(postRes.post_view.post).toBeDefined();
|
||||
|
@ -323,30 +334,38 @@ test("Remove a post from admin and community on same instance", async () => {
|
|||
});
|
||||
|
||||
test("Search for a post", async () => {
|
||||
if (!betaCommunity) {
|
||||
throw "Missing beta community";
|
||||
}
|
||||
await unfollowRemotes(alpha);
|
||||
let postRes = await createPost(alpha, betaCommunity.community.id);
|
||||
expect(postRes.post_view.post).toBeDefined();
|
||||
|
||||
let betaPost = (
|
||||
await resolvePost(beta, postRes.post_view.post)
|
||||
).post.unwrap();
|
||||
expect(betaPost.post.name).toBeDefined();
|
||||
let betaPost = (await resolvePost(beta, postRes.post_view.post)).post;
|
||||
expect(betaPost?.post.name).toBeDefined();
|
||||
});
|
||||
|
||||
test("Enforce site ban for federated user", async () => {
|
||||
if (!betaCommunity) {
|
||||
throw "Missing beta community";
|
||||
}
|
||||
// create a test user
|
||||
let alphaUserJwt = await registerUser(alpha);
|
||||
expect(alphaUserJwt).toBeDefined();
|
||||
let alpha_user: API = {
|
||||
client: alpha.client,
|
||||
auth: alphaUserJwt.jwt,
|
||||
auth: alphaUserJwt.jwt ?? "",
|
||||
};
|
||||
let alphaUserActorId = (await getSite(alpha_user)).my_user.unwrap()
|
||||
.local_user_view.person.actor_id;
|
||||
let alphaUserActorId = (await getSite(alpha_user)).my_user?.local_user_view
|
||||
.person.actor_id;
|
||||
if (!alphaUserActorId) {
|
||||
throw "Missing alpha user actor id";
|
||||
}
|
||||
expect(alphaUserActorId).toBeDefined();
|
||||
let alphaPerson = (
|
||||
await resolvePerson(alpha_user, alphaUserActorId)
|
||||
).person.unwrap();
|
||||
let alphaPerson = (await resolvePerson(alpha_user, alphaUserActorId)).person;
|
||||
if (!alphaPerson) {
|
||||
throw "Missing alpha person";
|
||||
}
|
||||
expect(alphaPerson).toBeDefined();
|
||||
|
||||
// alpha makes post in beta community, it federates to beta instance
|
||||
|
@ -365,7 +384,7 @@ test("Enforce site ban for federated user", async () => {
|
|||
|
||||
// alpha ban should be federated to beta
|
||||
let alphaUserOnBeta1 = await resolvePerson(beta, alphaUserActorId);
|
||||
expect(alphaUserOnBeta1.person.unwrap().person.banned).toBe(true);
|
||||
expect(alphaUserOnBeta1.person?.person.banned).toBe(true);
|
||||
|
||||
// existing alpha post should be removed on beta
|
||||
let searchBeta2 = await searchPostLocal(beta, postRes1.post_view.post);
|
||||
|
@ -386,12 +405,18 @@ test("Enforce site ban for federated user", async () => {
|
|||
expect(searchBeta3.posts[0]).toBeDefined();
|
||||
|
||||
let alphaUserOnBeta2 = await resolvePerson(beta, alphaUserActorId);
|
||||
expect(alphaUserOnBeta2.person.unwrap().person.banned).toBe(false);
|
||||
expect(alphaUserOnBeta2.person?.person.banned).toBe(false);
|
||||
});
|
||||
|
||||
test("Enforce community ban for federated user", async () => {
|
||||
if (!betaCommunity) {
|
||||
throw "Missing beta community";
|
||||
}
|
||||
let alphaShortname = `@lemmy_alpha@lemmy-alpha:8541`;
|
||||
let alphaPerson = (await resolvePerson(beta, alphaShortname)).person.unwrap();
|
||||
let alphaPerson = (await resolvePerson(beta, alphaShortname)).person;
|
||||
if (!alphaPerson) {
|
||||
throw "Missing alpha person";
|
||||
}
|
||||
expect(alphaPerson).toBeDefined();
|
||||
|
||||
// make a post in beta, it goes through
|
||||
|
@ -438,23 +463,29 @@ test("Enforce community ban for federated user", async () => {
|
|||
});
|
||||
|
||||
test("A and G subscribe to B (center) A posts, it gets announced to G", async () => {
|
||||
if (!betaCommunity) {
|
||||
throw "Missing beta community";
|
||||
}
|
||||
let postRes = await createPost(alpha, betaCommunity.community.id);
|
||||
expect(postRes.post_view.post).toBeDefined();
|
||||
|
||||
let betaPost = (
|
||||
await resolvePost(gamma, postRes.post_view.post)
|
||||
).post.unwrap();
|
||||
expect(betaPost.post.name).toBeDefined();
|
||||
let betaPost = (await resolvePost(gamma, postRes.post_view.post)).post;
|
||||
expect(betaPost?.post.name).toBeDefined();
|
||||
});
|
||||
|
||||
test("Report a post", async () => {
|
||||
let betaCommunity = (await resolveBetaCommunity(beta)).community.unwrap();
|
||||
// Note, this is a different one from the setup
|
||||
let betaCommunity = (await resolveBetaCommunity(beta)).community;
|
||||
if (!betaCommunity) {
|
||||
throw "Missing beta community";
|
||||
}
|
||||
let postRes = await createPost(beta, betaCommunity.community.id);
|
||||
expect(postRes.post_view.post).toBeDefined();
|
||||
|
||||
let alphaPost = (
|
||||
await resolvePost(alpha, postRes.post_view.post)
|
||||
).post.unwrap();
|
||||
let alphaPost = (await resolvePost(alpha, postRes.post_view.post)).post;
|
||||
if (!alphaPost) {
|
||||
throw "Missing alpha post";
|
||||
}
|
||||
let alphaReport = (
|
||||
await reportPost(alpha, alphaPost.post.id, randomString(10))
|
||||
).post_report_view.post_report;
|
||||
|
@ -463,11 +494,7 @@ test("Report a post", async () => {
|
|||
expect(betaReport).toBeDefined();
|
||||
expect(betaReport.resolved).toBe(false);
|
||||
expect(betaReport.original_post_name).toBe(alphaReport.original_post_name);
|
||||
expect(betaReport.original_post_url.unwrapOr("none")).toBe(
|
||||
alphaReport.original_post_url.unwrapOr("none")
|
||||
);
|
||||
expect(betaReport.original_post_body.unwrapOr("none")).toBe(
|
||||
alphaReport.original_post_body.unwrapOr("none")
|
||||
);
|
||||
expect(betaReport.original_post_url).toBe(alphaReport.original_post_url);
|
||||
expect(betaReport.original_post_body).toBe(alphaReport.original_post_body);
|
||||
expect(betaReport.reason).toBe(alphaReport.reason);
|
||||
});
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
import { None, Some, Option } from "@sniptt/monads";
|
||||
import {
|
||||
Login,
|
||||
LoginResponse,
|
||||
|
@ -69,65 +68,65 @@ import {
|
|||
|
||||
export interface API {
|
||||
client: LemmyHttp;
|
||||
auth: Option<string>;
|
||||
auth: string;
|
||||
}
|
||||
|
||||
export let alpha: API = {
|
||||
client: new LemmyHttp("http://127.0.0.1:8541"),
|
||||
auth: None,
|
||||
auth: "",
|
||||
};
|
||||
|
||||
export let beta: API = {
|
||||
client: new LemmyHttp("http://127.0.0.1:8551"),
|
||||
auth: None,
|
||||
auth: "",
|
||||
};
|
||||
|
||||
export let gamma: API = {
|
||||
client: new LemmyHttp("http://127.0.0.1:8561"),
|
||||
auth: None,
|
||||
auth: "",
|
||||
};
|
||||
|
||||
export let delta: API = {
|
||||
client: new LemmyHttp("http://127.0.0.1:8571"),
|
||||
auth: None,
|
||||
auth: "",
|
||||
};
|
||||
|
||||
export let epsilon: API = {
|
||||
client: new LemmyHttp("http://127.0.0.1:8581"),
|
||||
auth: None,
|
||||
auth: "",
|
||||
};
|
||||
|
||||
const password = "lemmylemmy";
|
||||
|
||||
export async function setupLogins() {
|
||||
let formAlpha = new Login({
|
||||
let formAlpha: Login = {
|
||||
username_or_email: "lemmy_alpha",
|
||||
password,
|
||||
});
|
||||
};
|
||||
let resAlpha = alpha.client.login(formAlpha);
|
||||
|
||||
let formBeta = new Login({
|
||||
let formBeta: Login = {
|
||||
username_or_email: "lemmy_beta",
|
||||
password,
|
||||
});
|
||||
};
|
||||
let resBeta = beta.client.login(formBeta);
|
||||
|
||||
let formGamma = new Login({
|
||||
let formGamma: Login = {
|
||||
username_or_email: "lemmy_gamma",
|
||||
password,
|
||||
});
|
||||
};
|
||||
let resGamma = gamma.client.login(formGamma);
|
||||
|
||||
let formDelta = new Login({
|
||||
let formDelta: Login = {
|
||||
username_or_email: "lemmy_delta",
|
||||
password,
|
||||
});
|
||||
};
|
||||
let resDelta = delta.client.login(formDelta);
|
||||
|
||||
let formEpsilon = new Login({
|
||||
let formEpsilon: Login = {
|
||||
username_or_email: "lemmy_epsilon",
|
||||
password,
|
||||
});
|
||||
};
|
||||
let resEpsilon = epsilon.client.login(formEpsilon);
|
||||
|
||||
let res = await Promise.all([
|
||||
|
@ -138,93 +137,60 @@ export async function setupLogins() {
|
|||
resEpsilon,
|
||||
]);
|
||||
|
||||
alpha.auth = res[0].jwt;
|
||||
beta.auth = res[1].jwt;
|
||||
gamma.auth = res[2].jwt;
|
||||
delta.auth = res[3].jwt;
|
||||
epsilon.auth = res[4].jwt;
|
||||
alpha.auth = res[0].jwt ?? "";
|
||||
beta.auth = res[1].jwt ?? "";
|
||||
gamma.auth = res[2].jwt ?? "";
|
||||
delta.auth = res[3].jwt ?? "";
|
||||
epsilon.auth = res[4].jwt ?? "";
|
||||
|
||||
// Registration applications are now enabled by default, need to disable them
|
||||
let editSiteForm = new EditSite({
|
||||
require_application: Some(false),
|
||||
federation_debug: Some(true),
|
||||
name: None,
|
||||
sidebar: None,
|
||||
description: None,
|
||||
icon: None,
|
||||
banner: None,
|
||||
enable_downvotes: None,
|
||||
open_registration: None,
|
||||
enable_nsfw: None,
|
||||
community_creation_admin_only: None,
|
||||
require_email_verification: None,
|
||||
application_question: None,
|
||||
private_instance: None,
|
||||
default_theme: None,
|
||||
default_post_listing_type: None,
|
||||
legal_information: None,
|
||||
application_email_admins: None,
|
||||
hide_modlog_mod_names: None,
|
||||
discussion_languages: None,
|
||||
slur_filter_regex: None,
|
||||
actor_name_max_length: None,
|
||||
rate_limit_message: Some(999),
|
||||
rate_limit_message_per_second: None,
|
||||
rate_limit_post: Some(999),
|
||||
rate_limit_post_per_second: None,
|
||||
rate_limit_register: Some(999),
|
||||
rate_limit_register_per_second: None,
|
||||
rate_limit_image: Some(999),
|
||||
rate_limit_image_per_second: None,
|
||||
rate_limit_comment: Some(999),
|
||||
rate_limit_comment_per_second: None,
|
||||
rate_limit_search: Some(999),
|
||||
rate_limit_search_per_second: None,
|
||||
federation_enabled: None,
|
||||
federation_worker_count: None,
|
||||
captcha_enabled: None,
|
||||
captcha_difficulty: None,
|
||||
allowed_instances: None,
|
||||
blocked_instances: None,
|
||||
let editSiteForm: EditSite = {
|
||||
require_application: false,
|
||||
federation_debug: true,
|
||||
rate_limit_message: 999,
|
||||
rate_limit_post: 999,
|
||||
rate_limit_register: 999,
|
||||
rate_limit_image: 999,
|
||||
rate_limit_comment: 999,
|
||||
rate_limit_search: 999,
|
||||
auth: "",
|
||||
taglines: None,
|
||||
});
|
||||
};
|
||||
|
||||
// Set the blocks and auths for each
|
||||
editSiteForm.auth = alpha.auth.unwrap();
|
||||
editSiteForm.allowed_instances = Some([
|
||||
editSiteForm.auth = alpha.auth;
|
||||
editSiteForm.allowed_instances = [
|
||||
"lemmy-beta",
|
||||
"lemmy-gamma",
|
||||
"lemmy-delta",
|
||||
"lemmy-epsilon",
|
||||
]);
|
||||
];
|
||||
await alpha.client.editSite(editSiteForm);
|
||||
|
||||
editSiteForm.auth = beta.auth.unwrap();
|
||||
editSiteForm.allowed_instances = Some([
|
||||
editSiteForm.auth = beta.auth;
|
||||
editSiteForm.allowed_instances = [
|
||||
"lemmy-alpha",
|
||||
"lemmy-gamma",
|
||||
"lemmy-delta",
|
||||
"lemmy-epsilon",
|
||||
]);
|
||||
];
|
||||
await beta.client.editSite(editSiteForm);
|
||||
|
||||
editSiteForm.auth = gamma.auth.unwrap();
|
||||
editSiteForm.allowed_instances = Some([
|
||||
editSiteForm.auth = gamma.auth;
|
||||
editSiteForm.allowed_instances = [
|
||||
"lemmy-alpha",
|
||||
"lemmy-beta",
|
||||
"lemmy-delta",
|
||||
"lemmy-epsilon",
|
||||
]);
|
||||
];
|
||||
await gamma.client.editSite(editSiteForm);
|
||||
|
||||
editSiteForm.allowed_instances = Some(["lemmy-beta"]);
|
||||
editSiteForm.auth = delta.auth.unwrap();
|
||||
editSiteForm.allowed_instances = ["lemmy-beta"];
|
||||
editSiteForm.auth = delta.auth;
|
||||
await delta.client.editSite(editSiteForm);
|
||||
|
||||
editSiteForm.auth = epsilon.auth.unwrap();
|
||||
editSiteForm.allowed_instances = Some([]);
|
||||
editSiteForm.blocked_instances = Some(["lemmy-alpha"]);
|
||||
editSiteForm.auth = epsilon.auth;
|
||||
editSiteForm.allowed_instances = [];
|
||||
editSiteForm.blocked_instances = ["lemmy-alpha"];
|
||||
await epsilon.client.editSite(editSiteForm);
|
||||
|
||||
// Create the main alpha/beta communities
|
||||
|
@ -237,32 +203,25 @@ export async function createPost(
|
|||
community_id: number
|
||||
): Promise<PostResponse> {
|
||||
let name = randomString(5);
|
||||
let body = Some(randomString(10));
|
||||
let url = Some("https://google.com/");
|
||||
let form = new CreatePost({
|
||||
let body = randomString(10);
|
||||
let url = "https://google.com/";
|
||||
let form: CreatePost = {
|
||||
name,
|
||||
url,
|
||||
body,
|
||||
auth: api.auth.unwrap(),
|
||||
auth: api.auth,
|
||||
community_id,
|
||||
nsfw: None,
|
||||
honeypot: None,
|
||||
language_id: None,
|
||||
});
|
||||
};
|
||||
return api.client.createPost(form);
|
||||
}
|
||||
|
||||
export async function editPost(api: API, post: Post): Promise<PostResponse> {
|
||||
let name = Some("A jest test federated post, updated");
|
||||
let form = new EditPost({
|
||||
let name = "A jest test federated post, updated";
|
||||
let form: EditPost = {
|
||||
name,
|
||||
post_id: post.id,
|
||||
auth: api.auth.unwrap(),
|
||||
nsfw: None,
|
||||
url: None,
|
||||
body: None,
|
||||
language_id: None,
|
||||
});
|
||||
auth: api.auth,
|
||||
};
|
||||
return api.client.editPost(form);
|
||||
}
|
||||
|
||||
|
@ -271,11 +230,11 @@ export async function deletePost(
|
|||
deleted: boolean,
|
||||
post: Post
|
||||
): Promise<PostResponse> {
|
||||
let form = new DeletePost({
|
||||
let form: DeletePost = {
|
||||
post_id: post.id,
|
||||
deleted: deleted,
|
||||
auth: api.auth.unwrap(),
|
||||
});
|
||||
auth: api.auth,
|
||||
};
|
||||
return api.client.deletePost(form);
|
||||
}
|
||||
|
||||
|
@ -284,12 +243,11 @@ export async function removePost(
|
|||
removed: boolean,
|
||||
post: Post
|
||||
): Promise<PostResponse> {
|
||||
let form = new RemovePost({
|
||||
let form: RemovePost = {
|
||||
post_id: post.id,
|
||||
removed,
|
||||
auth: api.auth.unwrap(),
|
||||
reason: None,
|
||||
});
|
||||
auth: api.auth,
|
||||
};
|
||||
return api.client.removePost(form);
|
||||
}
|
||||
|
||||
|
@ -298,12 +256,12 @@ export async function featurePost(
|
|||
featured: boolean,
|
||||
post: Post
|
||||
): Promise<PostResponse> {
|
||||
let form = new FeaturePost({
|
||||
let form: FeaturePost = {
|
||||
post_id: post.id,
|
||||
featured,
|
||||
feature_type: PostFeatureType.Community,
|
||||
auth: api.auth.unwrap(),
|
||||
});
|
||||
auth: api.auth,
|
||||
};
|
||||
return api.client.featurePost(form);
|
||||
}
|
||||
|
||||
|
@ -312,11 +270,11 @@ export async function lockPost(
|
|||
locked: boolean,
|
||||
post: Post
|
||||
): Promise<PostResponse> {
|
||||
let form = new LockPost({
|
||||
let form: LockPost = {
|
||||
post_id: post.id,
|
||||
locked,
|
||||
auth: api.auth.unwrap(),
|
||||
});
|
||||
auth: api.auth,
|
||||
};
|
||||
return api.client.lockPost(form);
|
||||
}
|
||||
|
||||
|
@ -324,10 +282,10 @@ export async function resolvePost(
|
|||
api: API,
|
||||
post: Post
|
||||
): Promise<ResolveObjectResponse> {
|
||||
let form = new ResolveObject({
|
||||
let form: ResolveObject = {
|
||||
q: post.ap_id,
|
||||
auth: api.auth,
|
||||
});
|
||||
};
|
||||
return api.client.resolveObject(form);
|
||||
}
|
||||
|
||||
|
@ -335,18 +293,12 @@ export async function searchPostLocal(
|
|||
api: API,
|
||||
post: Post
|
||||
): Promise<SearchResponse> {
|
||||
let form = new Search({
|
||||
let form: Search = {
|
||||
q: post.name,
|
||||
type_: Some(SearchType.Posts),
|
||||
sort: Some(SortType.TopAll),
|
||||
community_id: None,
|
||||
community_name: None,
|
||||
creator_id: None,
|
||||
listing_type: None,
|
||||
page: None,
|
||||
limit: None,
|
||||
type_: SearchType.Posts,
|
||||
sort: SortType.TopAll,
|
||||
auth: api.auth,
|
||||
});
|
||||
};
|
||||
return api.client.search(form);
|
||||
}
|
||||
|
||||
|
@ -354,11 +306,10 @@ export async function getPost(
|
|||
api: API,
|
||||
post_id: number
|
||||
): Promise<GetPostResponse> {
|
||||
let form = new GetPost({
|
||||
id: Some(post_id),
|
||||
comment_id: None,
|
||||
let form: GetPost = {
|
||||
id: post_id,
|
||||
auth: api.auth,
|
||||
});
|
||||
};
|
||||
return api.client.getPost(form);
|
||||
}
|
||||
|
||||
|
@ -366,19 +317,12 @@ export async function getComments(
|
|||
api: API,
|
||||
post_id: number
|
||||
): Promise<GetCommentsResponse> {
|
||||
let form = new GetComments({
|
||||
post_id: Some(post_id),
|
||||
type_: Some(ListingType.All),
|
||||
sort: Some(CommentSortType.New), // TODO this sort might be wrong
|
||||
max_depth: None,
|
||||
page: None,
|
||||
limit: None,
|
||||
community_id: None,
|
||||
community_name: None,
|
||||
saved_only: None,
|
||||
parent_id: None,
|
||||
let form: GetComments = {
|
||||
post_id: post_id,
|
||||
type_: ListingType.All,
|
||||
sort: CommentSortType.New,
|
||||
auth: api.auth,
|
||||
});
|
||||
};
|
||||
return api.client.getComments(form);
|
||||
}
|
||||
|
||||
|
@ -386,10 +330,10 @@ export async function resolveComment(
|
|||
api: API,
|
||||
comment: Comment
|
||||
): Promise<ResolveObjectResponse> {
|
||||
let form = new ResolveObject({
|
||||
let form: ResolveObject = {
|
||||
q: comment.ap_id,
|
||||
auth: api.auth,
|
||||
});
|
||||
};
|
||||
return api.client.resolveObject(form);
|
||||
}
|
||||
|
||||
|
@ -397,10 +341,10 @@ export async function resolveBetaCommunity(
|
|||
api: API
|
||||
): Promise<ResolveObjectResponse> {
|
||||
// Use short-hand search url
|
||||
let form = new ResolveObject({
|
||||
let form: ResolveObject = {
|
||||
q: "!main@lemmy-beta:8551",
|
||||
auth: api.auth,
|
||||
});
|
||||
};
|
||||
return api.client.resolveObject(form);
|
||||
}
|
||||
|
||||
|
@ -408,10 +352,10 @@ export async function resolveCommunity(
|
|||
api: API,
|
||||
q: string
|
||||
): Promise<ResolveObjectResponse> {
|
||||
let form = new ResolveObject({
|
||||
let form: ResolveObject = {
|
||||
q,
|
||||
auth: api.auth,
|
||||
});
|
||||
};
|
||||
return api.client.resolveObject(form);
|
||||
}
|
||||
|
||||
|
@ -419,10 +363,10 @@ export async function resolvePerson(
|
|||
api: API,
|
||||
apShortname: string
|
||||
): Promise<ResolveObjectResponse> {
|
||||
let form = new ResolveObject({
|
||||
let form: ResolveObject = {
|
||||
q: apShortname,
|
||||
auth: api.auth,
|
||||
});
|
||||
};
|
||||
return api.client.resolveObject(form);
|
||||
}
|
||||
|
||||
|
@ -433,14 +377,12 @@ export async function banPersonFromSite(
|
|||
remove_data: boolean
|
||||
): Promise<BanPersonResponse> {
|
||||
// Make sure lemmy-beta/c/main is cached on lemmy_alpha
|
||||
let form = new BanPerson({
|
||||
let form: BanPerson = {
|
||||
person_id,
|
||||
ban,
|
||||
remove_data: Some(remove_data),
|
||||
auth: api.auth.unwrap(),
|
||||
reason: None,
|
||||
expires: None,
|
||||
});
|
||||
remove_data: remove_data,
|
||||
auth: api.auth,
|
||||
};
|
||||
return api.client.banPerson(form);
|
||||
}
|
||||
|
||||
|
@ -451,15 +393,13 @@ export async function banPersonFromCommunity(
|
|||
remove_data: boolean,
|
||||
ban: boolean
|
||||
): Promise<BanFromCommunityResponse> {
|
||||
let form = new BanFromCommunity({
|
||||
let form: BanFromCommunity = {
|
||||
person_id,
|
||||
community_id,
|
||||
remove_data: Some(remove_data),
|
||||
remove_data: remove_data,
|
||||
ban,
|
||||
reason: None,
|
||||
expires: None,
|
||||
auth: api.auth.unwrap(),
|
||||
});
|
||||
auth: api.auth,
|
||||
};
|
||||
return api.client.banFromCommunity(form);
|
||||
}
|
||||
|
||||
|
@ -468,11 +408,11 @@ export async function followCommunity(
|
|||
follow: boolean,
|
||||
community_id: number
|
||||
): Promise<CommunityResponse> {
|
||||
let form = new FollowCommunity({
|
||||
let form: FollowCommunity = {
|
||||
community_id,
|
||||
follow,
|
||||
auth: api.auth.unwrap(),
|
||||
});
|
||||
auth: api.auth,
|
||||
};
|
||||
return api.client.followCommunity(form);
|
||||
}
|
||||
|
||||
|
@ -481,11 +421,11 @@ export async function likePost(
|
|||
score: number,
|
||||
post: Post
|
||||
): Promise<PostResponse> {
|
||||
let form = new CreatePostLike({
|
||||
let form: CreatePostLike = {
|
||||
post_id: post.id,
|
||||
score: score,
|
||||
auth: api.auth.unwrap(),
|
||||
});
|
||||
auth: api.auth,
|
||||
};
|
||||
|
||||
return api.client.likePost(form);
|
||||
}
|
||||
|
@ -493,33 +433,28 @@ export async function likePost(
|
|||
export async function createComment(
|
||||
api: API,
|
||||
post_id: number,
|
||||
parent_id: Option<number>,
|
||||
parent_id?: number,
|
||||
content = "a jest test comment"
|
||||
): Promise<CommentResponse> {
|
||||
let form = new CreateComment({
|
||||
let form: CreateComment = {
|
||||
content,
|
||||
post_id,
|
||||
parent_id,
|
||||
form_id: None,
|
||||
language_id: None,
|
||||
auth: api.auth.unwrap(),
|
||||
});
|
||||
auth: api.auth,
|
||||
};
|
||||
return api.client.createComment(form);
|
||||
}
|
||||
|
||||
export async function editComment(
|
||||
api: API,
|
||||
comment_id: number,
|
||||
content = Some("A jest test federated comment update")
|
||||
content = "A jest test federated comment update"
|
||||
): Promise<CommentResponse> {
|
||||
let form = new EditComment({
|
||||
let form: EditComment = {
|
||||
content,
|
||||
comment_id,
|
||||
form_id: None,
|
||||
language_id: None,
|
||||
distinguished: None,
|
||||
auth: api.auth.unwrap(),
|
||||
});
|
||||
auth: api.auth,
|
||||
};
|
||||
return api.client.editComment(form);
|
||||
}
|
||||
|
||||
|
@ -528,11 +463,11 @@ export async function deleteComment(
|
|||
deleted: boolean,
|
||||
comment_id: number
|
||||
): Promise<CommentResponse> {
|
||||
let form = new DeleteComment({
|
||||
let form: DeleteComment = {
|
||||
comment_id,
|
||||
deleted,
|
||||
auth: api.auth.unwrap(),
|
||||
});
|
||||
auth: api.auth,
|
||||
};
|
||||
return api.client.deleteComment(form);
|
||||
}
|
||||
|
||||
|
@ -541,25 +476,22 @@ export async function removeComment(
|
|||
removed: boolean,
|
||||
comment_id: number
|
||||
): Promise<CommentResponse> {
|
||||
let form = new RemoveComment({
|
||||
let form: RemoveComment = {
|
||||
comment_id,
|
||||
removed,
|
||||
reason: None,
|
||||
auth: api.auth.unwrap(),
|
||||
});
|
||||
auth: api.auth,
|
||||
};
|
||||
return api.client.removeComment(form);
|
||||
}
|
||||
|
||||
export async function getMentions(
|
||||
api: API
|
||||
): Promise<GetPersonMentionsResponse> {
|
||||
let form = new GetPersonMentions({
|
||||
sort: Some(CommentSortType.New),
|
||||
unread_only: Some(false),
|
||||
auth: api.auth.unwrap(),
|
||||
page: None,
|
||||
limit: None,
|
||||
});
|
||||
let form: GetPersonMentions = {
|
||||
sort: CommentSortType.New,
|
||||
unread_only: false,
|
||||
auth: api.auth,
|
||||
};
|
||||
return api.client.getPersonMentions(form);
|
||||
}
|
||||
|
||||
|
@ -568,11 +500,11 @@ export async function likeComment(
|
|||
score: number,
|
||||
comment: Comment
|
||||
): Promise<CommentResponse> {
|
||||
let form = new CreateCommentLike({
|
||||
let form: CreateCommentLike = {
|
||||
comment_id: comment.id,
|
||||
score,
|
||||
auth: api.auth.unwrap(),
|
||||
});
|
||||
auth: api.auth,
|
||||
};
|
||||
return api.client.likeComment(form);
|
||||
}
|
||||
|
||||
|
@ -580,17 +512,13 @@ export async function createCommunity(
|
|||
api: API,
|
||||
name_: string = randomString(5)
|
||||
): Promise<CommunityResponse> {
|
||||
let description = Some("a sample description");
|
||||
let form = new CreateCommunity({
|
||||
let description = "a sample description";
|
||||
let form: CreateCommunity = {
|
||||
name: name_,
|
||||
title: name_,
|
||||
description,
|
||||
nsfw: None,
|
||||
icon: None,
|
||||
banner: None,
|
||||
posting_restricted_to_mods: None,
|
||||
auth: api.auth.unwrap(),
|
||||
});
|
||||
auth: api.auth,
|
||||
};
|
||||
return api.client.createCommunity(form);
|
||||
}
|
||||
|
||||
|
@ -598,11 +526,10 @@ export async function getCommunity(
|
|||
api: API,
|
||||
id: number
|
||||
): Promise<CommunityResponse> {
|
||||
let form = new GetCommunity({
|
||||
id: Some(id),
|
||||
name: None,
|
||||
let form: GetCommunity = {
|
||||
id,
|
||||
auth: api.auth,
|
||||
});
|
||||
};
|
||||
return api.client.getCommunity(form);
|
||||
}
|
||||
|
||||
|
@ -611,11 +538,11 @@ export async function deleteCommunity(
|
|||
deleted: boolean,
|
||||
community_id: number
|
||||
): Promise<CommunityResponse> {
|
||||
let form = new DeleteCommunity({
|
||||
let form: DeleteCommunity = {
|
||||
community_id,
|
||||
deleted,
|
||||
auth: api.auth.unwrap(),
|
||||
});
|
||||
auth: api.auth,
|
||||
};
|
||||
return api.client.deleteCommunity(form);
|
||||
}
|
||||
|
||||
|
@ -624,13 +551,11 @@ export async function removeCommunity(
|
|||
removed: boolean,
|
||||
community_id: number
|
||||
): Promise<CommunityResponse> {
|
||||
let form = new RemoveCommunity({
|
||||
let form: RemoveCommunity = {
|
||||
community_id,
|
||||
removed,
|
||||
reason: None,
|
||||
expires: None,
|
||||
auth: api.auth.unwrap(),
|
||||
});
|
||||
auth: api.auth,
|
||||
};
|
||||
return api.client.removeCommunity(form);
|
||||
}
|
||||
|
||||
|
@ -639,11 +564,11 @@ export async function createPrivateMessage(
|
|||
recipient_id: number
|
||||
): Promise<PrivateMessageResponse> {
|
||||
let content = "A jest test federated private message";
|
||||
let form = new CreatePrivateMessage({
|
||||
let form: CreatePrivateMessage = {
|
||||
content,
|
||||
recipient_id,
|
||||
auth: api.auth.unwrap(),
|
||||
});
|
||||
auth: api.auth,
|
||||
};
|
||||
return api.client.createPrivateMessage(form);
|
||||
}
|
||||
|
||||
|
@ -652,11 +577,11 @@ export async function editPrivateMessage(
|
|||
private_message_id: number
|
||||
): Promise<PrivateMessageResponse> {
|
||||
let updatedContent = "A jest test federated private message edited";
|
||||
let form = new EditPrivateMessage({
|
||||
let form: EditPrivateMessage = {
|
||||
content: updatedContent,
|
||||
private_message_id,
|
||||
auth: api.auth.unwrap(),
|
||||
});
|
||||
auth: api.auth,
|
||||
};
|
||||
return api.client.editPrivateMessage(form);
|
||||
}
|
||||
|
||||
|
@ -665,11 +590,11 @@ export async function deletePrivateMessage(
|
|||
deleted: boolean,
|
||||
private_message_id: number
|
||||
): Promise<PrivateMessageResponse> {
|
||||
let form = new DeletePrivateMessage({
|
||||
let form: DeletePrivateMessage = {
|
||||
deleted,
|
||||
private_message_id,
|
||||
auth: api.auth.unwrap(),
|
||||
});
|
||||
auth: api.auth,
|
||||
};
|
||||
return api.client.deletePrivateMessage(form);
|
||||
}
|
||||
|
||||
|
@ -677,78 +602,49 @@ export async function registerUser(
|
|||
api: API,
|
||||
username: string = randomString(5)
|
||||
): Promise<LoginResponse> {
|
||||
let form = new Register({
|
||||
let form: Register = {
|
||||
username,
|
||||
password,
|
||||
password_verify: password,
|
||||
show_nsfw: true,
|
||||
email: None,
|
||||
captcha_uuid: None,
|
||||
captcha_answer: None,
|
||||
honeypot: None,
|
||||
answer: None,
|
||||
});
|
||||
};
|
||||
return api.client.register(form);
|
||||
}
|
||||
|
||||
export async function saveUserSettingsBio(api: API): Promise<LoginResponse> {
|
||||
let form = new SaveUserSettings({
|
||||
show_nsfw: Some(true),
|
||||
theme: Some("darkly"),
|
||||
default_sort_type: Some(Object.keys(SortType).indexOf(SortType.Active)),
|
||||
default_listing_type: Some(
|
||||
Object.keys(ListingType).indexOf(ListingType.All)
|
||||
),
|
||||
interface_language: Some("en"),
|
||||
show_avatars: Some(true),
|
||||
send_notifications_to_email: Some(false),
|
||||
bio: Some("a changed bio"),
|
||||
avatar: None,
|
||||
banner: None,
|
||||
display_name: None,
|
||||
email: None,
|
||||
matrix_user_id: None,
|
||||
show_scores: None,
|
||||
show_read_posts: None,
|
||||
show_bot_accounts: None,
|
||||
show_new_post_notifs: None,
|
||||
bot_account: None,
|
||||
discussion_languages: None,
|
||||
auth: api.auth.unwrap(),
|
||||
});
|
||||
let form: SaveUserSettings = {
|
||||
show_nsfw: true,
|
||||
theme: "darkly",
|
||||
default_sort_type: Object.keys(SortType).indexOf(SortType.Active),
|
||||
default_listing_type: Object.keys(ListingType).indexOf(ListingType.All),
|
||||
interface_language: "en",
|
||||
show_avatars: true,
|
||||
send_notifications_to_email: false,
|
||||
bio: "a changed bio",
|
||||
auth: api.auth,
|
||||
};
|
||||
return saveUserSettings(api, form);
|
||||
}
|
||||
|
||||
export async function saveUserSettingsFederated(
|
||||
api: API
|
||||
): Promise<LoginResponse> {
|
||||
let avatar = Some("https://image.flaticon.com/icons/png/512/35/35896.png");
|
||||
let banner = Some("https://image.flaticon.com/icons/png/512/36/35896.png");
|
||||
let bio = Some("a changed bio");
|
||||
let form = new SaveUserSettings({
|
||||
show_nsfw: Some(false),
|
||||
theme: Some(""),
|
||||
default_sort_type: Some(Object.keys(SortType).indexOf(SortType.Hot)),
|
||||
default_listing_type: Some(
|
||||
Object.keys(ListingType).indexOf(ListingType.All)
|
||||
),
|
||||
interface_language: Some(""),
|
||||
let avatar = "https://image.flaticon.com/icons/png/512/35/35896.png";
|
||||
let banner = "https://image.flaticon.com/icons/png/512/36/35896.png";
|
||||
let bio = "a changed bio";
|
||||
let form: SaveUserSettings = {
|
||||
show_nsfw: false,
|
||||
default_sort_type: Object.keys(SortType).indexOf(SortType.Hot),
|
||||
default_listing_type: Object.keys(ListingType).indexOf(ListingType.All),
|
||||
interface_language: "",
|
||||
avatar,
|
||||
banner,
|
||||
display_name: Some("user321"),
|
||||
show_avatars: Some(false),
|
||||
send_notifications_to_email: Some(false),
|
||||
display_name: "user321",
|
||||
show_avatars: false,
|
||||
send_notifications_to_email: false,
|
||||
bio,
|
||||
email: None,
|
||||
show_scores: None,
|
||||
show_read_posts: None,
|
||||
matrix_user_id: None,
|
||||
bot_account: None,
|
||||
show_bot_accounts: None,
|
||||
show_new_post_notifs: None,
|
||||
discussion_languages: None,
|
||||
auth: api.auth.unwrap(),
|
||||
});
|
||||
auth: api.auth,
|
||||
};
|
||||
return await saveUserSettings(alpha, form);
|
||||
}
|
||||
|
||||
|
@ -760,38 +656,35 @@ export async function saveUserSettings(
|
|||
}
|
||||
|
||||
export async function deleteUser(api: API): Promise<DeleteAccountResponse> {
|
||||
let form = new DeleteAccount({
|
||||
auth: api.auth.unwrap(),
|
||||
let form: DeleteAccount = {
|
||||
auth: api.auth,
|
||||
password,
|
||||
});
|
||||
};
|
||||
return api.client.deleteAccount(form);
|
||||
}
|
||||
|
||||
export async function getSite(api: API): Promise<GetSiteResponse> {
|
||||
let form = new GetSite({
|
||||
let form: GetSite = {
|
||||
auth: api.auth,
|
||||
});
|
||||
};
|
||||
return api.client.getSite(form);
|
||||
}
|
||||
|
||||
export async function listPrivateMessages(
|
||||
api: API
|
||||
): Promise<PrivateMessagesResponse> {
|
||||
let form = new GetPrivateMessages({
|
||||
auth: api.auth.unwrap(),
|
||||
unread_only: Some(false),
|
||||
page: None,
|
||||
limit: None,
|
||||
});
|
||||
let form: GetPrivateMessages = {
|
||||
auth: api.auth,
|
||||
unread_only: false,
|
||||
};
|
||||
return api.client.getPrivateMessages(form);
|
||||
}
|
||||
|
||||
export async function unfollowRemotes(api: API): Promise<GetSiteResponse> {
|
||||
// Unfollow all remote communities
|
||||
let site = await getSite(api);
|
||||
let remoteFollowed = site.my_user
|
||||
.unwrap()
|
||||
.follows.filter(c => c.community.local == false);
|
||||
let remoteFollowed =
|
||||
site.my_user?.follows.filter(c => c.community.local == false) ?? [];
|
||||
for (let cu of remoteFollowed) {
|
||||
await followCommunity(api, false, cu.community.id);
|
||||
}
|
||||
|
@ -801,12 +694,8 @@ export async function unfollowRemotes(api: API): Promise<GetSiteResponse> {
|
|||
|
||||
export async function followBeta(api: API): Promise<CommunityResponse> {
|
||||
let betaCommunity = (await resolveBetaCommunity(api)).community;
|
||||
if (betaCommunity.isSome()) {
|
||||
let follow = await followCommunity(
|
||||
api,
|
||||
true,
|
||||
betaCommunity.unwrap().community.id
|
||||
);
|
||||
if (betaCommunity) {
|
||||
let follow = await followCommunity(api, true, betaCommunity.community.id);
|
||||
return follow;
|
||||
} else {
|
||||
return Promise.reject("no community worked");
|
||||
|
@ -818,24 +707,20 @@ export async function reportPost(
|
|||
post_id: number,
|
||||
reason: string
|
||||
): Promise<PostReportResponse> {
|
||||
let form = new CreatePostReport({
|
||||
let form: CreatePostReport = {
|
||||
post_id,
|
||||
reason,
|
||||
auth: api.auth.unwrap(),
|
||||
});
|
||||
auth: api.auth,
|
||||
};
|
||||
return api.client.createPostReport(form);
|
||||
}
|
||||
|
||||
export async function listPostReports(
|
||||
api: API
|
||||
): Promise<ListPostReportsResponse> {
|
||||
let form = new ListPostReports({
|
||||
auth: api.auth.unwrap(),
|
||||
page: None,
|
||||
limit: None,
|
||||
community_id: None,
|
||||
unresolved_only: None,
|
||||
});
|
||||
let form: ListPostReports = {
|
||||
auth: api.auth,
|
||||
};
|
||||
return api.client.listPostReports(form);
|
||||
}
|
||||
|
||||
|
@ -844,24 +729,20 @@ export async function reportComment(
|
|||
comment_id: number,
|
||||
reason: string
|
||||
): Promise<CommentReportResponse> {
|
||||
let form = new CreateCommentReport({
|
||||
let form: CreateCommentReport = {
|
||||
comment_id,
|
||||
reason,
|
||||
auth: api.auth.unwrap(),
|
||||
});
|
||||
auth: api.auth,
|
||||
};
|
||||
return api.client.createCommentReport(form);
|
||||
}
|
||||
|
||||
export async function listCommentReports(
|
||||
api: API
|
||||
): Promise<ListCommentReportsResponse> {
|
||||
let form = new ListCommentReports({
|
||||
page: None,
|
||||
limit: None,
|
||||
community_id: None,
|
||||
unresolved_only: None,
|
||||
auth: api.auth.unwrap(),
|
||||
});
|
||||
let form: ListCommentReports = {
|
||||
auth: api.auth,
|
||||
};
|
||||
return api.client.listCommentReports(form);
|
||||
}
|
||||
|
||||
|
@ -895,14 +776,14 @@ export async function unfollows() {
|
|||
await unfollowRemotes(epsilon);
|
||||
}
|
||||
|
||||
export function getCommentParentId(comment: Comment): Option<number> {
|
||||
export function getCommentParentId(comment: Comment): number | undefined {
|
||||
let split = comment.path.split(".");
|
||||
// remove the 0
|
||||
split.shift();
|
||||
|
||||
if (split.length > 1) {
|
||||
return Some(Number(split[split.length - 2]));
|
||||
return Number(split[split.length - 2]);
|
||||
} else {
|
||||
return None;
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
jest.setTimeout(120000);
|
||||
import { None } from "@sniptt/monads";
|
||||
import { PersonViewSafe } from "lemmy-js-client";
|
||||
|
||||
import {
|
||||
|
@ -27,42 +26,35 @@ beforeAll(async () => {
|
|||
let apShortname: string;
|
||||
|
||||
function assertUserFederation(
|
||||
userOne: PersonViewSafe,
|
||||
userTwo: PersonViewSafe
|
||||
userOne?: PersonViewSafe,
|
||||
userTwo?: PersonViewSafe
|
||||
) {
|
||||
expect(userOne.person.name).toBe(userTwo.person.name);
|
||||
expect(userOne.person.display_name.unwrapOr("none")).toBe(
|
||||
userTwo.person.display_name.unwrapOr("none")
|
||||
);
|
||||
expect(userOne.person.bio.unwrapOr("none")).toBe(
|
||||
userTwo.person.bio.unwrapOr("none")
|
||||
);
|
||||
expect(userOne.person.actor_id).toBe(userTwo.person.actor_id);
|
||||
expect(userOne.person.avatar.unwrapOr("none")).toBe(
|
||||
userTwo.person.avatar.unwrapOr("none")
|
||||
);
|
||||
expect(userOne.person.banner.unwrapOr("none")).toBe(
|
||||
userTwo.person.banner.unwrapOr("none")
|
||||
);
|
||||
expect(userOne.person.published).toBe(userTwo.person.published);
|
||||
expect(userOne?.person.name).toBe(userTwo?.person.name);
|
||||
expect(userOne?.person.display_name).toBe(userTwo?.person.display_name);
|
||||
expect(userOne?.person.bio).toBe(userTwo?.person.bio);
|
||||
expect(userOne?.person.actor_id).toBe(userTwo?.person.actor_id);
|
||||
expect(userOne?.person.avatar).toBe(userTwo?.person.avatar);
|
||||
expect(userOne?.person.banner).toBe(userTwo?.person.banner);
|
||||
expect(userOne?.person.published).toBe(userTwo?.person.published);
|
||||
}
|
||||
|
||||
test("Create user", async () => {
|
||||
let userRes = await registerUser(alpha);
|
||||
expect(userRes.jwt).toBeDefined();
|
||||
alpha.auth = userRes.jwt;
|
||||
alpha.auth = userRes.jwt ?? "";
|
||||
|
||||
let site = await getSite(alpha);
|
||||
expect(site.my_user).toBeDefined();
|
||||
apShortname = `@${
|
||||
site.my_user.unwrap().local_user_view.person.name
|
||||
}@lemmy-alpha:8541`;
|
||||
if (!site.my_user) {
|
||||
throw "Missing site user";
|
||||
}
|
||||
apShortname = `@${site.my_user.local_user_view.person.name}@lemmy-alpha:8541`;
|
||||
});
|
||||
|
||||
test("Set some user settings, check that they are federated", async () => {
|
||||
await saveUserSettingsFederated(alpha);
|
||||
let alphaPerson = (await resolvePerson(alpha, apShortname)).person.unwrap();
|
||||
let betaPerson = (await resolvePerson(beta, apShortname)).person.unwrap();
|
||||
let alphaPerson = (await resolvePerson(alpha, apShortname)).person;
|
||||
let betaPerson = (await resolvePerson(beta, apShortname)).person;
|
||||
assertUserFederation(alphaPerson, betaPerson);
|
||||
});
|
||||
|
||||
|
@ -71,37 +63,38 @@ test("Delete user", async () => {
|
|||
expect(userRes.jwt).toBeDefined();
|
||||
let user: API = {
|
||||
client: alpha.client,
|
||||
auth: userRes.jwt,
|
||||
auth: userRes.jwt ?? "",
|
||||
};
|
||||
|
||||
// make a local post and comment
|
||||
let alphaCommunity = (
|
||||
await resolveCommunity(user, "!main@lemmy-alpha:8541")
|
||||
).community.unwrap();
|
||||
let alphaCommunity = (await resolveCommunity(user, "!main@lemmy-alpha:8541"))
|
||||
.community;
|
||||
if (!alphaCommunity) {
|
||||
throw "Missing alpha community";
|
||||
}
|
||||
let localPost = (await createPost(user, alphaCommunity.community.id))
|
||||
.post_view.post;
|
||||
expect(localPost).toBeDefined();
|
||||
let localComment = (await createComment(user, localPost.id, None))
|
||||
.comment_view.comment;
|
||||
let localComment = (await createComment(user, localPost.id)).comment_view
|
||||
.comment;
|
||||
expect(localComment).toBeDefined();
|
||||
|
||||
// make a remote post and comment
|
||||
let betaCommunity = (await resolveBetaCommunity(user)).community.unwrap();
|
||||
let betaCommunity = (await resolveBetaCommunity(user)).community;
|
||||
if (!betaCommunity) {
|
||||
throw "Missing beta community";
|
||||
}
|
||||
let remotePost = (await createPost(user, betaCommunity.community.id))
|
||||
.post_view.post;
|
||||
expect(remotePost).toBeDefined();
|
||||
let remoteComment = (await createComment(user, remotePost.id, None))
|
||||
.comment_view.comment;
|
||||
let remoteComment = (await createComment(user, remotePost.id)).comment_view
|
||||
.comment;
|
||||
expect(remoteComment).toBeDefined();
|
||||
|
||||
await deleteUser(user);
|
||||
|
||||
expect((await resolvePost(alpha, localPost)).post.isNone()).toBe(true);
|
||||
expect((await resolveComment(alpha, localComment)).comment.isNone()).toBe(
|
||||
true
|
||||
);
|
||||
expect((await resolvePost(alpha, remotePost)).post.isNone()).toBe(true);
|
||||
expect((await resolveComment(alpha, remoteComment)).comment.isNone()).toBe(
|
||||
true
|
||||
);
|
||||
expect((await resolvePost(alpha, localPost)).post).toBeUndefined();
|
||||
expect((await resolveComment(alpha, localComment)).comment).toBeUndefined();
|
||||
expect((await resolvePost(alpha, remotePost)).post).toBeUndefined();
|
||||
expect((await resolveComment(alpha, remoteComment)).comment).toBeUndefined();
|
||||
});
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
"lib": ["es2017", "es7", "es6", "dom"],
|
||||
"outDir": "./dist",
|
||||
"target": "ES5",
|
||||
"strictNullChecks": true,
|
||||
"moduleResolution": "Node"
|
||||
},
|
||||
"include": [
|
||||
|
|
|
@ -596,11 +596,6 @@
|
|||
dependencies:
|
||||
"@sinonjs/commons" "^1.7.0"
|
||||
|
||||
"@sniptt/monads@^0.5.10":
|
||||
version "0.5.10"
|
||||
resolved "https://registry.yarnpkg.com/@sniptt/monads/-/monads-0.5.10.tgz#a80cd00738bbd682d36d36dd36bdc0bddc96eb76"
|
||||
integrity sha512-+agDOv9DpDV+9e2zN/Vmdk+XaqGx5Sykl0fqhqgiJ90r18nsBkxe44DmZ2sA1HYK+MSsBeZBiAr6pq4w+5uhfw==
|
||||
|
||||
"@tootallnate/once@1":
|
||||
version "1.1.2"
|
||||
resolved "https://registry.yarnpkg.com/@tootallnate/once/-/once-1.1.2.tgz#ccb91445360179a04e7fe6aff78c00ffc1eeaf82"
|
||||
|
@ -1077,11 +1072,6 @@ cjs-module-lexer@^1.0.0:
|
|||
resolved "https://registry.yarnpkg.com/cjs-module-lexer/-/cjs-module-lexer-1.2.2.tgz#9f84ba3244a512f3a54e5277e8eef4c489864e40"
|
||||
integrity sha512-cOU9usZw8/dXIXKtwa8pM0OTJQuJkxMN6w30csNRUerHfeQ5R6U3kkU/FtJeIf3M202OHfY2U8ccInBG7/xogA==
|
||||
|
||||
class-transformer@^0.5.1:
|
||||
version "0.5.1"
|
||||
resolved "https://registry.yarnpkg.com/class-transformer/-/class-transformer-0.5.1.tgz#24147d5dffd2a6cea930a3250a677addf96ab336"
|
||||
integrity sha512-SQa1Ws6hUbfC98vKGxZH3KFY0Y1lm5Zm0SY8XX9zbK7FJCyVEac3ATW0RIpwzW+oOfmHE5PMPufDG9hCfoEOMw==
|
||||
|
||||
cliui@^7.0.2:
|
||||
version "7.0.4"
|
||||
resolved "https://registry.yarnpkg.com/cliui/-/cliui-7.0.4.tgz#a0265ee655476fc807aea9df3df8df7783808b4f"
|
||||
|
@ -2373,15 +2363,12 @@ kleur@^3.0.3:
|
|||
resolved "https://registry.yarnpkg.com/kleur/-/kleur-3.0.3.tgz#a79c9ecc86ee1ce3fa6206d1216c501f147fc07e"
|
||||
integrity sha512-eTIzlVOSUR+JxdDFepEYcBMtZ9Qqdef+rnzWdRZuMbOywu5tO2w2N7rqjoANZ5k9vywhL6Br1VRjUIgTQx4E8w==
|
||||
|
||||
lemmy-js-client@0.17.0-rc.56:
|
||||
version "0.17.0-rc.56"
|
||||
resolved "https://registry.yarnpkg.com/lemmy-js-client/-/lemmy-js-client-0.17.0-rc.56.tgz#2c7abba9b8195826eb36401e7c5c2cb75609bcf2"
|
||||
integrity sha512-7MM5xV8H9fIr1TbM/4e9PFKJpwlD2t135pSiH92TFgdkTzOMf0mtLO2BWLAQ7Rq+XVoVgj/WSBR4BofJka8XRQ==
|
||||
lemmy-js-client@0.17.0-rc.60:
|
||||
version "0.17.0-rc.60"
|
||||
resolved "https://registry.yarnpkg.com/lemmy-js-client/-/lemmy-js-client-0.17.0-rc.60.tgz#6cabac42d842eb1f152d230be018090050476614"
|
||||
integrity sha512-Nl+DUBJde0KpKywNkX5wof9PDCmr6RuJlgukVfQRmW5rznYRKYnI1V+awf+9mUx1eNQ8jhnjVO+6XxOzMjloZA==
|
||||
dependencies:
|
||||
"@sniptt/monads" "^0.5.10"
|
||||
class-transformer "^0.5.1"
|
||||
node-fetch "2.6.6"
|
||||
reflect-metadata "^0.1.13"
|
||||
|
||||
leven@^3.1.0:
|
||||
version "3.1.0"
|
||||
|
@ -2761,11 +2748,6 @@ react-is@^17.0.1:
|
|||
resolved "https://registry.yarnpkg.com/react-is/-/react-is-17.0.2.tgz#e691d4a8e9c789365655539ab372762b0efb54f0"
|
||||
integrity sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w==
|
||||
|
||||
reflect-metadata@^0.1.13:
|
||||
version "0.1.13"
|
||||
resolved "https://registry.yarnpkg.com/reflect-metadata/-/reflect-metadata-0.1.13.tgz#67ae3ca57c972a2aa1642b10fe363fe32d49dc08"
|
||||
integrity sha512-Ts1Y/anZELhSsjMcU605fU9RE4Oi3p5ORujwbIKXfWa+0Zxs510Qrmrce5/Jowq3cHSZSJqBjypxmHarc+vEWg==
|
||||
|
||||
regexpp@^3.2.0:
|
||||
version "3.2.0"
|
||||
resolved "https://registry.yarnpkg.com/regexpp/-/regexpp-3.2.0.tgz#0425a2768d8f23bad70ca4b90461fa2f1213e1b2"
|
||||
|
|
Loading…
Reference in a new issue