mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-12-23 03:11:32 +00:00
Changing unit tests to api v2.
This commit is contained in:
parent
a27b7f8d1f
commit
5af8257e19
13 changed files with 2531 additions and 1125 deletions
51
api_tests/.eslintrc.json
Normal file
51
api_tests/.eslintrc.json
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
{
|
||||||
|
"root": true,
|
||||||
|
"env": {
|
||||||
|
"browser": true
|
||||||
|
},
|
||||||
|
"plugins": [
|
||||||
|
"jane"
|
||||||
|
],
|
||||||
|
"extends": [
|
||||||
|
"plugin:jane/recommended",
|
||||||
|
"plugin:jane/typescript"
|
||||||
|
],
|
||||||
|
"parser": "@typescript-eslint/parser",
|
||||||
|
"parserOptions": {
|
||||||
|
"project": "./tsconfig.json",
|
||||||
|
"warnOnUnsupportedTypeScriptVersion": false
|
||||||
|
},
|
||||||
|
"rules": {
|
||||||
|
"@typescript-eslint/camelcase": 0,
|
||||||
|
"@typescript-eslint/member-delimiter-style": 0,
|
||||||
|
"@typescript-eslint/no-empty-interface": 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,
|
||||||
|
"arrow-body-style": 0,
|
||||||
|
"curly": 0,
|
||||||
|
"eol-last": 0,
|
||||||
|
"eqeqeq": 0,
|
||||||
|
"func-style": 0,
|
||||||
|
"import/no-duplicates": 0,
|
||||||
|
"max-statements": 0,
|
||||||
|
"max-params": 0,
|
||||||
|
"new-cap": 0,
|
||||||
|
"no-console": 0,
|
||||||
|
"no-duplicate-imports": 0,
|
||||||
|
"no-extra-parens": 0,
|
||||||
|
"no-return-assign": 0,
|
||||||
|
"no-throw-literal": 0,
|
||||||
|
"no-trailing-spaces": 0,
|
||||||
|
"no-unused-expressions": 0,
|
||||||
|
"no-useless-constructor": 0,
|
||||||
|
"no-useless-escape": 0,
|
||||||
|
"no-var": 0,
|
||||||
|
"prefer-const": 0,
|
||||||
|
"prefer-rest-params": 0,
|
||||||
|
"quote-props": 0,
|
||||||
|
"unicorn/filename-case": 0
|
||||||
|
}
|
||||||
|
}
|
4
api_tests/.prettierrc.js
Normal file
4
api_tests/.prettierrc.js
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
module.exports = Object.assign(require('eslint-plugin-jane/prettier-ts'), {
|
||||||
|
arrowParens: 'avoid',
|
||||||
|
semi: true,
|
||||||
|
});
|
|
@ -7,14 +7,19 @@
|
||||||
"author": "Dessalines",
|
"author": "Dessalines",
|
||||||
"license": "AGPL-3.0",
|
"license": "AGPL-3.0",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
"lint": "tsc --noEmit && eslint --report-unused-disable-directives --ext .js,.ts,.tsx src",
|
||||||
|
"fix": "prettier --write src && eslint --fix src",
|
||||||
"api-test": "jest src/ -i --verbose"
|
"api-test": "jest src/ -i --verbose"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/jest": "^26.0.14",
|
"@types/jest": "^26.0.19",
|
||||||
"jest": "^26.4.2",
|
"jest": "^26.6.3",
|
||||||
"lemmy-js-client": "^1.0.14",
|
"lemmy-js-client": "1.0.17-beta3",
|
||||||
"node-fetch": "^2.6.1",
|
"node-fetch": "^2.6.1",
|
||||||
"ts-jest": "^26.4.1",
|
"ts-jest": "^26.4.4",
|
||||||
"typescript": "^4.0.3"
|
"prettier": "^2.1.2",
|
||||||
|
"eslint": "^7.10.0",
|
||||||
|
"eslint-plugin-jane": "^9.0.3",
|
||||||
|
"typescript": "^4.1.3"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@ import {
|
||||||
followBeta,
|
followBeta,
|
||||||
searchForBetaCommunity,
|
searchForBetaCommunity,
|
||||||
createComment,
|
createComment,
|
||||||
updateComment,
|
editComment,
|
||||||
deleteComment,
|
deleteComment,
|
||||||
removeComment,
|
removeComment,
|
||||||
getMentions,
|
getMentions,
|
||||||
|
@ -23,9 +23,7 @@ import {
|
||||||
delay,
|
delay,
|
||||||
longDelay,
|
longDelay,
|
||||||
} from './shared';
|
} from './shared';
|
||||||
import {
|
import { CommentView } from 'lemmy-js-client';
|
||||||
Comment,
|
|
||||||
} from 'lemmy-js-client';
|
|
||||||
|
|
||||||
import { PostResponse } from 'lemmy-js-client';
|
import { PostResponse } from 'lemmy-js-client';
|
||||||
|
|
||||||
|
@ -39,7 +37,7 @@ beforeAll(async () => {
|
||||||
await longDelay();
|
await longDelay();
|
||||||
postRes = await createPost(
|
postRes = await createPost(
|
||||||
alpha,
|
alpha,
|
||||||
search.communities.filter(c => c.local == false)[0].id
|
search.communities.find(c => c.community.local == false).community.id
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -49,34 +47,35 @@ afterAll(async () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
function assertCommentFederation(
|
function assertCommentFederation(
|
||||||
commentOne: Comment,
|
commentOne: CommentView,
|
||||||
commentTwo: Comment) {
|
commentTwo: CommentView
|
||||||
expect(commentOne.ap_id).toBe(commentOne.ap_id);
|
) {
|
||||||
expect(commentOne.content).toBe(commentTwo.content);
|
expect(commentOne.comment.ap_id).toBe(commentOne.comment.ap_id);
|
||||||
expect(commentOne.creator_name).toBe(commentTwo.creator_name);
|
expect(commentOne.comment.content).toBe(commentTwo.comment.content);
|
||||||
expect(commentOne.community_actor_id).toBe(commentTwo.community_actor_id);
|
expect(commentOne.creator.name).toBe(commentTwo.creator.name);
|
||||||
expect(commentOne.published).toBe(commentTwo.published);
|
expect(commentOne.community.actor_id).toBe(commentTwo.community.actor_id);
|
||||||
expect(commentOne.updated).toBe(commentOne.updated);
|
expect(commentOne.comment.published).toBe(commentTwo.comment.published);
|
||||||
expect(commentOne.deleted).toBe(commentOne.deleted);
|
expect(commentOne.comment.updated).toBe(commentOne.comment.updated);
|
||||||
expect(commentOne.removed).toBe(commentOne.removed);
|
expect(commentOne.comment.deleted).toBe(commentOne.comment.deleted);
|
||||||
|
expect(commentOne.comment.removed).toBe(commentOne.comment.removed);
|
||||||
}
|
}
|
||||||
|
|
||||||
test('Create a comment', async () => {
|
test('Create a comment', async () => {
|
||||||
let commentRes = await createComment(alpha, postRes.post.id);
|
let commentRes = await createComment(alpha, postRes.post_view.post.id);
|
||||||
expect(commentRes.comment.content).toBeDefined();
|
expect(commentRes.comment_view.comment.content).toBeDefined();
|
||||||
expect(commentRes.comment.community_local).toBe(false);
|
expect(commentRes.comment_view.community.local).toBe(false);
|
||||||
expect(commentRes.comment.creator_local).toBe(true);
|
expect(commentRes.comment_view.creator.local).toBe(true);
|
||||||
expect(commentRes.comment.score).toBe(1);
|
expect(commentRes.comment_view.counts.score).toBe(1);
|
||||||
await longDelay();
|
await longDelay();
|
||||||
|
|
||||||
// Make sure that comment is liked on beta
|
// Make sure that comment is liked on beta
|
||||||
let searchBeta = await searchComment(beta, commentRes.comment);
|
let searchBeta = await searchComment(beta, commentRes.comment_view.comment);
|
||||||
let betaComment = searchBeta.comments[0];
|
let betaComment = searchBeta.comments[0];
|
||||||
expect(betaComment).toBeDefined();
|
expect(betaComment).toBeDefined();
|
||||||
expect(betaComment.community_local).toBe(true);
|
expect(betaComment.community.local).toBe(true);
|
||||||
expect(betaComment.creator_local).toBe(false);
|
expect(betaComment.creator.local).toBe(false);
|
||||||
expect(betaComment.score).toBe(1);
|
expect(betaComment.counts.score).toBe(1);
|
||||||
assertCommentFederation(betaComment, commentRes.comment);
|
assertCommentFederation(betaComment, commentRes.comment_view);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Create a comment in a non-existent post', async () => {
|
test('Create a comment in a non-existent post', async () => {
|
||||||
|
@ -85,39 +84,48 @@ test('Create a comment in a non-existent post', async () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Update a comment', async () => {
|
test('Update a comment', async () => {
|
||||||
let commentRes = await createComment(alpha, postRes.post.id);
|
let commentRes = await createComment(alpha, postRes.post_view.post.id);
|
||||||
// Federate the comment first
|
// Federate the comment first
|
||||||
let searchBeta = await searchComment(beta, commentRes.comment);
|
let searchBeta = await searchComment(beta, commentRes.comment_view.comment);
|
||||||
assertCommentFederation(searchBeta.comments[0], commentRes.comment);
|
assertCommentFederation(searchBeta.comments[0], commentRes.comment_view);
|
||||||
|
|
||||||
await delay();
|
await delay();
|
||||||
let updateCommentRes = await updateComment(alpha, commentRes.comment.id);
|
let updateCommentRes = await editComment(
|
||||||
expect(updateCommentRes.comment.content).toBe(
|
alpha,
|
||||||
|
commentRes.comment_view.comment.id
|
||||||
|
);
|
||||||
|
expect(updateCommentRes.comment_view.comment.content).toBe(
|
||||||
'A jest test federated comment update'
|
'A jest test federated comment update'
|
||||||
);
|
);
|
||||||
expect(updateCommentRes.comment.community_local).toBe(false);
|
expect(updateCommentRes.comment_view.community.local).toBe(false);
|
||||||
expect(updateCommentRes.comment.creator_local).toBe(true);
|
expect(updateCommentRes.comment_view.creator.local).toBe(true);
|
||||||
await delay();
|
await delay();
|
||||||
|
|
||||||
// Make sure that post is updated on beta
|
// Make sure that post is updated on beta
|
||||||
let searchBetaUpdated = await searchComment(beta, commentRes.comment);
|
let searchBetaUpdated = await searchComment(
|
||||||
assertCommentFederation(searchBetaUpdated.comments[0], updateCommentRes.comment);
|
beta,
|
||||||
|
commentRes.comment_view.comment
|
||||||
|
);
|
||||||
|
assertCommentFederation(
|
||||||
|
searchBetaUpdated.comments[0],
|
||||||
|
updateCommentRes.comment_view
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Delete a comment', async () => {
|
test('Delete a comment', async () => {
|
||||||
let commentRes = await createComment(alpha, postRes.post.id);
|
let commentRes = await createComment(alpha, postRes.post_view.post.id);
|
||||||
await delay();
|
await delay();
|
||||||
|
|
||||||
let deleteCommentRes = await deleteComment(
|
let deleteCommentRes = await deleteComment(
|
||||||
alpha,
|
alpha,
|
||||||
true,
|
true,
|
||||||
commentRes.comment.id
|
commentRes.comment_view.comment.id
|
||||||
);
|
);
|
||||||
expect(deleteCommentRes.comment.deleted).toBe(true);
|
expect(deleteCommentRes.comment_view.comment.deleted).toBe(true);
|
||||||
await delay();
|
await delay();
|
||||||
|
|
||||||
// Make sure that comment is undefined on beta
|
// Make sure that comment is undefined on beta
|
||||||
let searchBeta = await searchComment(beta, commentRes.comment);
|
let searchBeta = await searchComment(beta, commentRes.comment_view.comment);
|
||||||
let betaComment = searchBeta.comments[0];
|
let betaComment = searchBeta.comments[0];
|
||||||
expect(betaComment).toBeUndefined();
|
expect(betaComment).toBeUndefined();
|
||||||
await delay();
|
await delay();
|
||||||
|
@ -125,43 +133,50 @@ test('Delete a comment', async () => {
|
||||||
let undeleteCommentRes = await deleteComment(
|
let undeleteCommentRes = await deleteComment(
|
||||||
alpha,
|
alpha,
|
||||||
false,
|
false,
|
||||||
commentRes.comment.id
|
commentRes.comment_view.comment.id
|
||||||
);
|
);
|
||||||
expect(undeleteCommentRes.comment.deleted).toBe(false);
|
expect(undeleteCommentRes.comment_view.comment.deleted).toBe(false);
|
||||||
await delay();
|
await delay();
|
||||||
|
|
||||||
// Make sure that comment is undeleted on beta
|
// Make sure that comment is undeleted on beta
|
||||||
let searchBeta2 = await searchComment(beta, commentRes.comment);
|
let searchBeta2 = await searchComment(beta, commentRes.comment_view.comment);
|
||||||
let betaComment2 = searchBeta2.comments[0];
|
let betaComment2 = searchBeta2.comments[0];
|
||||||
expect(betaComment2.deleted).toBe(false);
|
expect(betaComment2.comment.deleted).toBe(false);
|
||||||
assertCommentFederation(searchBeta2.comments[0], undeleteCommentRes.comment);
|
assertCommentFederation(
|
||||||
|
searchBeta2.comments[0],
|
||||||
|
undeleteCommentRes.comment_view
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Remove a comment from admin and community on the same instance', async () => {
|
test('Remove a comment from admin and community on the same instance', async () => {
|
||||||
let commentRes = await createComment(alpha, postRes.post.id);
|
let commentRes = await createComment(alpha, postRes.post_view.post.id);
|
||||||
await delay();
|
await delay();
|
||||||
|
|
||||||
// Get the id for beta
|
// Get the id for beta
|
||||||
let betaCommentId = (await searchComment(beta, commentRes.comment))
|
let betaCommentId = (
|
||||||
.comments[0].id;
|
await searchComment(beta, commentRes.comment_view.comment)
|
||||||
|
).comments[0].comment.id;
|
||||||
|
|
||||||
// The beta admin removes it (the community lives on beta)
|
// The beta admin removes it (the community lives on beta)
|
||||||
let removeCommentRes = await removeComment(beta, true, betaCommentId);
|
let removeCommentRes = await removeComment(beta, true, betaCommentId);
|
||||||
expect(removeCommentRes.comment.removed).toBe(true);
|
expect(removeCommentRes.comment_view.comment.removed).toBe(true);
|
||||||
await longDelay();
|
await longDelay();
|
||||||
|
|
||||||
// Make sure that comment is removed on alpha (it gets pushed since an admin from beta removed it)
|
// Make sure that comment is removed on alpha (it gets pushed since an admin from beta removed it)
|
||||||
let refetchedPost = await getPost(alpha, postRes.post.id);
|
let refetchedPost = await getPost(alpha, postRes.post_view.post.id);
|
||||||
expect(refetchedPost.comments[0].removed).toBe(true);
|
expect(refetchedPost.comments[0].comment.removed).toBe(true);
|
||||||
|
|
||||||
let unremoveCommentRes = await removeComment(beta, false, betaCommentId);
|
let unremoveCommentRes = await removeComment(beta, false, betaCommentId);
|
||||||
expect(unremoveCommentRes.comment.removed).toBe(false);
|
expect(unremoveCommentRes.comment_view.comment.removed).toBe(false);
|
||||||
await longDelay();
|
await longDelay();
|
||||||
|
|
||||||
// Make sure that comment is unremoved on beta
|
// Make sure that comment is unremoved on beta
|
||||||
let refetchedPost2 = await getPost(alpha, postRes.post.id);
|
let refetchedPost2 = await getPost(alpha, postRes.post_view.post.id);
|
||||||
expect(refetchedPost2.comments[0].removed).toBe(false);
|
expect(refetchedPost2.comments[0].comment.removed).toBe(false);
|
||||||
assertCommentFederation(refetchedPost2.comments[0], unremoveCommentRes.comment);
|
assertCommentFederation(
|
||||||
|
refetchedPost2.comments[0],
|
||||||
|
unremoveCommentRes.comment_view
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Remove a comment from admin and community on different instance', async () => {
|
test('Remove a comment from admin and community on different instance', async () => {
|
||||||
|
@ -174,159 +189,170 @@ test('Remove a comment from admin and community on different instance', async ()
|
||||||
// New alpha user creates a community, post, and comment.
|
// New alpha user creates a community, post, and comment.
|
||||||
let newCommunity = await createCommunity(newAlphaApi);
|
let newCommunity = await createCommunity(newAlphaApi);
|
||||||
await delay();
|
await delay();
|
||||||
let newPost = await createPost(newAlphaApi, newCommunity.community.id);
|
let newPost = await createPost(
|
||||||
|
newAlphaApi,
|
||||||
|
newCommunity.community_view.community.id
|
||||||
|
);
|
||||||
await delay();
|
await delay();
|
||||||
let commentRes = await createComment(newAlphaApi, newPost.post.id);
|
let commentRes = await createComment(newAlphaApi, newPost.post_view.post.id);
|
||||||
expect(commentRes.comment.content).toBeDefined();
|
expect(commentRes.comment_view.comment.content).toBeDefined();
|
||||||
await delay();
|
await delay();
|
||||||
|
|
||||||
// Beta searches that to cache it, then removes it
|
// Beta searches that to cache it, then removes it
|
||||||
let searchBeta = await searchComment(beta, commentRes.comment);
|
let searchBeta = await searchComment(beta, commentRes.comment_view.comment);
|
||||||
let betaComment = searchBeta.comments[0];
|
let betaComment = searchBeta.comments[0];
|
||||||
let removeCommentRes = await removeComment(beta, true, betaComment.id);
|
let removeCommentRes = await removeComment(
|
||||||
expect(removeCommentRes.comment.removed).toBe(true);
|
beta,
|
||||||
|
true,
|
||||||
|
betaComment.comment.id
|
||||||
|
);
|
||||||
|
expect(removeCommentRes.comment_view.comment.removed).toBe(true);
|
||||||
await delay();
|
await delay();
|
||||||
|
|
||||||
// Make sure its not removed on alpha
|
// Make sure its not removed on alpha
|
||||||
let refetchedPost = await getPost(newAlphaApi, newPost.post.id);
|
let refetchedPost = await getPost(newAlphaApi, newPost.post_view.post.id);
|
||||||
expect(refetchedPost.comments[0].removed).toBe(false);
|
expect(refetchedPost.comments[0].comment.removed).toBe(false);
|
||||||
assertCommentFederation(refetchedPost.comments[0], commentRes.comment);
|
assertCommentFederation(refetchedPost.comments[0], commentRes.comment_view);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Unlike a comment', async () => {
|
test('Unlike a comment', async () => {
|
||||||
let commentRes = await createComment(alpha, postRes.post.id);
|
let commentRes = await createComment(alpha, postRes.post_view.post.id);
|
||||||
await delay();
|
await delay();
|
||||||
let unlike = await likeComment(alpha, 0, commentRes.comment);
|
let unlike = await likeComment(alpha, 0, commentRes.comment_view.comment);
|
||||||
expect(unlike.comment.score).toBe(0);
|
expect(unlike.comment_view.counts.score).toBe(0);
|
||||||
await delay();
|
await delay();
|
||||||
|
|
||||||
// Make sure that post is unliked on beta
|
// Make sure that post is unliked on beta
|
||||||
let searchBeta = await searchComment(beta, commentRes.comment);
|
let searchBeta = await searchComment(beta, commentRes.comment_view.comment);
|
||||||
let betaComment = searchBeta.comments[0];
|
let betaComment = searchBeta.comments[0];
|
||||||
expect(betaComment).toBeDefined();
|
expect(betaComment).toBeDefined();
|
||||||
expect(betaComment.community_local).toBe(true);
|
expect(betaComment.community.local).toBe(true);
|
||||||
expect(betaComment.creator_local).toBe(false);
|
expect(betaComment.creator.local).toBe(false);
|
||||||
expect(betaComment.score).toBe(0);
|
expect(betaComment.counts.score).toBe(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Federated comment like', async () => {
|
test('Federated comment like', async () => {
|
||||||
let commentRes = await createComment(alpha, postRes.post.id);
|
let commentRes = await createComment(alpha, postRes.post_view.post.id);
|
||||||
await longDelay();
|
await longDelay();
|
||||||
|
|
||||||
// Find the comment on beta
|
// Find the comment on beta
|
||||||
let searchBeta = await searchComment(beta, commentRes.comment);
|
let searchBeta = await searchComment(beta, commentRes.comment_view.comment);
|
||||||
let betaComment = searchBeta.comments[0];
|
let betaComment = searchBeta.comments[0];
|
||||||
|
|
||||||
let like = await likeComment(beta, 1, betaComment);
|
let like = await likeComment(beta, 1, betaComment.comment);
|
||||||
expect(like.comment.score).toBe(2);
|
expect(like.comment_view.counts.score).toBe(2);
|
||||||
await longDelay();
|
await longDelay();
|
||||||
|
|
||||||
// Get the post from alpha, check the likes
|
// Get the post from alpha, check the likes
|
||||||
let post = await getPost(alpha, postRes.post.id);
|
let post = await getPost(alpha, postRes.post_view.post.id);
|
||||||
expect(post.comments[0].score).toBe(2);
|
expect(post.comments[0].counts.score).toBe(2);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Reply to a comment', async () => {
|
test('Reply to a comment', async () => {
|
||||||
// Create a comment on alpha, find it on beta
|
// Create a comment on alpha, find it on beta
|
||||||
let commentRes = await createComment(alpha, postRes.post.id);
|
let commentRes = await createComment(alpha, postRes.post_view.post.id);
|
||||||
await delay();
|
await delay();
|
||||||
let searchBeta = await searchComment(beta, commentRes.comment);
|
let searchBeta = await searchComment(beta, commentRes.comment_view.comment);
|
||||||
let betaComment = searchBeta.comments[0];
|
let betaComment = searchBeta.comments[0];
|
||||||
|
|
||||||
// find that comment id on beta
|
// find that comment id on beta
|
||||||
|
|
||||||
// Reply from beta
|
// Reply from beta
|
||||||
let replyRes = await createComment(beta, betaComment.post_id, betaComment.id);
|
let replyRes = await createComment(
|
||||||
expect(replyRes.comment.content).toBeDefined();
|
beta,
|
||||||
expect(replyRes.comment.community_local).toBe(true);
|
betaComment.post.id,
|
||||||
expect(replyRes.comment.creator_local).toBe(true);
|
betaComment.comment.id
|
||||||
expect(replyRes.comment.parent_id).toBe(betaComment.id);
|
);
|
||||||
expect(replyRes.comment.score).toBe(1);
|
expect(replyRes.comment_view.comment.content).toBeDefined();
|
||||||
|
expect(replyRes.comment_view.community.local).toBe(true);
|
||||||
|
expect(replyRes.comment_view.creator.local).toBe(true);
|
||||||
|
expect(replyRes.comment_view.comment.parent_id).toBe(betaComment.comment.id);
|
||||||
|
expect(replyRes.comment_view.counts.score).toBe(1);
|
||||||
await longDelay();
|
await longDelay();
|
||||||
|
|
||||||
// Make sure that comment is seen on alpha
|
// Make sure that comment is seen on alpha
|
||||||
// TODO not sure why, but a searchComment back to alpha, for the ap_id of betas
|
// TODO not sure why, but a searchComment back to alpha, for the ap_id of betas
|
||||||
// comment, isn't working.
|
// comment, isn't working.
|
||||||
// let searchAlpha = await searchComment(alpha, replyRes.comment);
|
// let searchAlpha = await searchComment(alpha, replyRes.comment);
|
||||||
let post = await getPost(alpha, postRes.post.id);
|
let post = await getPost(alpha, postRes.post_view.post.id);
|
||||||
let alphaComment = post.comments[0];
|
let alphaComment = post.comments[0];
|
||||||
expect(alphaComment.content).toBeDefined();
|
expect(alphaComment.comment.content).toBeDefined();
|
||||||
expect(alphaComment.parent_id).toBe(post.comments[1].id);
|
expect(alphaComment.comment.parent_id).toBe(post.comments[1].comment.id);
|
||||||
expect(alphaComment.community_local).toBe(false);
|
expect(alphaComment.community.local).toBe(false);
|
||||||
expect(alphaComment.creator_local).toBe(false);
|
expect(alphaComment.creator.local).toBe(false);
|
||||||
expect(alphaComment.score).toBe(1);
|
expect(alphaComment.counts.score).toBe(1);
|
||||||
assertCommentFederation(alphaComment, replyRes.comment);
|
assertCommentFederation(alphaComment, replyRes.comment_view);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Mention beta', async () => {
|
test('Mention beta', async () => {
|
||||||
// Create a mention on alpha
|
// Create a mention on alpha
|
||||||
let mentionContent = 'A test mention of @lemmy_beta@lemmy-beta:8551';
|
let mentionContent = 'A test mention of @lemmy_beta@lemmy-beta:8551';
|
||||||
let commentRes = await createComment(alpha, postRes.post.id);
|
let commentRes = await createComment(alpha, postRes.post_view.post.id);
|
||||||
await delay();
|
await delay();
|
||||||
let mentionRes = await createComment(
|
let mentionRes = await createComment(
|
||||||
alpha,
|
alpha,
|
||||||
postRes.post.id,
|
postRes.post_view.post.id,
|
||||||
commentRes.comment.id,
|
commentRes.comment_view.comment.id,
|
||||||
mentionContent
|
mentionContent
|
||||||
);
|
);
|
||||||
expect(mentionRes.comment.content).toBeDefined();
|
expect(mentionRes.comment_view.comment.content).toBeDefined();
|
||||||
expect(mentionRes.comment.community_local).toBe(false);
|
expect(mentionRes.comment_view.community.local).toBe(false);
|
||||||
expect(mentionRes.comment.creator_local).toBe(true);
|
expect(mentionRes.comment_view.creator.local).toBe(true);
|
||||||
expect(mentionRes.comment.score).toBe(1);
|
expect(mentionRes.comment_view.counts.score).toBe(1);
|
||||||
await delay();
|
await delay();
|
||||||
|
|
||||||
let mentionsRes = await getMentions(beta);
|
let mentionsRes = await getMentions(beta);
|
||||||
expect(mentionsRes.mentions[0].content).toBeDefined();
|
expect(mentionsRes.mentions[0].comment.content).toBeDefined();
|
||||||
expect(mentionsRes.mentions[0].community_local).toBe(true);
|
expect(mentionsRes.mentions[0].community.local).toBe(true);
|
||||||
expect(mentionsRes.mentions[0].creator_local).toBe(false);
|
expect(mentionsRes.mentions[0].creator.local).toBe(false);
|
||||||
expect(mentionsRes.mentions[0].score).toBe(1);
|
expect(mentionsRes.mentions[0].counts.score).toBe(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Comment Search', async () => {
|
test('Comment Search', async () => {
|
||||||
let commentRes = await createComment(alpha, postRes.post.id);
|
let commentRes = await createComment(alpha, postRes.post_view.post.id);
|
||||||
await delay();
|
await delay();
|
||||||
let searchBeta = await searchComment(beta, commentRes.comment);
|
let searchBeta = await searchComment(beta, commentRes.comment_view.comment);
|
||||||
assertCommentFederation(searchBeta.comments[0], commentRes.comment);
|
assertCommentFederation(searchBeta.comments[0], commentRes.comment_view);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('A and G subscribe to B (center) A posts, G mentions B, it gets announced to A', async () => {
|
test('A and G subscribe to B (center) A posts, G mentions B, it gets announced to A', async () => {
|
||||||
// Create a local post
|
// Create a local post
|
||||||
let alphaPost = await createPost(alpha, 2);
|
let alphaPost = await createPost(alpha, 2);
|
||||||
expect(alphaPost.post.community_local).toBe(true);
|
expect(alphaPost.post_view.community.local).toBe(true);
|
||||||
await delay();
|
await delay();
|
||||||
|
|
||||||
// Make sure gamma sees it
|
// Make sure gamma sees it
|
||||||
let search = await searchPost(gamma, alphaPost.post);
|
let search = await searchPost(gamma, alphaPost.post_view.post);
|
||||||
let gammaPost = search.posts[0];
|
let gammaPost = search.posts[0];
|
||||||
|
|
||||||
let commentContent =
|
let commentContent =
|
||||||
'A jest test federated comment announce, lets mention @lemmy_beta@lemmy-beta:8551';
|
'A jest test federated comment announce, lets mention @lemmy_beta@lemmy-beta:8551';
|
||||||
let commentRes = await createComment(
|
let commentRes = await createComment(
|
||||||
gamma,
|
gamma,
|
||||||
gammaPost.id,
|
gammaPost.post.id,
|
||||||
undefined,
|
undefined,
|
||||||
commentContent
|
commentContent
|
||||||
);
|
);
|
||||||
expect(commentRes.comment.content).toBe(commentContent);
|
expect(commentRes.comment_view.comment.content).toBe(commentContent);
|
||||||
expect(commentRes.comment.community_local).toBe(false);
|
expect(commentRes.comment_view.community.local).toBe(false);
|
||||||
expect(commentRes.comment.creator_local).toBe(true);
|
expect(commentRes.comment_view.creator.local).toBe(true);
|
||||||
expect(commentRes.comment.score).toBe(1);
|
expect(commentRes.comment_view.counts.score).toBe(1);
|
||||||
await longDelay();
|
await longDelay();
|
||||||
|
|
||||||
// Make sure alpha sees it
|
// Make sure alpha sees it
|
||||||
let alphaPost2 = await getPost(alpha, alphaPost.post.id);
|
let alphaPost2 = await getPost(alpha, alphaPost.post_view.post.id);
|
||||||
expect(alphaPost2.comments[0].content).toBe(commentContent);
|
expect(alphaPost2.comments[0].comment.content).toBe(commentContent);
|
||||||
expect(alphaPost2.comments[0].community_local).toBe(true);
|
expect(alphaPost2.comments[0].community.local).toBe(true);
|
||||||
expect(alphaPost2.comments[0].creator_local).toBe(false);
|
expect(alphaPost2.comments[0].creator.local).toBe(false);
|
||||||
expect(alphaPost2.comments[0].score).toBe(1);
|
expect(alphaPost2.comments[0].counts.score).toBe(1);
|
||||||
assertCommentFederation(alphaPost2.comments[0], commentRes.comment);
|
assertCommentFederation(alphaPost2.comments[0], commentRes.comment_view);
|
||||||
await delay();
|
await delay();
|
||||||
|
|
||||||
// Make sure beta has mentions
|
// Make sure beta has mentions
|
||||||
let mentionsRes = await getMentions(beta);
|
let mentionsRes = await getMentions(beta);
|
||||||
expect(mentionsRes.mentions[0].content).toBe(commentContent);
|
expect(mentionsRes.mentions[0].comment.content).toBe(commentContent);
|
||||||
expect(mentionsRes.mentions[0].community_local).toBe(false);
|
expect(mentionsRes.mentions[0].community.local).toBe(false);
|
||||||
expect(mentionsRes.mentions[0].creator_local).toBe(false);
|
expect(mentionsRes.mentions[0].creator.local).toBe(false);
|
||||||
// TODO this is failing because fetchInReplyTos aren't getting score
|
// TODO this is failing because fetchInReplyTos aren't getting score
|
||||||
// expect(mentionsRes.mentions[0].score).toBe(1);
|
// expect(mentionsRes.mentions[0].score).toBe(1);
|
||||||
});
|
});
|
||||||
|
@ -335,60 +361,64 @@ test('Fetch in_reply_tos: A is unsubbed from B, B makes a post, and some embedde
|
||||||
// Unfollow all remote communities
|
// Unfollow all remote communities
|
||||||
let followed = await unfollowRemotes(alpha);
|
let followed = await unfollowRemotes(alpha);
|
||||||
expect(
|
expect(
|
||||||
followed.communities.filter(c => c.community_local == false).length
|
followed.communities.filter(c => c.community.local == false).length
|
||||||
).toBe(0);
|
).toBe(0);
|
||||||
|
|
||||||
// B creates a post, and two comments, should be invisible to A
|
// B creates a post, and two comments, should be invisible to A
|
||||||
let postRes = await createPost(beta, 2);
|
let postRes = await createPost(beta, 2);
|
||||||
expect(postRes.post.name).toBeDefined();
|
expect(postRes.post_view.post.name).toBeDefined();
|
||||||
await delay();
|
await delay();
|
||||||
|
|
||||||
let parentCommentContent = 'An invisible top level comment from beta';
|
let parentCommentContent = 'An invisible top level comment from beta';
|
||||||
let parentCommentRes = await createComment(
|
let parentCommentRes = await createComment(
|
||||||
beta,
|
beta,
|
||||||
postRes.post.id,
|
postRes.post_view.post.id,
|
||||||
undefined,
|
undefined,
|
||||||
parentCommentContent
|
parentCommentContent
|
||||||
);
|
);
|
||||||
expect(parentCommentRes.comment.content).toBe(parentCommentContent);
|
expect(parentCommentRes.comment_view.comment.content).toBe(
|
||||||
|
parentCommentContent
|
||||||
|
);
|
||||||
await delay();
|
await delay();
|
||||||
|
|
||||||
// B creates a comment, then a child one of that.
|
// B creates a comment, then a child one of that.
|
||||||
let childCommentContent = 'An invisible child comment from beta';
|
let childCommentContent = 'An invisible child comment from beta';
|
||||||
let childCommentRes = await createComment(
|
let childCommentRes = await createComment(
|
||||||
beta,
|
beta,
|
||||||
postRes.post.id,
|
postRes.post_view.post.id,
|
||||||
parentCommentRes.comment.id,
|
parentCommentRes.comment_view.comment.id,
|
||||||
|
childCommentContent
|
||||||
|
);
|
||||||
|
expect(childCommentRes.comment_view.comment.content).toBe(
|
||||||
childCommentContent
|
childCommentContent
|
||||||
);
|
);
|
||||||
expect(childCommentRes.comment.content).toBe(childCommentContent);
|
|
||||||
await delay();
|
await delay();
|
||||||
|
|
||||||
// Follow beta again
|
// Follow beta again
|
||||||
let follow = await followBeta(alpha);
|
let follow = await followBeta(alpha);
|
||||||
expect(follow.community.local).toBe(false);
|
expect(follow.community_view.community.local).toBe(false);
|
||||||
expect(follow.community.name).toBe('main');
|
expect(follow.community_view.community.name).toBe('main');
|
||||||
await delay();
|
await delay();
|
||||||
|
|
||||||
// An update to the child comment on beta, should push the post, parent, and child to alpha now
|
// An update to the child comment on beta, should push the post, parent, and child to alpha now
|
||||||
let updatedCommentContent = 'An update child comment from beta';
|
let updatedCommentContent = 'An update child comment from beta';
|
||||||
let updateRes = await updateComment(
|
let updateRes = await editComment(
|
||||||
beta,
|
beta,
|
||||||
childCommentRes.comment.id,
|
childCommentRes.comment_view.comment.id,
|
||||||
updatedCommentContent
|
updatedCommentContent
|
||||||
);
|
);
|
||||||
expect(updateRes.comment.content).toBe(updatedCommentContent);
|
expect(updateRes.comment_view.comment.content).toBe(updatedCommentContent);
|
||||||
await delay();
|
await delay();
|
||||||
|
|
||||||
// Get the post from alpha
|
// Get the post from alpha
|
||||||
let search = await searchPost(alpha, postRes.post);
|
let search = await searchPost(alpha, postRes.post_view.post);
|
||||||
let alphaPostB = search.posts[0];
|
let alphaPostB = search.posts[0];
|
||||||
await longDelay();
|
await longDelay();
|
||||||
|
|
||||||
let alphaPost = await getPost(alpha, alphaPostB.id);
|
let alphaPost = await getPost(alpha, alphaPostB.post.id);
|
||||||
expect(alphaPost.post.name).toBeDefined();
|
expect(alphaPost.post_view.post.name).toBeDefined();
|
||||||
assertCommentFederation(alphaPost.comments[1], parentCommentRes.comment);
|
assertCommentFederation(alphaPost.comments[1], parentCommentRes.comment_view);
|
||||||
assertCommentFederation(alphaPost.comments[0], updateRes.comment);
|
assertCommentFederation(alphaPost.comments[0], updateRes.comment_view);
|
||||||
expect(alphaPost.post.community_local).toBe(false);
|
expect(alphaPost.post_view.community.local).toBe(false);
|
||||||
expect(alphaPost.post.creator_local).toBe(false);
|
expect(alphaPost.post_view.creator.local).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
|
@ -3,7 +3,6 @@ import {
|
||||||
alpha,
|
alpha,
|
||||||
beta,
|
beta,
|
||||||
setupLogins,
|
setupLogins,
|
||||||
searchForBetaCommunity,
|
|
||||||
searchForCommunity,
|
searchForCommunity,
|
||||||
createCommunity,
|
createCommunity,
|
||||||
deleteCommunity,
|
deleteCommunity,
|
||||||
|
@ -11,40 +10,44 @@ import {
|
||||||
getCommunity,
|
getCommunity,
|
||||||
followCommunity,
|
followCommunity,
|
||||||
delay,
|
delay,
|
||||||
longDelay,
|
|
||||||
} from './shared';
|
} from './shared';
|
||||||
import {
|
import { CommunityView } from 'lemmy-js-client';
|
||||||
Community,
|
|
||||||
} from 'lemmy-js-client';
|
|
||||||
|
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
await setupLogins();
|
await setupLogins();
|
||||||
});
|
});
|
||||||
|
|
||||||
function assertCommunityFederation(
|
function assertCommunityFederation(
|
||||||
communityOne: Community,
|
communityOne: CommunityView,
|
||||||
communityTwo: Community) {
|
communityTwo: CommunityView
|
||||||
expect(communityOne.actor_id).toBe(communityTwo.actor_id);
|
) {
|
||||||
expect(communityOne.name).toBe(communityTwo.name);
|
expect(communityOne.community.actor_id).toBe(communityTwo.community.actor_id);
|
||||||
expect(communityOne.title).toBe(communityTwo.title);
|
expect(communityOne.community.name).toBe(communityTwo.community.name);
|
||||||
expect(communityOne.description).toBe(communityTwo.description);
|
expect(communityOne.community.title).toBe(communityTwo.community.title);
|
||||||
expect(communityOne.icon).toBe(communityTwo.icon);
|
expect(communityOne.community.description).toBe(
|
||||||
expect(communityOne.banner).toBe(communityTwo.banner);
|
communityTwo.community.description
|
||||||
expect(communityOne.published).toBe(communityTwo.published);
|
);
|
||||||
expect(communityOne.creator_actor_id).toBe(communityTwo.creator_actor_id);
|
expect(communityOne.community.icon).toBe(communityTwo.community.icon);
|
||||||
expect(communityOne.nsfw).toBe(communityTwo.nsfw);
|
expect(communityOne.community.banner).toBe(communityTwo.community.banner);
|
||||||
expect(communityOne.category_id).toBe(communityTwo.category_id);
|
expect(communityOne.community.published).toBe(
|
||||||
expect(communityOne.removed).toBe(communityTwo.removed);
|
communityTwo.community.published
|
||||||
expect(communityOne.deleted).toBe(communityTwo.deleted);
|
);
|
||||||
|
expect(communityOne.creator.actor_id).toBe(communityTwo.creator.actor_id);
|
||||||
|
expect(communityOne.community.nsfw).toBe(communityTwo.community.nsfw);
|
||||||
|
expect(communityOne.community.category_id).toBe(
|
||||||
|
communityTwo.community.category_id
|
||||||
|
);
|
||||||
|
expect(communityOne.community.removed).toBe(communityTwo.community.removed);
|
||||||
|
expect(communityOne.community.deleted).toBe(communityTwo.community.deleted);
|
||||||
}
|
}
|
||||||
|
|
||||||
test('Create community', async () => {
|
test('Create community', async () => {
|
||||||
let communityRes = await createCommunity(alpha);
|
let communityRes = await createCommunity(alpha);
|
||||||
expect(communityRes.community.name).toBeDefined();
|
expect(communityRes.community_view.community.name).toBeDefined();
|
||||||
|
|
||||||
// A dupe check
|
// A dupe check
|
||||||
let prevName = communityRes.community.name;
|
let prevName = communityRes.community_view.community.name;
|
||||||
let communityRes2 = await createCommunity(alpha, prevName);
|
let communityRes2: any = await createCommunity(alpha, prevName);
|
||||||
expect(communityRes2['error']).toBe('community_already_exists');
|
expect(communityRes2['error']).toBe('community_already_exists');
|
||||||
await delay();
|
await delay();
|
||||||
|
|
||||||
|
@ -52,7 +55,7 @@ test('Create community', async () => {
|
||||||
let searchShort = `!${prevName}@lemmy-alpha:8541`;
|
let searchShort = `!${prevName}@lemmy-alpha:8541`;
|
||||||
let search = await searchForCommunity(beta, searchShort);
|
let search = await searchForCommunity(beta, searchShort);
|
||||||
let communityOnBeta = search.communities[0];
|
let communityOnBeta = search.communities[0];
|
||||||
assertCommunityFederation(communityOnBeta, communityRes.community);
|
assertCommunityFederation(communityOnBeta, communityRes.community_view);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Delete community', async () => {
|
test('Delete community', async () => {
|
||||||
|
@ -60,44 +63,56 @@ test('Delete community', async () => {
|
||||||
await delay();
|
await delay();
|
||||||
|
|
||||||
// Cache the community on Alpha
|
// Cache the community on Alpha
|
||||||
let searchShort = `!${communityRes.community.name}@lemmy-beta:8551`;
|
let searchShort = `!${communityRes.community_view.community.name}@lemmy-beta:8551`;
|
||||||
let search = await searchForCommunity(alpha, searchShort);
|
let search = await searchForCommunity(alpha, searchShort);
|
||||||
let communityOnAlpha = search.communities[0];
|
let communityOnAlpha = search.communities[0];
|
||||||
assertCommunityFederation(communityOnAlpha, communityRes.community);
|
assertCommunityFederation(communityOnAlpha, communityRes.community_view);
|
||||||
await delay();
|
await delay();
|
||||||
|
|
||||||
// Follow the community from alpha
|
// Follow the community from alpha
|
||||||
let follow = await followCommunity(alpha, true, communityOnAlpha.id);
|
let follow = await followCommunity(
|
||||||
|
alpha,
|
||||||
|
true,
|
||||||
|
communityOnAlpha.community.id
|
||||||
|
);
|
||||||
|
|
||||||
// Make sure the follow response went through
|
// Make sure the follow response went through
|
||||||
expect(follow.community.local).toBe(false);
|
expect(follow.community_view.community.local).toBe(false);
|
||||||
await delay();
|
await delay();
|
||||||
|
|
||||||
let deleteCommunityRes = await deleteCommunity(
|
let deleteCommunityRes = await deleteCommunity(
|
||||||
beta,
|
beta,
|
||||||
true,
|
true,
|
||||||
communityRes.community.id
|
communityRes.community_view.community.id
|
||||||
);
|
);
|
||||||
expect(deleteCommunityRes.community.deleted).toBe(true);
|
expect(deleteCommunityRes.community_view.community.deleted).toBe(true);
|
||||||
await delay();
|
await delay();
|
||||||
|
|
||||||
// Make sure it got deleted on A
|
// Make sure it got deleted on A
|
||||||
let communityOnAlphaDeleted = await getCommunity(alpha, communityOnAlpha.id);
|
let communityOnAlphaDeleted = await getCommunity(
|
||||||
expect(communityOnAlphaDeleted.community.deleted).toBe(true);
|
alpha,
|
||||||
|
communityOnAlpha.community.id
|
||||||
|
);
|
||||||
|
expect(communityOnAlphaDeleted.community_view.community.deleted).toBe(true);
|
||||||
await delay();
|
await delay();
|
||||||
|
|
||||||
// Undelete
|
// Undelete
|
||||||
let undeleteCommunityRes = await deleteCommunity(
|
let undeleteCommunityRes = await deleteCommunity(
|
||||||
beta,
|
beta,
|
||||||
false,
|
false,
|
||||||
communityRes.community.id
|
communityRes.community_view.community.id
|
||||||
);
|
);
|
||||||
expect(undeleteCommunityRes.community.deleted).toBe(false);
|
expect(undeleteCommunityRes.community_view.community.deleted).toBe(false);
|
||||||
await delay();
|
await delay();
|
||||||
|
|
||||||
// Make sure it got undeleted on A
|
// Make sure it got undeleted on A
|
||||||
let communityOnAlphaUnDeleted = await getCommunity(alpha, communityOnAlpha.id);
|
let communityOnAlphaUnDeleted = await getCommunity(
|
||||||
expect(communityOnAlphaUnDeleted.community.deleted).toBe(false);
|
alpha,
|
||||||
|
communityOnAlpha.community.id
|
||||||
|
);
|
||||||
|
expect(communityOnAlphaUnDeleted.community_view.community.deleted).toBe(
|
||||||
|
false
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Remove community', async () => {
|
test('Remove community', async () => {
|
||||||
|
@ -105,53 +120,65 @@ test('Remove community', async () => {
|
||||||
await delay();
|
await delay();
|
||||||
|
|
||||||
// Cache the community on Alpha
|
// Cache the community on Alpha
|
||||||
let searchShort = `!${communityRes.community.name}@lemmy-beta:8551`;
|
let searchShort = `!${communityRes.community_view.community.name}@lemmy-beta:8551`;
|
||||||
let search = await searchForCommunity(alpha, searchShort);
|
let search = await searchForCommunity(alpha, searchShort);
|
||||||
let communityOnAlpha = search.communities[0];
|
let communityOnAlpha = search.communities[0];
|
||||||
assertCommunityFederation(communityOnAlpha, communityRes.community);
|
assertCommunityFederation(communityOnAlpha, communityRes.community_view);
|
||||||
await delay();
|
await delay();
|
||||||
|
|
||||||
// Follow the community from alpha
|
// Follow the community from alpha
|
||||||
let follow = await followCommunity(alpha, true, communityOnAlpha.id);
|
let follow = await followCommunity(
|
||||||
|
alpha,
|
||||||
|
true,
|
||||||
|
communityOnAlpha.community.id
|
||||||
|
);
|
||||||
|
|
||||||
// Make sure the follow response went through
|
// Make sure the follow response went through
|
||||||
expect(follow.community.local).toBe(false);
|
expect(follow.community_view.community.local).toBe(false);
|
||||||
await delay();
|
await delay();
|
||||||
|
|
||||||
let removeCommunityRes = await removeCommunity(
|
let removeCommunityRes = await removeCommunity(
|
||||||
beta,
|
beta,
|
||||||
true,
|
true,
|
||||||
communityRes.community.id
|
communityRes.community_view.community.id
|
||||||
);
|
);
|
||||||
expect(removeCommunityRes.community.removed).toBe(true);
|
expect(removeCommunityRes.community_view.community.removed).toBe(true);
|
||||||
await delay();
|
await delay();
|
||||||
|
|
||||||
// Make sure it got Removed on A
|
// Make sure it got Removed on A
|
||||||
let communityOnAlphaRemoved = await getCommunity(alpha, communityOnAlpha.id);
|
let communityOnAlphaRemoved = await getCommunity(
|
||||||
expect(communityOnAlphaRemoved.community.removed).toBe(true);
|
alpha,
|
||||||
|
communityOnAlpha.community.id
|
||||||
|
);
|
||||||
|
expect(communityOnAlphaRemoved.community_view.community.removed).toBe(true);
|
||||||
await delay();
|
await delay();
|
||||||
|
|
||||||
// unremove
|
// unremove
|
||||||
let unremoveCommunityRes = await removeCommunity(
|
let unremoveCommunityRes = await removeCommunity(
|
||||||
beta,
|
beta,
|
||||||
false,
|
false,
|
||||||
communityRes.community.id
|
communityRes.community_view.community.id
|
||||||
);
|
);
|
||||||
expect(unremoveCommunityRes.community.removed).toBe(false);
|
expect(unremoveCommunityRes.community_view.community.removed).toBe(false);
|
||||||
await delay();
|
await delay();
|
||||||
|
|
||||||
// Make sure it got undeleted on A
|
// Make sure it got undeleted on A
|
||||||
let communityOnAlphaUnRemoved = await getCommunity(alpha, communityOnAlpha.id);
|
let communityOnAlphaUnRemoved = await getCommunity(
|
||||||
expect(communityOnAlphaUnRemoved.community.removed).toBe(false);
|
alpha,
|
||||||
|
communityOnAlpha.community.id
|
||||||
|
);
|
||||||
|
expect(communityOnAlphaUnRemoved.community_view.community.removed).toBe(
|
||||||
|
false
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Search for beta community', async () => {
|
test('Search for beta community', async () => {
|
||||||
let communityRes = await createCommunity(beta);
|
let communityRes = await createCommunity(beta);
|
||||||
expect(communityRes.community.name).toBeDefined();
|
expect(communityRes.community_view.community.name).toBeDefined();
|
||||||
await delay();
|
await delay();
|
||||||
|
|
||||||
let searchShort = `!${communityRes.community.name}@lemmy-beta:8551`;
|
let searchShort = `!${communityRes.community_view.community.name}@lemmy-beta:8551`;
|
||||||
let search = await searchForCommunity(alpha, searchShort);
|
let search = await searchForCommunity(alpha, searchShort);
|
||||||
let communityOnAlpha = search.communities[0];
|
let communityOnAlpha = search.communities[0];
|
||||||
assertCommunityFederation(communityOnAlpha, communityRes.community);
|
assertCommunityFederation(communityOnAlpha, communityRes.community_view);
|
||||||
});
|
});
|
||||||
|
|
|
@ -20,24 +20,28 @@ afterAll(async () => {
|
||||||
|
|
||||||
test('Follow federated community', async () => {
|
test('Follow federated community', async () => {
|
||||||
let search = await searchForBetaCommunity(alpha); // TODO sometimes this is returning null?
|
let search = await searchForBetaCommunity(alpha); // TODO sometimes this is returning null?
|
||||||
let follow = await followCommunity(alpha, true, search.communities[0].id);
|
let follow = await followCommunity(
|
||||||
|
alpha,
|
||||||
|
true,
|
||||||
|
search.communities[0].community.id
|
||||||
|
);
|
||||||
|
|
||||||
// Make sure the follow response went through
|
// Make sure the follow response went through
|
||||||
expect(follow.community.local).toBe(false);
|
expect(follow.community_view.community.local).toBe(false);
|
||||||
expect(follow.community.name).toBe('main');
|
expect(follow.community_view.community.name).toBe('main');
|
||||||
await longDelay();
|
await longDelay();
|
||||||
|
|
||||||
// Check it from local
|
// Check it from local
|
||||||
let followCheck = await checkFollowedCommunities(alpha);
|
let followCheck = await checkFollowedCommunities(alpha);
|
||||||
await delay();
|
await delay();
|
||||||
let remoteCommunityId = followCheck.communities.filter(
|
let remoteCommunityId = followCheck.communities.find(
|
||||||
c => c.community_local == false
|
c => c.community.local == false
|
||||||
)[0].community_id;
|
).community.id;
|
||||||
expect(remoteCommunityId).toBeDefined();
|
expect(remoteCommunityId).toBeDefined();
|
||||||
|
|
||||||
// Test an unfollow
|
// Test an unfollow
|
||||||
let unfollow = await followCommunity(alpha, false, remoteCommunityId);
|
let unfollow = await followCommunity(alpha, false, remoteCommunityId);
|
||||||
expect(unfollow.community.local).toBe(false);
|
expect(unfollow.community_view.community.local).toBe(false);
|
||||||
await delay();
|
await delay();
|
||||||
|
|
||||||
// Make sure you are unsubbed locally
|
// Make sure you are unsubbed locally
|
||||||
|
|
|
@ -7,7 +7,7 @@ import {
|
||||||
epsilon,
|
epsilon,
|
||||||
setupLogins,
|
setupLogins,
|
||||||
createPost,
|
createPost,
|
||||||
updatePost,
|
editPost,
|
||||||
stickyPost,
|
stickyPost,
|
||||||
lockPost,
|
lockPost,
|
||||||
searchPost,
|
searchPost,
|
||||||
|
@ -26,9 +26,7 @@ import {
|
||||||
searchPostLocal,
|
searchPostLocal,
|
||||||
banUserFromCommunity,
|
banUserFromCommunity,
|
||||||
} from './shared';
|
} from './shared';
|
||||||
import {
|
import { PostView } from 'lemmy-js-client';
|
||||||
Post,
|
|
||||||
} from 'lemmy-js-client';
|
|
||||||
|
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
await setupLogins();
|
await setupLogins();
|
||||||
|
@ -46,50 +44,48 @@ afterAll(async () => {
|
||||||
await unfollowRemotes(epsilon);
|
await unfollowRemotes(epsilon);
|
||||||
});
|
});
|
||||||
|
|
||||||
function assertPostFederation(
|
function assertPostFederation(postOne: PostView, postTwo: PostView) {
|
||||||
postOne: Post,
|
expect(postOne.post.ap_id).toBe(postTwo.post.ap_id);
|
||||||
postTwo: Post) {
|
expect(postOne.post.name).toBe(postTwo.post.name);
|
||||||
expect(postOne.ap_id).toBe(postTwo.ap_id);
|
expect(postOne.post.body).toBe(postTwo.post.body);
|
||||||
expect(postOne.name).toBe(postTwo.name);
|
expect(postOne.post.url).toBe(postTwo.post.url);
|
||||||
expect(postOne.body).toBe(postTwo.body);
|
expect(postOne.post.nsfw).toBe(postTwo.post.nsfw);
|
||||||
expect(postOne.url).toBe(postTwo.url);
|
expect(postOne.post.embed_title).toBe(postTwo.post.embed_title);
|
||||||
expect(postOne.nsfw).toBe(postTwo.nsfw);
|
expect(postOne.post.embed_description).toBe(postTwo.post.embed_description);
|
||||||
expect(postOne.embed_title).toBe(postTwo.embed_title);
|
expect(postOne.post.embed_html).toBe(postTwo.post.embed_html);
|
||||||
expect(postOne.embed_description).toBe(postTwo.embed_description);
|
expect(postOne.post.published).toBe(postTwo.post.published);
|
||||||
expect(postOne.embed_html).toBe(postTwo.embed_html);
|
expect(postOne.community.actor_id).toBe(postTwo.community.actor_id);
|
||||||
expect(postOne.published).toBe(postTwo.published);
|
expect(postOne.post.locked).toBe(postTwo.post.locked);
|
||||||
expect(postOne.community_actor_id).toBe(postTwo.community_actor_id);
|
expect(postOne.post.removed).toBe(postTwo.post.removed);
|
||||||
expect(postOne.locked).toBe(postTwo.locked);
|
expect(postOne.post.deleted).toBe(postTwo.post.deleted);
|
||||||
expect(postOne.removed).toBe(postTwo.removed);
|
|
||||||
expect(postOne.deleted).toBe(postTwo.deleted);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
test('Create a post', async () => {
|
test('Create a post', async () => {
|
||||||
let search = await searchForBetaCommunity(alpha);
|
let search = await searchForBetaCommunity(alpha);
|
||||||
await delay();
|
await delay();
|
||||||
let postRes = await createPost(alpha, search.communities[0].id);
|
let postRes = await createPost(alpha, search.communities[0].community.id);
|
||||||
expect(postRes.post).toBeDefined();
|
expect(postRes.post_view.post).toBeDefined();
|
||||||
expect(postRes.post.community_local).toBe(false);
|
expect(postRes.post_view.community.local).toBe(false);
|
||||||
expect(postRes.post.creator_local).toBe(true);
|
expect(postRes.post_view.creator.local).toBe(true);
|
||||||
expect(postRes.post.score).toBe(1);
|
expect(postRes.post_view.counts.score).toBe(1);
|
||||||
await longDelay();
|
await longDelay();
|
||||||
|
|
||||||
// Make sure that post is liked on beta
|
// Make sure that post is liked on beta
|
||||||
let searchBeta = await searchPost(beta, postRes.post);
|
let searchBeta = await searchPost(beta, postRes.post_view.post);
|
||||||
let betaPost = searchBeta.posts[0];
|
let betaPost = searchBeta.posts[0];
|
||||||
|
|
||||||
expect(betaPost).toBeDefined();
|
expect(betaPost).toBeDefined();
|
||||||
expect(betaPost.community_local).toBe(true);
|
expect(betaPost.community.local).toBe(true);
|
||||||
expect(betaPost.creator_local).toBe(false);
|
expect(betaPost.creator.local).toBe(false);
|
||||||
expect(betaPost.score).toBe(1);
|
expect(betaPost.counts.score).toBe(1);
|
||||||
assertPostFederation(betaPost, postRes.post);
|
assertPostFederation(betaPost, postRes.post_view);
|
||||||
|
|
||||||
// Delta only follows beta, so it should not see an alpha ap_id
|
// Delta only follows beta, so it should not see an alpha ap_id
|
||||||
let searchDelta = await searchPost(delta, postRes.post);
|
let searchDelta = await searchPost(delta, postRes.post_view.post);
|
||||||
expect(searchDelta.posts[0]).toBeUndefined();
|
expect(searchDelta.posts[0]).toBeUndefined();
|
||||||
|
|
||||||
// Epsilon has alpha blocked, it should not see the alpha post
|
// Epsilon has alpha blocked, it should not see the alpha post
|
||||||
let searchEpsilon = await searchPost(epsilon, postRes.post);
|
let searchEpsilon = await searchPost(epsilon, postRes.post_view.post);
|
||||||
expect(searchEpsilon.posts[0]).toBeUndefined();
|
expect(searchEpsilon.posts[0]).toBeUndefined();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -100,245 +96,244 @@ test('Create a post in a non-existent community', async () => {
|
||||||
|
|
||||||
test('Unlike a post', async () => {
|
test('Unlike a post', async () => {
|
||||||
let search = await searchForBetaCommunity(alpha);
|
let search = await searchForBetaCommunity(alpha);
|
||||||
let postRes = await createPost(alpha, search.communities[0].id);
|
let postRes = await createPost(alpha, search.communities[0].community.id);
|
||||||
await delay();
|
await delay();
|
||||||
let unlike = await likePost(alpha, 0, postRes.post);
|
let unlike = await likePost(alpha, 0, postRes.post_view.post);
|
||||||
expect(unlike.post.score).toBe(0);
|
expect(unlike.post_view.counts.score).toBe(0);
|
||||||
await delay();
|
await delay();
|
||||||
|
|
||||||
// Try to unlike it again, make sure it stays at 0
|
// Try to unlike it again, make sure it stays at 0
|
||||||
let unlike2 = await likePost(alpha, 0, postRes.post);
|
let unlike2 = await likePost(alpha, 0, postRes.post_view.post);
|
||||||
expect(unlike2.post.score).toBe(0);
|
expect(unlike2.post_view.counts.score).toBe(0);
|
||||||
await longDelay();
|
await longDelay();
|
||||||
|
|
||||||
// Make sure that post is unliked on beta
|
// Make sure that post is unliked on beta
|
||||||
let searchBeta = await searchPost(beta, postRes.post);
|
let searchBeta = await searchPost(beta, postRes.post_view.post);
|
||||||
let betaPost = searchBeta.posts[0];
|
let betaPost = searchBeta.posts[0];
|
||||||
|
|
||||||
expect(betaPost).toBeDefined();
|
expect(betaPost).toBeDefined();
|
||||||
expect(betaPost.community_local).toBe(true);
|
expect(betaPost.community.local).toBe(true);
|
||||||
expect(betaPost.creator_local).toBe(false);
|
expect(betaPost.creator.local).toBe(false);
|
||||||
expect(betaPost.score).toBe(0);
|
expect(betaPost.counts.score).toBe(0);
|
||||||
assertPostFederation(betaPost, postRes.post);
|
assertPostFederation(betaPost, postRes.post_view);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Update a post', async () => {
|
test('Update a post', async () => {
|
||||||
let search = await searchForBetaCommunity(alpha);
|
let search = await searchForBetaCommunity(alpha);
|
||||||
let postRes = await createPost(alpha, search.communities[0].id);
|
let postRes = await createPost(alpha, search.communities[0].community.id);
|
||||||
await delay();
|
await delay();
|
||||||
|
|
||||||
let updatedName = 'A jest test federated post, updated';
|
let updatedName = 'A jest test federated post, updated';
|
||||||
let updatedPost = await updatePost(alpha, postRes.post);
|
let updatedPost = await editPost(alpha, postRes.post_view.post);
|
||||||
expect(updatedPost.post.name).toBe(updatedName);
|
expect(updatedPost.post_view.post.name).toBe(updatedName);
|
||||||
expect(updatedPost.post.community_local).toBe(false);
|
expect(updatedPost.post_view.community.local).toBe(false);
|
||||||
expect(updatedPost.post.creator_local).toBe(true);
|
expect(updatedPost.post_view.creator.local).toBe(true);
|
||||||
await delay();
|
await delay();
|
||||||
|
|
||||||
// Make sure that post is updated on beta
|
// Make sure that post is updated on beta
|
||||||
let searchBeta = await searchPost(beta, postRes.post);
|
let searchBeta = await searchPost(beta, postRes.post_view.post);
|
||||||
let betaPost = searchBeta.posts[0];
|
let betaPost = searchBeta.posts[0];
|
||||||
expect(betaPost.community_local).toBe(true);
|
expect(betaPost.community.local).toBe(true);
|
||||||
expect(betaPost.creator_local).toBe(false);
|
expect(betaPost.creator.local).toBe(false);
|
||||||
expect(betaPost.name).toBe(updatedName);
|
expect(betaPost.post.name).toBe(updatedName);
|
||||||
assertPostFederation(betaPost, updatedPost.post);
|
assertPostFederation(betaPost, updatedPost.post_view);
|
||||||
await delay();
|
await delay();
|
||||||
|
|
||||||
// Make sure lemmy beta cannot update the post
|
// Make sure lemmy beta cannot update the post
|
||||||
let updatedPostBeta = await updatePost(beta, betaPost);
|
let updatedPostBeta = await editPost(beta, betaPost.post);
|
||||||
expect(updatedPostBeta).toStrictEqual({ error: 'no_post_edit_allowed' });
|
expect(updatedPostBeta).toStrictEqual({ error: 'no_post_edit_allowed' });
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Sticky a post', async () => {
|
test('Sticky a post', async () => {
|
||||||
let search = await searchForBetaCommunity(alpha);
|
let search = await searchForBetaCommunity(alpha);
|
||||||
let postRes = await createPost(alpha, search.communities[0].id);
|
let postRes = await createPost(alpha, search.communities[0].community.id);
|
||||||
await delay();
|
await delay();
|
||||||
|
|
||||||
let stickiedPostRes = await stickyPost(alpha, true, postRes.post);
|
let stickiedPostRes = await stickyPost(alpha, true, postRes.post_view.post);
|
||||||
expect(stickiedPostRes.post.stickied).toBe(true);
|
expect(stickiedPostRes.post_view.post.stickied).toBe(true);
|
||||||
await delay();
|
await delay();
|
||||||
|
|
||||||
// Make sure that post is stickied on beta
|
// Make sure that post is stickied on beta
|
||||||
let searchBeta = await searchPost(beta, postRes.post);
|
let searchBeta = await searchPost(beta, postRes.post_view.post);
|
||||||
let betaPost = searchBeta.posts[0];
|
let betaPost = searchBeta.posts[0];
|
||||||
expect(betaPost.community_local).toBe(true);
|
expect(betaPost.community.local).toBe(true);
|
||||||
expect(betaPost.creator_local).toBe(false);
|
expect(betaPost.creator.local).toBe(false);
|
||||||
expect(betaPost.stickied).toBe(true);
|
expect(betaPost.post.stickied).toBe(true);
|
||||||
|
|
||||||
// Unsticky a post
|
// Unsticky a post
|
||||||
let unstickiedPost = await stickyPost(alpha, false, postRes.post);
|
let unstickiedPost = await stickyPost(alpha, false, postRes.post_view.post);
|
||||||
expect(unstickiedPost.post.stickied).toBe(false);
|
expect(unstickiedPost.post_view.post.stickied).toBe(false);
|
||||||
await delay();
|
await delay();
|
||||||
|
|
||||||
// Make sure that post is unstickied on beta
|
// Make sure that post is unstickied on beta
|
||||||
let searchBeta2 = await searchPost(beta, postRes.post);
|
let searchBeta2 = await searchPost(beta, postRes.post_view.post);
|
||||||
let betaPost2 = searchBeta2.posts[0];
|
let betaPost2 = searchBeta2.posts[0];
|
||||||
expect(betaPost2.community_local).toBe(true);
|
expect(betaPost2.community.local).toBe(true);
|
||||||
expect(betaPost2.creator_local).toBe(false);
|
expect(betaPost2.creator.local).toBe(false);
|
||||||
expect(betaPost2.stickied).toBe(false);
|
expect(betaPost2.post.stickied).toBe(false);
|
||||||
|
|
||||||
// Make sure that gamma cannot sticky the post on beta
|
// Make sure that gamma cannot sticky the post on beta
|
||||||
let searchGamma = await searchPost(gamma, postRes.post);
|
let searchGamma = await searchPost(gamma, postRes.post_view.post);
|
||||||
let gammaPost = searchGamma.posts[0];
|
let gammaPost = searchGamma.posts[0];
|
||||||
let gammaTrySticky = await stickyPost(gamma, true, gammaPost);
|
let gammaTrySticky = await stickyPost(gamma, true, gammaPost.post);
|
||||||
await delay();
|
await delay();
|
||||||
let searchBeta3 = await searchPost(beta, postRes.post);
|
let searchBeta3 = await searchPost(beta, postRes.post_view.post);
|
||||||
let betaPost3 = searchBeta3.posts[0];
|
let betaPost3 = searchBeta3.posts[0];
|
||||||
expect(gammaTrySticky.post.stickied).toBe(true);
|
expect(gammaTrySticky.post_view.post.stickied).toBe(true);
|
||||||
expect(betaPost3.stickied).toBe(false);
|
expect(betaPost3.post.stickied).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Lock a post', async () => {
|
test('Lock a post', async () => {
|
||||||
let search = await searchForBetaCommunity(alpha);
|
let search = await searchForBetaCommunity(alpha);
|
||||||
await delay();
|
await delay();
|
||||||
let postRes = await createPost(alpha, search.communities[0].id);
|
let postRes = await createPost(alpha, search.communities[0].community.id);
|
||||||
await delay();
|
await delay();
|
||||||
|
|
||||||
// Lock the post
|
// Lock the post
|
||||||
let lockedPostRes = await lockPost(alpha, true, postRes.post);
|
let lockedPostRes = await lockPost(alpha, true, postRes.post_view.post);
|
||||||
expect(lockedPostRes.post.locked).toBe(true);
|
expect(lockedPostRes.post_view.post.locked).toBe(true);
|
||||||
await longDelay();
|
await longDelay();
|
||||||
|
|
||||||
// Make sure that post is locked on beta
|
// Make sure that post is locked on beta
|
||||||
let searchBeta = await searchPostLocal(beta, postRes.post);
|
let searchBeta = await searchPostLocal(beta, postRes.post_view.post);
|
||||||
let betaPost1 = searchBeta.posts[0];
|
let betaPost1 = searchBeta.posts[0];
|
||||||
expect(betaPost1.locked).toBe(true);
|
expect(betaPost1.post.locked).toBe(true);
|
||||||
await delay();
|
await delay();
|
||||||
|
|
||||||
// Try to make a new comment there, on alpha
|
// Try to make a new comment there, on alpha
|
||||||
let comment = await createComment(alpha, postRes.post.id);
|
let comment: any = await createComment(alpha, postRes.post_view.post.id);
|
||||||
expect(comment['error']).toBe('locked');
|
expect(comment['error']).toBe('locked');
|
||||||
await delay();
|
await delay();
|
||||||
|
|
||||||
// Unlock a post
|
// Unlock a post
|
||||||
let unlockedPost = await lockPost(alpha, false, postRes.post);
|
let unlockedPost = await lockPost(alpha, false, postRes.post_view.post);
|
||||||
expect(unlockedPost.post.locked).toBe(false);
|
expect(unlockedPost.post_view.post.locked).toBe(false);
|
||||||
await delay();
|
await delay();
|
||||||
|
|
||||||
// Make sure that post is unlocked on beta
|
// Make sure that post is unlocked on beta
|
||||||
let searchBeta2 = await searchPost(beta, postRes.post);
|
let searchBeta2 = await searchPost(beta, postRes.post_view.post);
|
||||||
let betaPost2 = searchBeta2.posts[0];
|
let betaPost2 = searchBeta2.posts[0];
|
||||||
expect(betaPost2.community_local).toBe(true);
|
expect(betaPost2.community.local).toBe(true);
|
||||||
expect(betaPost2.creator_local).toBe(false);
|
expect(betaPost2.creator.local).toBe(false);
|
||||||
expect(betaPost2.locked).toBe(false);
|
expect(betaPost2.post.locked).toBe(false);
|
||||||
|
|
||||||
// Try to create a new comment, on beta
|
// Try to create a new comment, on beta
|
||||||
let commentBeta = await createComment(beta, betaPost2.id);
|
let commentBeta = await createComment(beta, betaPost2.post.id);
|
||||||
expect(commentBeta).toBeDefined();
|
expect(commentBeta).toBeDefined();
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Delete a post', async () => {
|
test('Delete a post', async () => {
|
||||||
let search = await searchForBetaCommunity(alpha);
|
let search = await searchForBetaCommunity(alpha);
|
||||||
let postRes = await createPost(alpha, search.communities[0].id);
|
let postRes = await createPost(alpha, search.communities[0].community.id);
|
||||||
await delay();
|
await delay();
|
||||||
|
|
||||||
let deletedPost = await deletePost(alpha, true, postRes.post);
|
let deletedPost = await deletePost(alpha, true, postRes.post_view.post);
|
||||||
expect(deletedPost.post.deleted).toBe(true);
|
expect(deletedPost.post_view.post.deleted).toBe(true);
|
||||||
await delay();
|
await delay();
|
||||||
|
|
||||||
// Make sure lemmy beta sees post is deleted
|
// Make sure lemmy beta sees post is deleted
|
||||||
let searchBeta = await searchPost(beta, postRes.post);
|
let searchBeta = await searchPost(beta, postRes.post_view.post);
|
||||||
let betaPost = searchBeta.posts[0];
|
let betaPost = searchBeta.posts[0];
|
||||||
// This will be undefined because of the tombstone
|
// This will be undefined because of the tombstone
|
||||||
expect(betaPost).toBeUndefined();
|
expect(betaPost).toBeUndefined();
|
||||||
await delay();
|
await delay();
|
||||||
|
|
||||||
// Undelete
|
// Undelete
|
||||||
let undeletedPost = await deletePost(alpha, false, postRes.post);
|
let undeletedPost = await deletePost(alpha, false, postRes.post_view.post);
|
||||||
expect(undeletedPost.post.deleted).toBe(false);
|
expect(undeletedPost.post_view.post.deleted).toBe(false);
|
||||||
await delay();
|
await delay();
|
||||||
|
|
||||||
// Make sure lemmy beta sees post is undeleted
|
// Make sure lemmy beta sees post is undeleted
|
||||||
let searchBeta2 = await searchPost(beta, postRes.post);
|
let searchBeta2 = await searchPost(beta, postRes.post_view.post);
|
||||||
let betaPost2 = searchBeta2.posts[0];
|
let betaPost2 = searchBeta2.posts[0];
|
||||||
expect(betaPost2.deleted).toBe(false);
|
expect(betaPost2.post.deleted).toBe(false);
|
||||||
assertPostFederation(betaPost2, undeletedPost.post);
|
assertPostFederation(betaPost2, undeletedPost.post_view);
|
||||||
|
|
||||||
// Make sure lemmy beta cannot delete the post
|
// Make sure lemmy beta cannot delete the post
|
||||||
let deletedPostBeta = await deletePost(beta, true, betaPost2);
|
let deletedPostBeta = await deletePost(beta, true, betaPost2.post);
|
||||||
expect(deletedPostBeta).toStrictEqual({ error: 'no_post_edit_allowed' });
|
expect(deletedPostBeta).toStrictEqual({ error: 'no_post_edit_allowed' });
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Remove a post from admin and community on different instance', async () => {
|
test('Remove a post from admin and community on different instance', async () => {
|
||||||
let search = await searchForBetaCommunity(alpha);
|
let search = await searchForBetaCommunity(alpha);
|
||||||
let postRes = await createPost(alpha, search.communities[0].id);
|
let postRes = await createPost(alpha, search.communities[0].community.id);
|
||||||
await delay();
|
await delay();
|
||||||
|
|
||||||
let removedPost = await removePost(alpha, true, postRes.post);
|
let removedPost = await removePost(alpha, true, postRes.post_view.post);
|
||||||
expect(removedPost.post.removed).toBe(true);
|
expect(removedPost.post_view.post.removed).toBe(true);
|
||||||
await delay();
|
await delay();
|
||||||
|
|
||||||
// Make sure lemmy beta sees post is NOT removed
|
// Make sure lemmy beta sees post is NOT removed
|
||||||
let searchBeta = await searchPost(beta, postRes.post);
|
let searchBeta = await searchPost(beta, postRes.post_view.post);
|
||||||
let betaPost = searchBeta.posts[0];
|
let betaPost = searchBeta.posts[0];
|
||||||
expect(betaPost.removed).toBe(false);
|
expect(betaPost.post.removed).toBe(false);
|
||||||
await delay();
|
await delay();
|
||||||
|
|
||||||
// Undelete
|
// Undelete
|
||||||
let undeletedPost = await removePost(alpha, false, postRes.post);
|
let undeletedPost = await removePost(alpha, false, postRes.post_view.post);
|
||||||
expect(undeletedPost.post.removed).toBe(false);
|
expect(undeletedPost.post_view.post.removed).toBe(false);
|
||||||
await delay();
|
await delay();
|
||||||
|
|
||||||
// Make sure lemmy beta sees post is undeleted
|
// Make sure lemmy beta sees post is undeleted
|
||||||
let searchBeta2 = await searchPost(beta, postRes.post);
|
let searchBeta2 = await searchPost(beta, postRes.post_view.post);
|
||||||
let betaPost2 = searchBeta2.posts[0];
|
let betaPost2 = searchBeta2.posts[0];
|
||||||
expect(betaPost2.removed).toBe(false);
|
expect(betaPost2.post.removed).toBe(false);
|
||||||
assertPostFederation(betaPost2, undeletedPost.post);
|
assertPostFederation(betaPost2, undeletedPost.post_view);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Remove a post from admin and community on same instance', async () => {
|
test('Remove a post from admin and community on same instance', async () => {
|
||||||
let search = await searchForBetaCommunity(alpha);
|
let search = await searchForBetaCommunity(alpha);
|
||||||
let postRes = await createPost(alpha, search.communities[0].id);
|
let postRes = await createPost(alpha, search.communities[0].community.id);
|
||||||
await longDelay();
|
await longDelay();
|
||||||
|
|
||||||
// Get the id for beta
|
// Get the id for beta
|
||||||
let searchBeta = await searchPost(beta, postRes.post);
|
let searchBeta = await searchPost(beta, postRes.post_view.post);
|
||||||
let betaPost = searchBeta.posts[0];
|
let betaPost = searchBeta.posts[0];
|
||||||
await longDelay();
|
await longDelay();
|
||||||
|
|
||||||
// The beta admin removes it (the community lives on beta)
|
// The beta admin removes it (the community lives on beta)
|
||||||
let removePostRes = await removePost(beta, true, betaPost);
|
let removePostRes = await removePost(beta, true, betaPost.post);
|
||||||
expect(removePostRes.post.removed).toBe(true);
|
expect(removePostRes.post_view.post.removed).toBe(true);
|
||||||
await longDelay();
|
await longDelay();
|
||||||
|
|
||||||
// Make sure lemmy alpha sees post is removed
|
// Make sure lemmy alpha sees post is removed
|
||||||
let alphaPost = await getPost(alpha, postRes.post.id);
|
let alphaPost = await getPost(alpha, postRes.post_view.post.id);
|
||||||
expect(alphaPost.post.removed).toBe(true);
|
expect(alphaPost.post_view.post.removed).toBe(true);
|
||||||
assertPostFederation(alphaPost.post, removePostRes.post);
|
assertPostFederation(alphaPost.post_view, removePostRes.post_view);
|
||||||
await longDelay();
|
await longDelay();
|
||||||
|
|
||||||
// Undelete
|
// Undelete
|
||||||
let undeletedPost = await removePost(beta, false, betaPost);
|
let undeletedPost = await removePost(beta, false, betaPost.post);
|
||||||
expect(undeletedPost.post.removed).toBe(false);
|
expect(undeletedPost.post_view.post.removed).toBe(false);
|
||||||
await longDelay();
|
await longDelay();
|
||||||
|
|
||||||
// Make sure lemmy alpha sees post is undeleted
|
// Make sure lemmy alpha sees post is undeleted
|
||||||
let alphaPost2 = await getPost(alpha, postRes.post.id);
|
let alphaPost2 = await getPost(alpha, postRes.post_view.post.id);
|
||||||
await delay();
|
await delay();
|
||||||
expect(alphaPost2.post.removed).toBe(false);
|
expect(alphaPost2.post_view.post.removed).toBe(false);
|
||||||
assertPostFederation(alphaPost2.post, undeletedPost.post);
|
assertPostFederation(alphaPost2.post_view, undeletedPost.post_view);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Search for a post', async () => {
|
test('Search for a post', async () => {
|
||||||
let search = await searchForBetaCommunity(alpha);
|
let search = await searchForBetaCommunity(alpha);
|
||||||
await delay();
|
await delay();
|
||||||
let postRes = await createPost(alpha, search.communities[0].id);
|
let postRes = await createPost(alpha, search.communities[0].community.id);
|
||||||
await delay();
|
await delay();
|
||||||
let searchBeta = await searchPost(beta, postRes.post);
|
let searchBeta = await searchPost(beta, postRes.post_view.post);
|
||||||
|
|
||||||
expect(searchBeta.posts[0].name).toBeDefined();
|
expect(searchBeta.posts[0].post.name).toBeDefined();
|
||||||
});
|
});
|
||||||
|
|
||||||
test('A and G subscribe to B (center) A posts, it gets announced to G', async () => {
|
test('A and G subscribe to B (center) A posts, it gets announced to G', async () => {
|
||||||
let search = await searchForBetaCommunity(alpha);
|
let search = await searchForBetaCommunity(alpha);
|
||||||
let postRes = await createPost(alpha, search.communities[0].id);
|
let postRes = await createPost(alpha, search.communities[0].community.id);
|
||||||
await delay();
|
await delay();
|
||||||
|
|
||||||
let search2 = await searchPost(gamma, postRes.post);
|
let search2 = await searchPost(gamma, postRes.post_view.post);
|
||||||
expect(search2.posts[0].name).toBeDefined();
|
expect(search2.posts[0].post.name).toBeDefined();
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Enforce site ban for federated user', async () => {
|
test('Enforce site ban for federated user', async () => {
|
||||||
|
|
||||||
let alphaShortname = `@lemmy_alpha@lemmy-alpha:8541`;
|
let alphaShortname = `@lemmy_alpha@lemmy-alpha:8541`;
|
||||||
let userSearch = await searchForUser(beta, alphaShortname);
|
let userSearch = await searchForUser(beta, alphaShortname);
|
||||||
let alphaUser = userSearch.users[0];
|
let alphaUser = userSearch.users[0];
|
||||||
|
@ -346,28 +341,28 @@ test('Enforce site ban for federated user', async () => {
|
||||||
await delay();
|
await delay();
|
||||||
|
|
||||||
// ban alpha from beta site
|
// ban alpha from beta site
|
||||||
let banAlpha = await banUserFromSite(beta, alphaUser.id, true);
|
let banAlpha = await banUserFromSite(beta, alphaUser.user.id, true);
|
||||||
expect(banAlpha.banned).toBe(true);
|
expect(banAlpha.banned).toBe(true);
|
||||||
await longDelay();
|
await longDelay();
|
||||||
|
|
||||||
// Alpha makes post on beta
|
// Alpha makes post on beta
|
||||||
let search = await searchForBetaCommunity(alpha);
|
let search = await searchForBetaCommunity(alpha);
|
||||||
await delay();
|
await delay();
|
||||||
let postRes = await createPost(alpha, search.communities[0].id);
|
let postRes = await createPost(alpha, search.communities[0].community.id);
|
||||||
expect(postRes.post).toBeDefined();
|
expect(postRes.post_view.post).toBeDefined();
|
||||||
expect(postRes.post.community_local).toBe(false);
|
expect(postRes.post_view.community.local).toBe(false);
|
||||||
expect(postRes.post.creator_local).toBe(true);
|
expect(postRes.post_view.creator.local).toBe(true);
|
||||||
expect(postRes.post.score).toBe(1);
|
expect(postRes.post_view.counts.score).toBe(1);
|
||||||
await longDelay();
|
await longDelay();
|
||||||
|
|
||||||
// Make sure that post doesn't make it to beta
|
// Make sure that post doesn't make it to beta
|
||||||
let searchBeta = await searchPostLocal(beta, postRes.post);
|
let searchBeta = await searchPostLocal(beta, postRes.post_view.post);
|
||||||
let betaPost = searchBeta.posts[0];
|
let betaPost = searchBeta.posts[0];
|
||||||
expect(betaPost).toBeUndefined();
|
expect(betaPost).toBeUndefined();
|
||||||
await delay();
|
await delay();
|
||||||
|
|
||||||
// Unban alpha
|
// Unban alpha
|
||||||
let unBanAlpha = await banUserFromSite(beta, alphaUser.id, false);
|
let unBanAlpha = await banUserFromSite(beta, alphaUser.user.id, false);
|
||||||
expect(unBanAlpha.banned).toBe(false);
|
expect(unBanAlpha.banned).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -379,27 +374,32 @@ test('Enforce community ban for federated user', async () => {
|
||||||
await delay();
|
await delay();
|
||||||
|
|
||||||
// ban alpha from beta site
|
// ban alpha from beta site
|
||||||
await banUserFromCommunity(beta, alphaUser.id, 2, false);
|
await banUserFromCommunity(beta, alphaUser.user.id, 2, false);
|
||||||
let banAlpha = await banUserFromCommunity(beta, alphaUser.id, 2, true);
|
let banAlpha = await banUserFromCommunity(beta, alphaUser.user.id, 2, true);
|
||||||
expect(banAlpha.banned).toBe(true);
|
expect(banAlpha.banned).toBe(true);
|
||||||
await longDelay();
|
await longDelay();
|
||||||
|
|
||||||
// Alpha makes post on beta
|
// Alpha makes post on beta
|
||||||
let search = await searchForBetaCommunity(alpha);
|
let search = await searchForBetaCommunity(alpha);
|
||||||
await delay();
|
await delay();
|
||||||
let postRes = await createPost(alpha, search.communities[0].id);
|
let postRes = await createPost(alpha, search.communities[0].community.id);
|
||||||
expect(postRes.post).toBeDefined();
|
expect(postRes.post_view.post).toBeDefined();
|
||||||
expect(postRes.post.community_local).toBe(false);
|
expect(postRes.post_view.community.local).toBe(false);
|
||||||
expect(postRes.post.creator_local).toBe(true);
|
expect(postRes.post_view.creator.local).toBe(true);
|
||||||
expect(postRes.post.score).toBe(1);
|
expect(postRes.post_view.counts.score).toBe(1);
|
||||||
await longDelay();
|
await longDelay();
|
||||||
|
|
||||||
// Make sure that post doesn't make it to beta community
|
// Make sure that post doesn't make it to beta community
|
||||||
let searchBeta = await searchPostLocal(beta, postRes.post);
|
let searchBeta = await searchPostLocal(beta, postRes.post_view.post);
|
||||||
let betaPost = searchBeta.posts[0];
|
let betaPost = searchBeta.posts[0];
|
||||||
expect(betaPost).toBeUndefined();
|
expect(betaPost).toBeUndefined();
|
||||||
|
|
||||||
// Unban alpha
|
// Unban alpha
|
||||||
let unBanAlpha = await banUserFromCommunity(beta, alphaUser.id, 2, false);
|
let unBanAlpha = await banUserFromCommunity(
|
||||||
|
beta,
|
||||||
|
alphaUser.user.id,
|
||||||
|
2,
|
||||||
|
false
|
||||||
|
);
|
||||||
expect(unBanAlpha.banned).toBe(false);
|
expect(unBanAlpha.banned).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
|
@ -5,7 +5,7 @@ import {
|
||||||
setupLogins,
|
setupLogins,
|
||||||
followBeta,
|
followBeta,
|
||||||
createPrivateMessage,
|
createPrivateMessage,
|
||||||
updatePrivateMessage,
|
editPrivateMessage,
|
||||||
listPrivateMessages,
|
listPrivateMessages,
|
||||||
deletePrivateMessage,
|
deletePrivateMessage,
|
||||||
unfollowRemotes,
|
unfollowRemotes,
|
||||||
|
@ -19,7 +19,7 @@ beforeAll(async () => {
|
||||||
await setupLogins();
|
await setupLogins();
|
||||||
let follow = await followBeta(alpha);
|
let follow = await followBeta(alpha);
|
||||||
await longDelay();
|
await longDelay();
|
||||||
recipient_id = follow.community.creator_id;
|
recipient_id = follow.community_view.creator.id;
|
||||||
});
|
});
|
||||||
|
|
||||||
afterAll(async () => {
|
afterAll(async () => {
|
||||||
|
@ -28,55 +28,72 @@ afterAll(async () => {
|
||||||
|
|
||||||
test('Create a private message', async () => {
|
test('Create a private message', async () => {
|
||||||
let pmRes = await createPrivateMessage(alpha, recipient_id);
|
let pmRes = await createPrivateMessage(alpha, recipient_id);
|
||||||
expect(pmRes.message.content).toBeDefined();
|
expect(pmRes.private_message_view.private_message.content).toBeDefined();
|
||||||
expect(pmRes.message.local).toBe(true);
|
expect(pmRes.private_message_view.private_message.local).toBe(true);
|
||||||
expect(pmRes.message.creator_local).toBe(true);
|
expect(pmRes.private_message_view.creator.local).toBe(true);
|
||||||
expect(pmRes.message.recipient_local).toBe(false);
|
expect(pmRes.private_message_view.recipient.local).toBe(false);
|
||||||
await delay();
|
await delay();
|
||||||
|
|
||||||
let betaPms = await listPrivateMessages(beta);
|
let betaPms = await listPrivateMessages(beta);
|
||||||
expect(betaPms.messages[0].content).toBeDefined();
|
expect(betaPms.private_messages[0].private_message.content).toBeDefined();
|
||||||
expect(betaPms.messages[0].local).toBe(false);
|
expect(betaPms.private_messages[0].private_message.local).toBe(false);
|
||||||
expect(betaPms.messages[0].creator_local).toBe(false);
|
expect(betaPms.private_messages[0].creator.local).toBe(false);
|
||||||
expect(betaPms.messages[0].recipient_local).toBe(true);
|
expect(betaPms.private_messages[0].recipient.local).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Update a private message', async () => {
|
test('Update a private message', async () => {
|
||||||
let updatedContent = 'A jest test federated private message edited';
|
let updatedContent = 'A jest test federated private message edited';
|
||||||
|
|
||||||
let pmRes = await createPrivateMessage(alpha, recipient_id);
|
let pmRes = await createPrivateMessage(alpha, recipient_id);
|
||||||
let pmUpdated = await updatePrivateMessage(alpha, pmRes.message.id);
|
let pmUpdated = await editPrivateMessage(
|
||||||
expect(pmUpdated.message.content).toBe(updatedContent);
|
alpha,
|
||||||
|
pmRes.private_message_view.private_message.id
|
||||||
|
);
|
||||||
|
expect(pmUpdated.private_message_view.private_message.content).toBe(
|
||||||
|
updatedContent
|
||||||
|
);
|
||||||
await longDelay();
|
await longDelay();
|
||||||
|
|
||||||
let betaPms = await listPrivateMessages(beta);
|
let betaPms = await listPrivateMessages(beta);
|
||||||
expect(betaPms.messages[0].content).toBe(updatedContent);
|
expect(betaPms.private_messages[0].private_message.content).toBe(
|
||||||
|
updatedContent
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Delete a private message', async () => {
|
test('Delete a private message', async () => {
|
||||||
let pmRes = await createPrivateMessage(alpha, recipient_id);
|
let pmRes = await createPrivateMessage(alpha, recipient_id);
|
||||||
await delay();
|
await delay();
|
||||||
let betaPms1 = await listPrivateMessages(beta);
|
let betaPms1 = await listPrivateMessages(beta);
|
||||||
let deletedPmRes = await deletePrivateMessage(alpha, true, pmRes.message.id);
|
let deletedPmRes = await deletePrivateMessage(
|
||||||
expect(deletedPmRes.message.deleted).toBe(true);
|
alpha,
|
||||||
|
true,
|
||||||
|
pmRes.private_message_view.private_message.id
|
||||||
|
);
|
||||||
|
expect(deletedPmRes.private_message_view.private_message.deleted).toBe(true);
|
||||||
await delay();
|
await delay();
|
||||||
|
|
||||||
// The GetPrivateMessages filters out deleted,
|
// The GetPrivateMessages filters out deleted,
|
||||||
// even though they are in the actual database.
|
// even though they are in the actual database.
|
||||||
// no reason to show them
|
// no reason to show them
|
||||||
let betaPms2 = await listPrivateMessages(beta);
|
let betaPms2 = await listPrivateMessages(beta);
|
||||||
expect(betaPms2.messages.length).toBe(betaPms1.messages.length - 1);
|
expect(betaPms2.private_messages.length).toBe(
|
||||||
|
betaPms1.private_messages.length - 1
|
||||||
|
);
|
||||||
await delay();
|
await delay();
|
||||||
|
|
||||||
// Undelete
|
// Undelete
|
||||||
let undeletedPmRes = await deletePrivateMessage(
|
let undeletedPmRes = await deletePrivateMessage(
|
||||||
alpha,
|
alpha,
|
||||||
false,
|
false,
|
||||||
pmRes.message.id
|
pmRes.private_message_view.private_message.id
|
||||||
|
);
|
||||||
|
expect(undeletedPmRes.private_message_view.private_message.deleted).toBe(
|
||||||
|
false
|
||||||
);
|
);
|
||||||
expect(undeletedPmRes.message.deleted).toBe(false);
|
|
||||||
await longDelay();
|
await longDelay();
|
||||||
|
|
||||||
let betaPms3 = await listPrivateMessages(beta);
|
let betaPms3 = await listPrivateMessages(beta);
|
||||||
expect(betaPms3.messages.length).toBe(betaPms1.messages.length);
|
expect(betaPms3.private_messages.length).toBe(
|
||||||
|
betaPms1.private_messages.length
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,52 +1,54 @@
|
||||||
import {
|
import {
|
||||||
LoginForm,
|
Login,
|
||||||
LoginResponse,
|
LoginResponse,
|
||||||
Post,
|
CreatePost,
|
||||||
PostForm,
|
EditPost,
|
||||||
Comment,
|
CreateComment,
|
||||||
DeletePostForm,
|
DeletePost,
|
||||||
RemovePostForm,
|
RemovePost,
|
||||||
StickyPostForm,
|
StickyPost,
|
||||||
LockPostForm,
|
LockPost,
|
||||||
PostResponse,
|
PostResponse,
|
||||||
SearchResponse,
|
SearchResponse,
|
||||||
FollowCommunityForm,
|
FollowCommunity,
|
||||||
CommunityResponse,
|
CommunityResponse,
|
||||||
GetFollowedCommunitiesResponse,
|
GetFollowedCommunitiesResponse,
|
||||||
GetPostResponse,
|
GetPostResponse,
|
||||||
RegisterForm,
|
Register,
|
||||||
CommentForm,
|
Comment,
|
||||||
DeleteCommentForm,
|
EditComment,
|
||||||
RemoveCommentForm,
|
DeleteComment,
|
||||||
SearchForm,
|
RemoveComment,
|
||||||
|
Search,
|
||||||
CommentResponse,
|
CommentResponse,
|
||||||
GetCommunityForm,
|
GetCommunity,
|
||||||
CommunityForm,
|
CreateCommunity,
|
||||||
DeleteCommunityForm,
|
DeleteCommunity,
|
||||||
RemoveCommunityForm,
|
RemoveCommunity,
|
||||||
GetUserMentionsForm,
|
GetUserMentions,
|
||||||
CommentLikeForm,
|
CreateCommentLike,
|
||||||
CreatePostLikeForm,
|
CreatePostLike,
|
||||||
PrivateMessageForm,
|
EditPrivateMessage,
|
||||||
EditPrivateMessageForm,
|
DeletePrivateMessage,
|
||||||
DeletePrivateMessageForm,
|
GetFollowedCommunities,
|
||||||
GetFollowedCommunitiesForm,
|
GetPrivateMessages,
|
||||||
GetPrivateMessagesForm,
|
GetSite,
|
||||||
GetSiteForm,
|
GetPost,
|
||||||
GetPostForm,
|
|
||||||
PrivateMessageResponse,
|
PrivateMessageResponse,
|
||||||
PrivateMessagesResponse,
|
PrivateMessagesResponse,
|
||||||
GetUserMentionsResponse,
|
GetUserMentionsResponse,
|
||||||
UserSettingsForm,
|
SaveUserSettings,
|
||||||
SortType,
|
SortType,
|
||||||
ListingType,
|
ListingType,
|
||||||
GetSiteResponse,
|
GetSiteResponse,
|
||||||
SearchType,
|
SearchType,
|
||||||
LemmyHttp,
|
LemmyHttp,
|
||||||
BanUserResponse,
|
BanUserResponse,
|
||||||
BanUserForm,
|
BanUser,
|
||||||
BanFromCommunityForm,
|
BanFromCommunity,
|
||||||
BanFromCommunityResponse,
|
BanFromCommunityResponse,
|
||||||
|
Post,
|
||||||
|
CreatePrivateMessage,
|
||||||
} from 'lemmy-js-client';
|
} from 'lemmy-js-client';
|
||||||
|
|
||||||
export interface API {
|
export interface API {
|
||||||
|
@ -55,27 +57,27 @@ export interface API {
|
||||||
}
|
}
|
||||||
|
|
||||||
export let alpha: API = {
|
export let alpha: API = {
|
||||||
client: new LemmyHttp('http://localhost:8541/api/v1'),
|
client: new LemmyHttp('http://localhost:8541/api/v2'),
|
||||||
};
|
};
|
||||||
|
|
||||||
export let beta: API = {
|
export let beta: API = {
|
||||||
client: new LemmyHttp('http://localhost:8551/api/v1'),
|
client: new LemmyHttp('http://localhost:8551/api/v2'),
|
||||||
};
|
};
|
||||||
|
|
||||||
export let gamma: API = {
|
export let gamma: API = {
|
||||||
client: new LemmyHttp('http://localhost:8561/api/v1'),
|
client: new LemmyHttp('http://localhost:8561/api/v2'),
|
||||||
};
|
};
|
||||||
|
|
||||||
export let delta: API = {
|
export let delta: API = {
|
||||||
client: new LemmyHttp('http://localhost:8571/api/v1'),
|
client: new LemmyHttp('http://localhost:8571/api/v2'),
|
||||||
};
|
};
|
||||||
|
|
||||||
export let epsilon: API = {
|
export let epsilon: API = {
|
||||||
client: new LemmyHttp('http://localhost:8581/api/v1'),
|
client: new LemmyHttp('http://localhost:8581/api/v2'),
|
||||||
};
|
};
|
||||||
|
|
||||||
export async function setupLogins() {
|
export async function setupLogins() {
|
||||||
let formAlpha: LoginForm = {
|
let formAlpha: Login = {
|
||||||
username_or_email: 'lemmy_alpha',
|
username_or_email: 'lemmy_alpha',
|
||||||
password: 'lemmy',
|
password: 'lemmy',
|
||||||
};
|
};
|
||||||
|
@ -127,7 +129,7 @@ export async function createPost(
|
||||||
let name = randomString(5);
|
let name = randomString(5);
|
||||||
let body = randomString(10);
|
let body = randomString(10);
|
||||||
let url = 'https://google.com/';
|
let url = 'https://google.com/';
|
||||||
let form: PostForm = {
|
let form: CreatePost = {
|
||||||
name,
|
name,
|
||||||
url,
|
url,
|
||||||
body,
|
body,
|
||||||
|
@ -138,9 +140,9 @@ export async function createPost(
|
||||||
return api.client.createPost(form);
|
return api.client.createPost(form);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function updatePost(api: API, post: Post): Promise<PostResponse> {
|
export async function editPost(api: API, post: Post): Promise<PostResponse> {
|
||||||
let name = 'A jest test federated post, updated';
|
let name = 'A jest test federated post, updated';
|
||||||
let form: PostForm = {
|
let form: EditPost = {
|
||||||
name,
|
name,
|
||||||
edit_id: post.id,
|
edit_id: post.id,
|
||||||
auth: api.auth,
|
auth: api.auth,
|
||||||
|
@ -154,7 +156,7 @@ export async function deletePost(
|
||||||
deleted: boolean,
|
deleted: boolean,
|
||||||
post: Post
|
post: Post
|
||||||
): Promise<PostResponse> {
|
): Promise<PostResponse> {
|
||||||
let form: DeletePostForm = {
|
let form: DeletePost = {
|
||||||
edit_id: post.id,
|
edit_id: post.id,
|
||||||
deleted: deleted,
|
deleted: deleted,
|
||||||
auth: api.auth,
|
auth: api.auth,
|
||||||
|
@ -167,7 +169,7 @@ export async function removePost(
|
||||||
removed: boolean,
|
removed: boolean,
|
||||||
post: Post
|
post: Post
|
||||||
): Promise<PostResponse> {
|
): Promise<PostResponse> {
|
||||||
let form: RemovePostForm = {
|
let form: RemovePost = {
|
||||||
edit_id: post.id,
|
edit_id: post.id,
|
||||||
removed,
|
removed,
|
||||||
auth: api.auth,
|
auth: api.auth,
|
||||||
|
@ -180,7 +182,7 @@ export async function stickyPost(
|
||||||
stickied: boolean,
|
stickied: boolean,
|
||||||
post: Post
|
post: Post
|
||||||
): Promise<PostResponse> {
|
): Promise<PostResponse> {
|
||||||
let form: StickyPostForm = {
|
let form: StickyPost = {
|
||||||
edit_id: post.id,
|
edit_id: post.id,
|
||||||
stickied,
|
stickied,
|
||||||
auth: api.auth,
|
auth: api.auth,
|
||||||
|
@ -193,7 +195,7 @@ export async function lockPost(
|
||||||
locked: boolean,
|
locked: boolean,
|
||||||
post: Post
|
post: Post
|
||||||
): Promise<PostResponse> {
|
): Promise<PostResponse> {
|
||||||
let form: LockPostForm = {
|
let form: LockPost = {
|
||||||
edit_id: post.id,
|
edit_id: post.id,
|
||||||
locked,
|
locked,
|
||||||
auth: api.auth,
|
auth: api.auth,
|
||||||
|
@ -205,7 +207,7 @@ export async function searchPost(
|
||||||
api: API,
|
api: API,
|
||||||
post: Post
|
post: Post
|
||||||
): Promise<SearchResponse> {
|
): Promise<SearchResponse> {
|
||||||
let form: SearchForm = {
|
let form: Search = {
|
||||||
q: post.ap_id,
|
q: post.ap_id,
|
||||||
type_: SearchType.Posts,
|
type_: SearchType.Posts,
|
||||||
sort: SortType.TopAll,
|
sort: SortType.TopAll,
|
||||||
|
@ -217,7 +219,7 @@ export async function searchPostLocal(
|
||||||
api: API,
|
api: API,
|
||||||
post: Post
|
post: Post
|
||||||
): Promise<SearchResponse> {
|
): Promise<SearchResponse> {
|
||||||
let form: SearchForm = {
|
let form: Search = {
|
||||||
q: post.name,
|
q: post.name,
|
||||||
type_: SearchType.Posts,
|
type_: SearchType.Posts,
|
||||||
sort: SortType.TopAll,
|
sort: SortType.TopAll,
|
||||||
|
@ -229,7 +231,7 @@ export async function getPost(
|
||||||
api: API,
|
api: API,
|
||||||
post_id: number
|
post_id: number
|
||||||
): Promise<GetPostResponse> {
|
): Promise<GetPostResponse> {
|
||||||
let form: GetPostForm = {
|
let form: GetPost = {
|
||||||
id: post_id,
|
id: post_id,
|
||||||
};
|
};
|
||||||
return api.client.getPost(form);
|
return api.client.getPost(form);
|
||||||
|
@ -239,7 +241,7 @@ export async function searchComment(
|
||||||
api: API,
|
api: API,
|
||||||
comment: Comment
|
comment: Comment
|
||||||
): Promise<SearchResponse> {
|
): Promise<SearchResponse> {
|
||||||
let form: SearchForm = {
|
let form: Search = {
|
||||||
q: comment.ap_id,
|
q: comment.ap_id,
|
||||||
type_: SearchType.Comments,
|
type_: SearchType.Comments,
|
||||||
sort: SortType.TopAll,
|
sort: SortType.TopAll,
|
||||||
|
@ -252,7 +254,7 @@ export async function searchForBetaCommunity(
|
||||||
): Promise<SearchResponse> {
|
): Promise<SearchResponse> {
|
||||||
// Make sure lemmy-beta/c/main is cached on lemmy_alpha
|
// Make sure lemmy-beta/c/main is cached on lemmy_alpha
|
||||||
// Use short-hand search url
|
// Use short-hand search url
|
||||||
let form: SearchForm = {
|
let form: Search = {
|
||||||
q: '!main@lemmy-beta:8551',
|
q: '!main@lemmy-beta:8551',
|
||||||
type_: SearchType.Communities,
|
type_: SearchType.Communities,
|
||||||
sort: SortType.TopAll,
|
sort: SortType.TopAll,
|
||||||
|
@ -262,10 +264,10 @@ export async function searchForBetaCommunity(
|
||||||
|
|
||||||
export async function searchForCommunity(
|
export async function searchForCommunity(
|
||||||
api: API,
|
api: API,
|
||||||
q: string,
|
q: string
|
||||||
): Promise<SearchResponse> {
|
): Promise<SearchResponse> {
|
||||||
// Use short-hand search url
|
// Use short-hand search url
|
||||||
let form: SearchForm = {
|
let form: Search = {
|
||||||
q,
|
q,
|
||||||
type_: SearchType.Communities,
|
type_: SearchType.Communities,
|
||||||
sort: SortType.TopAll,
|
sort: SortType.TopAll,
|
||||||
|
@ -279,7 +281,7 @@ export async function searchForUser(
|
||||||
): Promise<SearchResponse> {
|
): Promise<SearchResponse> {
|
||||||
// Make sure lemmy-beta/c/main is cached on lemmy_alpha
|
// Make sure lemmy-beta/c/main is cached on lemmy_alpha
|
||||||
// Use short-hand search url
|
// Use short-hand search url
|
||||||
let form: SearchForm = {
|
let form: Search = {
|
||||||
q: apShortname,
|
q: apShortname,
|
||||||
type_: SearchType.Users,
|
type_: SearchType.Users,
|
||||||
sort: SortType.TopAll,
|
sort: SortType.TopAll,
|
||||||
|
@ -290,13 +292,14 @@ export async function searchForUser(
|
||||||
export async function banUserFromSite(
|
export async function banUserFromSite(
|
||||||
api: API,
|
api: API,
|
||||||
user_id: number,
|
user_id: number,
|
||||||
ban: boolean,
|
ban: boolean
|
||||||
): Promise<BanUserResponse> {
|
): Promise<BanUserResponse> {
|
||||||
// Make sure lemmy-beta/c/main is cached on lemmy_alpha
|
// Make sure lemmy-beta/c/main is cached on lemmy_alpha
|
||||||
// Use short-hand search url
|
// Use short-hand search url
|
||||||
let form: BanUserForm = {
|
let form: BanUser = {
|
||||||
user_id,
|
user_id,
|
||||||
ban,
|
ban,
|
||||||
|
remove_data: false,
|
||||||
auth: api.auth,
|
auth: api.auth,
|
||||||
};
|
};
|
||||||
return api.client.banUser(form);
|
return api.client.banUser(form);
|
||||||
|
@ -306,13 +309,14 @@ export async function banUserFromCommunity(
|
||||||
api: API,
|
api: API,
|
||||||
user_id: number,
|
user_id: number,
|
||||||
community_id: number,
|
community_id: number,
|
||||||
ban: boolean,
|
ban: boolean
|
||||||
): Promise<BanFromCommunityResponse> {
|
): Promise<BanFromCommunityResponse> {
|
||||||
// Make sure lemmy-beta/c/main is cached on lemmy_alpha
|
// Make sure lemmy-beta/c/main is cached on lemmy_alpha
|
||||||
// Use short-hand search url
|
// Use short-hand search url
|
||||||
let form: BanFromCommunityForm = {
|
let form: BanFromCommunity = {
|
||||||
user_id,
|
user_id,
|
||||||
community_id,
|
community_id,
|
||||||
|
remove_data: false,
|
||||||
ban,
|
ban,
|
||||||
auth: api.auth,
|
auth: api.auth,
|
||||||
};
|
};
|
||||||
|
@ -324,7 +328,7 @@ export async function followCommunity(
|
||||||
follow: boolean,
|
follow: boolean,
|
||||||
community_id: number
|
community_id: number
|
||||||
): Promise<CommunityResponse> {
|
): Promise<CommunityResponse> {
|
||||||
let form: FollowCommunityForm = {
|
let form: FollowCommunity = {
|
||||||
community_id,
|
community_id,
|
||||||
follow,
|
follow,
|
||||||
auth: api.auth,
|
auth: api.auth,
|
||||||
|
@ -335,7 +339,7 @@ export async function followCommunity(
|
||||||
export async function checkFollowedCommunities(
|
export async function checkFollowedCommunities(
|
||||||
api: API
|
api: API
|
||||||
): Promise<GetFollowedCommunitiesResponse> {
|
): Promise<GetFollowedCommunitiesResponse> {
|
||||||
let form: GetFollowedCommunitiesForm = {
|
let form: GetFollowedCommunities = {
|
||||||
auth: api.auth,
|
auth: api.auth,
|
||||||
};
|
};
|
||||||
return api.client.getFollowedCommunities(form);
|
return api.client.getFollowedCommunities(form);
|
||||||
|
@ -346,7 +350,7 @@ export async function likePost(
|
||||||
score: number,
|
score: number,
|
||||||
post: Post
|
post: Post
|
||||||
): Promise<PostResponse> {
|
): Promise<PostResponse> {
|
||||||
let form: CreatePostLikeForm = {
|
let form: CreatePostLike = {
|
||||||
post_id: post.id,
|
post_id: post.id,
|
||||||
score: score,
|
score: score,
|
||||||
auth: api.auth,
|
auth: api.auth,
|
||||||
|
@ -361,7 +365,7 @@ export async function createComment(
|
||||||
parent_id?: number,
|
parent_id?: number,
|
||||||
content = 'a jest test comment'
|
content = 'a jest test comment'
|
||||||
): Promise<CommentResponse> {
|
): Promise<CommentResponse> {
|
||||||
let form: CommentForm = {
|
let form: CreateComment = {
|
||||||
content,
|
content,
|
||||||
post_id,
|
post_id,
|
||||||
parent_id,
|
parent_id,
|
||||||
|
@ -370,12 +374,12 @@ export async function createComment(
|
||||||
return api.client.createComment(form);
|
return api.client.createComment(form);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function updateComment(
|
export async function editComment(
|
||||||
api: API,
|
api: API,
|
||||||
edit_id: number,
|
edit_id: number,
|
||||||
content = 'A jest test federated comment update'
|
content = 'A jest test federated comment update'
|
||||||
): Promise<CommentResponse> {
|
): Promise<CommentResponse> {
|
||||||
let form: CommentForm = {
|
let form: EditComment = {
|
||||||
content,
|
content,
|
||||||
edit_id,
|
edit_id,
|
||||||
auth: api.auth,
|
auth: api.auth,
|
||||||
|
@ -388,7 +392,7 @@ export async function deleteComment(
|
||||||
deleted: boolean,
|
deleted: boolean,
|
||||||
edit_id: number
|
edit_id: number
|
||||||
): Promise<CommentResponse> {
|
): Promise<CommentResponse> {
|
||||||
let form: DeleteCommentForm = {
|
let form: DeleteComment = {
|
||||||
edit_id,
|
edit_id,
|
||||||
deleted,
|
deleted,
|
||||||
auth: api.auth,
|
auth: api.auth,
|
||||||
|
@ -401,7 +405,7 @@ export async function removeComment(
|
||||||
removed: boolean,
|
removed: boolean,
|
||||||
edit_id: number
|
edit_id: number
|
||||||
): Promise<CommentResponse> {
|
): Promise<CommentResponse> {
|
||||||
let form: RemoveCommentForm = {
|
let form: RemoveComment = {
|
||||||
edit_id,
|
edit_id,
|
||||||
removed,
|
removed,
|
||||||
auth: api.auth,
|
auth: api.auth,
|
||||||
|
@ -410,7 +414,7 @@ export async function removeComment(
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getMentions(api: API): Promise<GetUserMentionsResponse> {
|
export async function getMentions(api: API): Promise<GetUserMentionsResponse> {
|
||||||
let form: GetUserMentionsForm = {
|
let form: GetUserMentions = {
|
||||||
sort: SortType.New,
|
sort: SortType.New,
|
||||||
unread_only: false,
|
unread_only: false,
|
||||||
auth: api.auth,
|
auth: api.auth,
|
||||||
|
@ -423,7 +427,7 @@ export async function likeComment(
|
||||||
score: number,
|
score: number,
|
||||||
comment: Comment
|
comment: Comment
|
||||||
): Promise<CommentResponse> {
|
): Promise<CommentResponse> {
|
||||||
let form: CommentLikeForm = {
|
let form: CreateCommentLike = {
|
||||||
comment_id: comment.id,
|
comment_id: comment.id,
|
||||||
score,
|
score,
|
||||||
auth: api.auth,
|
auth: api.auth,
|
||||||
|
@ -438,7 +442,7 @@ export async function createCommunity(
|
||||||
let description = 'a sample description';
|
let description = 'a sample description';
|
||||||
let icon = 'https://image.flaticon.com/icons/png/512/35/35896.png';
|
let icon = 'https://image.flaticon.com/icons/png/512/35/35896.png';
|
||||||
let banner = 'https://image.flaticon.com/icons/png/512/35/35896.png';
|
let banner = 'https://image.flaticon.com/icons/png/512/35/35896.png';
|
||||||
let form: CommunityForm = {
|
let form: CreateCommunity = {
|
||||||
name: name_,
|
name: name_,
|
||||||
title: name_,
|
title: name_,
|
||||||
description,
|
description,
|
||||||
|
@ -453,9 +457,9 @@ export async function createCommunity(
|
||||||
|
|
||||||
export async function getCommunity(
|
export async function getCommunity(
|
||||||
api: API,
|
api: API,
|
||||||
id: number,
|
id: number
|
||||||
): Promise<CommunityResponse> {
|
): Promise<CommunityResponse> {
|
||||||
let form: GetCommunityForm = {
|
let form: GetCommunity = {
|
||||||
id,
|
id,
|
||||||
};
|
};
|
||||||
return api.client.getCommunity(form);
|
return api.client.getCommunity(form);
|
||||||
|
@ -466,7 +470,7 @@ export async function deleteCommunity(
|
||||||
deleted: boolean,
|
deleted: boolean,
|
||||||
edit_id: number
|
edit_id: number
|
||||||
): Promise<CommunityResponse> {
|
): Promise<CommunityResponse> {
|
||||||
let form: DeleteCommunityForm = {
|
let form: DeleteCommunity = {
|
||||||
edit_id,
|
edit_id,
|
||||||
deleted,
|
deleted,
|
||||||
auth: api.auth,
|
auth: api.auth,
|
||||||
|
@ -479,7 +483,7 @@ export async function removeCommunity(
|
||||||
removed: boolean,
|
removed: boolean,
|
||||||
edit_id: number
|
edit_id: number
|
||||||
): Promise<CommunityResponse> {
|
): Promise<CommunityResponse> {
|
||||||
let form: RemoveCommunityForm = {
|
let form: RemoveCommunity = {
|
||||||
edit_id,
|
edit_id,
|
||||||
removed,
|
removed,
|
||||||
auth: api.auth,
|
auth: api.auth,
|
||||||
|
@ -492,7 +496,7 @@ export async function createPrivateMessage(
|
||||||
recipient_id: number
|
recipient_id: number
|
||||||
): Promise<PrivateMessageResponse> {
|
): Promise<PrivateMessageResponse> {
|
||||||
let content = 'A jest test federated private message';
|
let content = 'A jest test federated private message';
|
||||||
let form: PrivateMessageForm = {
|
let form: CreatePrivateMessage = {
|
||||||
content,
|
content,
|
||||||
recipient_id,
|
recipient_id,
|
||||||
auth: api.auth,
|
auth: api.auth,
|
||||||
|
@ -500,12 +504,12 @@ export async function createPrivateMessage(
|
||||||
return api.client.createPrivateMessage(form);
|
return api.client.createPrivateMessage(form);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function updatePrivateMessage(
|
export async function editPrivateMessage(
|
||||||
api: API,
|
api: API,
|
||||||
edit_id: number
|
edit_id: number
|
||||||
): Promise<PrivateMessageResponse> {
|
): Promise<PrivateMessageResponse> {
|
||||||
let updatedContent = 'A jest test federated private message edited';
|
let updatedContent = 'A jest test federated private message edited';
|
||||||
let form: EditPrivateMessageForm = {
|
let form: EditPrivateMessage = {
|
||||||
content: updatedContent,
|
content: updatedContent,
|
||||||
edit_id,
|
edit_id,
|
||||||
auth: api.auth,
|
auth: api.auth,
|
||||||
|
@ -518,7 +522,7 @@ export async function deletePrivateMessage(
|
||||||
deleted: boolean,
|
deleted: boolean,
|
||||||
edit_id: number
|
edit_id: number
|
||||||
): Promise<PrivateMessageResponse> {
|
): Promise<PrivateMessageResponse> {
|
||||||
let form: DeletePrivateMessageForm = {
|
let form: DeletePrivateMessage = {
|
||||||
deleted,
|
deleted,
|
||||||
edit_id,
|
edit_id,
|
||||||
auth: api.auth,
|
auth: api.auth,
|
||||||
|
@ -530,7 +534,7 @@ export async function registerUser(
|
||||||
api: API,
|
api: API,
|
||||||
username: string = randomString(5)
|
username: string = randomString(5)
|
||||||
): Promise<LoginResponse> {
|
): Promise<LoginResponse> {
|
||||||
let form: RegisterForm = {
|
let form: Register = {
|
||||||
username,
|
username,
|
||||||
password: 'test',
|
password: 'test',
|
||||||
password_verify: 'test',
|
password_verify: 'test',
|
||||||
|
@ -544,11 +548,11 @@ export async function saveUserSettingsBio(
|
||||||
api: API,
|
api: API,
|
||||||
auth: string
|
auth: string
|
||||||
): Promise<LoginResponse> {
|
): Promise<LoginResponse> {
|
||||||
let form: UserSettingsForm = {
|
let form: SaveUserSettings = {
|
||||||
show_nsfw: true,
|
show_nsfw: true,
|
||||||
theme: 'darkly',
|
theme: 'darkly',
|
||||||
default_sort_type: Object.keys(SortType).indexOf(SortType.Active),
|
default_sort_type: SortType.Active,
|
||||||
default_listing_type: Object.keys(ListingType).indexOf(ListingType.All),
|
default_listing_type: ListingType.All,
|
||||||
lang: 'en',
|
lang: 'en',
|
||||||
show_avatars: true,
|
show_avatars: true,
|
||||||
send_notifications_to_email: false,
|
send_notifications_to_email: false,
|
||||||
|
@ -560,7 +564,7 @@ export async function saveUserSettingsBio(
|
||||||
|
|
||||||
export async function saveUserSettings(
|
export async function saveUserSettings(
|
||||||
api: API,
|
api: API,
|
||||||
form: UserSettingsForm
|
form: SaveUserSettings
|
||||||
): Promise<LoginResponse> {
|
): Promise<LoginResponse> {
|
||||||
return api.client.saveUserSettings(form);
|
return api.client.saveUserSettings(form);
|
||||||
}
|
}
|
||||||
|
@ -569,7 +573,7 @@ export async function getSite(
|
||||||
api: API,
|
api: API,
|
||||||
auth: string
|
auth: string
|
||||||
): Promise<GetSiteResponse> {
|
): Promise<GetSiteResponse> {
|
||||||
let form: GetSiteForm = {
|
let form: GetSite = {
|
||||||
auth,
|
auth,
|
||||||
};
|
};
|
||||||
return api.client.getSite(form);
|
return api.client.getSite(form);
|
||||||
|
@ -578,7 +582,7 @@ export async function getSite(
|
||||||
export async function listPrivateMessages(
|
export async function listPrivateMessages(
|
||||||
api: API
|
api: API
|
||||||
): Promise<PrivateMessagesResponse> {
|
): Promise<PrivateMessagesResponse> {
|
||||||
let form: GetPrivateMessagesForm = {
|
let form: GetPrivateMessages = {
|
||||||
auth: api.auth,
|
auth: api.auth,
|
||||||
unread_only: false,
|
unread_only: false,
|
||||||
limit: 999,
|
limit: 999,
|
||||||
|
@ -592,10 +596,10 @@ export async function unfollowRemotes(
|
||||||
// Unfollow all remote communities
|
// Unfollow all remote communities
|
||||||
let followed = await checkFollowedCommunities(api);
|
let followed = await checkFollowedCommunities(api);
|
||||||
let remoteFollowed = followed.communities.filter(
|
let remoteFollowed = followed.communities.filter(
|
||||||
c => c.community_local == false
|
c => c.community.local == false
|
||||||
);
|
);
|
||||||
for (let cu of remoteFollowed) {
|
for (let cu of remoteFollowed) {
|
||||||
await followCommunity(api, false, cu.community_id);
|
await followCommunity(api, false, cu.community.id);
|
||||||
}
|
}
|
||||||
let followed2 = await checkFollowedCommunities(api);
|
let followed2 = await checkFollowedCommunities(api);
|
||||||
return followed2;
|
return followed2;
|
||||||
|
@ -606,17 +610,15 @@ export async function followBeta(api: API): Promise<CommunityResponse> {
|
||||||
|
|
||||||
// Cache it
|
// Cache it
|
||||||
let search = await searchForBetaCommunity(api);
|
let search = await searchForBetaCommunity(api);
|
||||||
let com = search.communities.filter(c => c.local == false);
|
let com = search.communities.find(c => c.community.local == false);
|
||||||
if (com[0]) {
|
if (com) {
|
||||||
let follow = await followCommunity(api, true, com[0].id);
|
let follow = await followCommunity(api, true, com.community.id);
|
||||||
return follow;
|
return follow;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function delay(millis: number = 500) {
|
export function delay(millis: number = 500) {
|
||||||
return new Promise((resolve, _reject) => {
|
return new Promise(resolve => setTimeout(resolve, millis));
|
||||||
setTimeout(_ => resolve(), millis);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function longDelay() {
|
export function longDelay() {
|
||||||
|
|
|
@ -9,23 +9,23 @@ import {
|
||||||
getSite,
|
getSite,
|
||||||
} from './shared';
|
} from './shared';
|
||||||
import {
|
import {
|
||||||
UserView,
|
UserViewSafe,
|
||||||
UserSettingsForm,
|
SaveUserSettings,
|
||||||
|
SortType,
|
||||||
|
ListingType,
|
||||||
} from 'lemmy-js-client';
|
} from 'lemmy-js-client';
|
||||||
|
|
||||||
let auth: string;
|
let auth: string;
|
||||||
let apShortname: string;
|
let apShortname: string;
|
||||||
|
|
||||||
function assertUserFederation(
|
function assertUserFederation(userOne: UserViewSafe, userTwo: UserViewSafe) {
|
||||||
userOne: UserView,
|
expect(userOne.user.name).toBe(userTwo.user.name);
|
||||||
userTwo: UserView) {
|
expect(userOne.user.preferred_username).toBe(userTwo.user.preferred_username);
|
||||||
expect(userOne.name).toBe(userTwo.name);
|
expect(userOne.user.bio).toBe(userTwo.user.bio);
|
||||||
expect(userOne.preferred_username).toBe(userTwo.preferred_username);
|
expect(userOne.user.actor_id).toBe(userTwo.user.actor_id);
|
||||||
expect(userOne.bio).toBe(userTwo.bio);
|
expect(userOne.user.avatar).toBe(userTwo.user.avatar);
|
||||||
expect(userOne.actor_id).toBe(userTwo.actor_id);
|
expect(userOne.user.banner).toBe(userTwo.user.banner);
|
||||||
expect(userOne.avatar).toBe(userTwo.avatar);
|
expect(userOne.user.published).toBe(userTwo.user.published);
|
||||||
expect(userOne.banner).toBe(userTwo.banner);
|
|
||||||
expect(userOne.published).toBe(userTwo.published);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
test('Create user', async () => {
|
test('Create user', async () => {
|
||||||
|
@ -55,20 +55,20 @@ test('Save user settings, check changed bio from beta', async () => {
|
||||||
test('Set avatar and banner, check that they are federated', async () => {
|
test('Set avatar and banner, check that they are federated', async () => {
|
||||||
let avatar = 'https://image.flaticon.com/icons/png/512/35/35896.png';
|
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 banner = 'https://image.flaticon.com/icons/png/512/36/35896.png';
|
||||||
let form: UserSettingsForm = {
|
let form: SaveUserSettings = {
|
||||||
show_nsfw: false,
|
show_nsfw: false,
|
||||||
theme: "",
|
theme: '',
|
||||||
default_sort_type: 0,
|
default_sort_type: SortType.Hot,
|
||||||
default_listing_type: 0,
|
default_listing_type: ListingType.All,
|
||||||
lang: "",
|
lang: '',
|
||||||
avatar,
|
avatar,
|
||||||
banner,
|
banner,
|
||||||
preferred_username: "user321",
|
preferred_username: 'user321',
|
||||||
show_avatars: false,
|
show_avatars: false,
|
||||||
send_notifications_to_email: false,
|
send_notifications_to_email: false,
|
||||||
auth,
|
auth,
|
||||||
}
|
};
|
||||||
let settingsRes = await saveUserSettings(alpha, form);
|
let _settingsRes = await saveUserSettings(alpha, form);
|
||||||
|
|
||||||
let searchAlpha = await searchForUser(beta, apShortname);
|
let searchAlpha = await searchForUser(beta, apShortname);
|
||||||
let userOnAlpha = searchAlpha.users[0];
|
let userOnAlpha = searchAlpha.users[0];
|
||||||
|
|
16
api_tests/tsconfig.json
Normal file
16
api_tests/tsconfig.json
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"declaration": true,
|
||||||
|
"declarationDir": "./dist",
|
||||||
|
"module": "CommonJS",
|
||||||
|
"noImplicitAny": true,
|
||||||
|
"lib": ["es2017", "es7", "es6", "dom"],
|
||||||
|
"outDir": "./dist",
|
||||||
|
"target": "ES5",
|
||||||
|
"moduleResolution": "Node"
|
||||||
|
},
|
||||||
|
"include": [
|
||||||
|
"src/**/*"
|
||||||
|
],
|
||||||
|
"exclude": ["node_modules", "dist"]
|
||||||
|
}
|
2558
api_tests/yarn.lock
2558
api_tests/yarn.lock
File diff suppressed because it is too large
Load diff
|
@ -7,7 +7,7 @@ use serde::Deserialize;
|
||||||
|
|
||||||
pub fn config(cfg: &mut web::ServiceConfig, rate_limit: &RateLimit) {
|
pub fn config(cfg: &mut web::ServiceConfig, rate_limit: &RateLimit) {
|
||||||
cfg.service(
|
cfg.service(
|
||||||
web::scope("/api/v1")
|
web::scope("/api/v2")
|
||||||
// Websockets
|
// Websockets
|
||||||
.service(web::resource("/ws").to(super::websocket::chat_route))
|
.service(web::resource("/ws").to(super::websocket::chat_route))
|
||||||
// Site
|
// Site
|
||||||
|
|
Loading…
Reference in a new issue