mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-11-22 06:36:14 +00:00
Fixing drone tests.
This commit is contained in:
parent
e492cce206
commit
179709cc09
|
@ -17,4 +17,4 @@ killall lemmy_server
|
||||||
|
|
||||||
for INSTANCE in lemmy_alpha lemmy_beta lemmy_gamma lemmy_delta lemmy_epsilon; do
|
for INSTANCE in lemmy_alpha lemmy_beta lemmy_gamma lemmy_delta lemmy_epsilon; do
|
||||||
psql "$LEMMY_DATABASE_URL" -c "DROP DATABASE $INSTANCE"
|
psql "$LEMMY_DATABASE_URL" -c "DROP DATABASE $INSTANCE"
|
||||||
done
|
done
|
||||||
|
|
|
@ -20,8 +20,6 @@ import {
|
||||||
createCommunity,
|
createCommunity,
|
||||||
registerUser,
|
registerUser,
|
||||||
API,
|
API,
|
||||||
delay,
|
|
||||||
longDelay,
|
|
||||||
} from './shared';
|
} from './shared';
|
||||||
import {
|
import {
|
||||||
Comment,
|
Comment,
|
||||||
|
@ -36,7 +34,6 @@ beforeAll(async () => {
|
||||||
await followBeta(alpha);
|
await followBeta(alpha);
|
||||||
await followBeta(gamma);
|
await followBeta(gamma);
|
||||||
let search = await searchForBetaCommunity(alpha);
|
let search = await searchForBetaCommunity(alpha);
|
||||||
await longDelay();
|
|
||||||
postRes = await createPost(
|
postRes = await createPost(
|
||||||
alpha,
|
alpha,
|
||||||
search.communities.filter(c => c.local == false)[0].id
|
search.communities.filter(c => c.local == false)[0].id
|
||||||
|
@ -67,7 +64,6 @@ test('Create a comment', async () => {
|
||||||
expect(commentRes.comment.community_local).toBe(false);
|
expect(commentRes.comment.community_local).toBe(false);
|
||||||
expect(commentRes.comment.creator_local).toBe(true);
|
expect(commentRes.comment.creator_local).toBe(true);
|
||||||
expect(commentRes.comment.score).toBe(1);
|
expect(commentRes.comment.score).toBe(1);
|
||||||
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);
|
||||||
|
@ -90,14 +86,12 @@ test('Update a comment', async () => {
|
||||||
let searchBeta = await searchComment(beta, commentRes.comment);
|
let searchBeta = await searchComment(beta, commentRes.comment);
|
||||||
assertCommentFederation(searchBeta.comments[0], commentRes.comment);
|
assertCommentFederation(searchBeta.comments[0], commentRes.comment);
|
||||||
|
|
||||||
await delay();
|
|
||||||
let updateCommentRes = await updateComment(alpha, commentRes.comment.id);
|
let updateCommentRes = await updateComment(alpha, commentRes.comment.id);
|
||||||
expect(updateCommentRes.comment.content).toBe(
|
expect(updateCommentRes.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.community_local).toBe(false);
|
||||||
expect(updateCommentRes.comment.creator_local).toBe(true);
|
expect(updateCommentRes.comment.creator_local).toBe(true);
|
||||||
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(beta, commentRes.comment);
|
||||||
|
@ -106,7 +100,6 @@ test('Update a comment', async () => {
|
||||||
|
|
||||||
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.id);
|
||||||
await delay();
|
|
||||||
|
|
||||||
let deleteCommentRes = await deleteComment(
|
let deleteCommentRes = await deleteComment(
|
||||||
alpha,
|
alpha,
|
||||||
|
@ -114,13 +107,11 @@ test('Delete a comment', async () => {
|
||||||
commentRes.comment.id
|
commentRes.comment.id
|
||||||
);
|
);
|
||||||
expect(deleteCommentRes.comment.deleted).toBe(true);
|
expect(deleteCommentRes.comment.deleted).toBe(true);
|
||||||
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);
|
||||||
let betaComment = searchBeta.comments[0];
|
let betaComment = searchBeta.comments[0];
|
||||||
expect(betaComment).toBeUndefined();
|
expect(betaComment).toBeUndefined();
|
||||||
await delay();
|
|
||||||
|
|
||||||
let undeleteCommentRes = await deleteComment(
|
let undeleteCommentRes = await deleteComment(
|
||||||
alpha,
|
alpha,
|
||||||
|
@ -128,7 +119,6 @@ test('Delete a comment', async () => {
|
||||||
commentRes.comment.id
|
commentRes.comment.id
|
||||||
);
|
);
|
||||||
expect(undeleteCommentRes.comment.deleted).toBe(false);
|
expect(undeleteCommentRes.comment.deleted).toBe(false);
|
||||||
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);
|
||||||
|
@ -139,7 +129,6 @@ test('Delete a comment', async () => {
|
||||||
|
|
||||||
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.id);
|
||||||
await delay();
|
|
||||||
|
|
||||||
// Get the id for beta
|
// Get the id for beta
|
||||||
let betaCommentId = (await searchComment(beta, commentRes.comment))
|
let betaCommentId = (await searchComment(beta, commentRes.comment))
|
||||||
|
@ -148,7 +137,6 @@ test('Remove a comment from admin and community on the same instance', async ()
|
||||||
// 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.removed).toBe(true);
|
||||||
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.id);
|
||||||
|
@ -156,7 +144,6 @@ test('Remove a comment from admin and community on the same instance', async ()
|
||||||
|
|
||||||
let unremoveCommentRes = await removeComment(beta, false, betaCommentId);
|
let unremoveCommentRes = await removeComment(beta, false, betaCommentId);
|
||||||
expect(unremoveCommentRes.comment.removed).toBe(false);
|
expect(unremoveCommentRes.comment.removed).toBe(false);
|
||||||
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.id);
|
||||||
|
@ -173,19 +160,15 @@ 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();
|
|
||||||
let newPost = await createPost(newAlphaApi, newCommunity.community.id);
|
let newPost = await createPost(newAlphaApi, newCommunity.community.id);
|
||||||
await delay();
|
|
||||||
let commentRes = await createComment(newAlphaApi, newPost.post.id);
|
let commentRes = await createComment(newAlphaApi, newPost.post.id);
|
||||||
expect(commentRes.comment.content).toBeDefined();
|
expect(commentRes.comment.content).toBeDefined();
|
||||||
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);
|
||||||
let betaComment = searchBeta.comments[0];
|
let betaComment = searchBeta.comments[0];
|
||||||
let removeCommentRes = await removeComment(beta, true, betaComment.id);
|
let removeCommentRes = await removeComment(beta, true, betaComment.id);
|
||||||
expect(removeCommentRes.comment.removed).toBe(true);
|
expect(removeCommentRes.comment.removed).toBe(true);
|
||||||
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.id);
|
||||||
|
@ -195,10 +178,8 @@ test('Remove a comment from admin and community on different instance', async ()
|
||||||
|
|
||||||
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.id);
|
||||||
await delay();
|
|
||||||
let unlike = await likeComment(alpha, 0, commentRes.comment);
|
let unlike = await likeComment(alpha, 0, commentRes.comment);
|
||||||
expect(unlike.comment.score).toBe(0);
|
expect(unlike.comment.score).toBe(0);
|
||||||
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);
|
||||||
|
@ -211,7 +192,6 @@ test('Unlike a comment', async () => {
|
||||||
|
|
||||||
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.id);
|
||||||
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);
|
||||||
|
@ -219,7 +199,6 @@ test('Federated comment like', async () => {
|
||||||
|
|
||||||
let like = await likeComment(beta, 1, betaComment);
|
let like = await likeComment(beta, 1, betaComment);
|
||||||
expect(like.comment.score).toBe(2);
|
expect(like.comment.score).toBe(2);
|
||||||
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.id);
|
||||||
|
@ -229,7 +208,6 @@ test('Federated comment like', async () => {
|
||||||
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.id);
|
||||||
await delay();
|
|
||||||
let searchBeta = await searchComment(beta, commentRes.comment);
|
let searchBeta = await searchComment(beta, commentRes.comment);
|
||||||
let betaComment = searchBeta.comments[0];
|
let betaComment = searchBeta.comments[0];
|
||||||
|
|
||||||
|
@ -242,7 +220,6 @@ test('Reply to a comment', async () => {
|
||||||
expect(replyRes.comment.creator_local).toBe(true);
|
expect(replyRes.comment.creator_local).toBe(true);
|
||||||
expect(replyRes.comment.parent_id).toBe(betaComment.id);
|
expect(replyRes.comment.parent_id).toBe(betaComment.id);
|
||||||
expect(replyRes.comment.score).toBe(1);
|
expect(replyRes.comment.score).toBe(1);
|
||||||
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
|
||||||
|
@ -262,7 +239,6 @@ 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.id);
|
||||||
await delay();
|
|
||||||
let mentionRes = await createComment(
|
let mentionRes = await createComment(
|
||||||
alpha,
|
alpha,
|
||||||
postRes.post.id,
|
postRes.post.id,
|
||||||
|
@ -273,7 +249,6 @@ test('Mention beta', async () => {
|
||||||
expect(mentionRes.comment.community_local).toBe(false);
|
expect(mentionRes.comment.community_local).toBe(false);
|
||||||
expect(mentionRes.comment.creator_local).toBe(true);
|
expect(mentionRes.comment.creator_local).toBe(true);
|
||||||
expect(mentionRes.comment.score).toBe(1);
|
expect(mentionRes.comment.score).toBe(1);
|
||||||
await delay();
|
|
||||||
|
|
||||||
let mentionsRes = await getMentions(beta);
|
let mentionsRes = await getMentions(beta);
|
||||||
expect(mentionsRes.mentions[0].content).toBeDefined();
|
expect(mentionsRes.mentions[0].content).toBeDefined();
|
||||||
|
@ -284,7 +259,6 @@ test('Mention beta', async () => {
|
||||||
|
|
||||||
test('Comment Search', async () => {
|
test('Comment Search', async () => {
|
||||||
let commentRes = await createComment(alpha, postRes.post.id);
|
let commentRes = await createComment(alpha, postRes.post.id);
|
||||||
await delay();
|
|
||||||
let searchBeta = await searchComment(beta, commentRes.comment);
|
let searchBeta = await searchComment(beta, commentRes.comment);
|
||||||
assertCommentFederation(searchBeta.comments[0], commentRes.comment);
|
assertCommentFederation(searchBeta.comments[0], commentRes.comment);
|
||||||
});
|
});
|
||||||
|
@ -293,7 +267,6 @@ test('A and G subscribe to B (center) A posts, G mentions B, it gets announced t
|
||||||
// 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.community_local).toBe(true);
|
||||||
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);
|
||||||
|
@ -311,7 +284,6 @@ test('A and G subscribe to B (center) A posts, G mentions B, it gets announced t
|
||||||
expect(commentRes.comment.community_local).toBe(false);
|
expect(commentRes.comment.community_local).toBe(false);
|
||||||
expect(commentRes.comment.creator_local).toBe(true);
|
expect(commentRes.comment.creator_local).toBe(true);
|
||||||
expect(commentRes.comment.score).toBe(1);
|
expect(commentRes.comment.score).toBe(1);
|
||||||
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.id);
|
||||||
|
@ -320,7 +292,6 @@ test('A and G subscribe to B (center) A posts, G mentions B, it gets announced t
|
||||||
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].score).toBe(1);
|
||||||
assertCommentFederation(alphaPost2.comments[0], commentRes.comment);
|
assertCommentFederation(alphaPost2.comments[0], commentRes.comment);
|
||||||
await delay();
|
|
||||||
|
|
||||||
// Make sure beta has mentions
|
// Make sure beta has mentions
|
||||||
let mentionsRes = await getMentions(beta);
|
let mentionsRes = await getMentions(beta);
|
||||||
|
@ -341,7 +312,6 @@ test('Fetch in_reply_tos: A is unsubbed from B, B makes a post, and some embedde
|
||||||
// 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.name).toBeDefined();
|
||||||
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(
|
||||||
|
@ -351,7 +321,6 @@ test('Fetch in_reply_tos: A is unsubbed from B, B makes a post, and some embedde
|
||||||
parentCommentContent
|
parentCommentContent
|
||||||
);
|
);
|
||||||
expect(parentCommentRes.comment.content).toBe(parentCommentContent);
|
expect(parentCommentRes.comment.content).toBe(parentCommentContent);
|
||||||
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';
|
||||||
|
@ -362,13 +331,11 @@ test('Fetch in_reply_tos: A is unsubbed from B, B makes a post, and some embedde
|
||||||
childCommentContent
|
childCommentContent
|
||||||
);
|
);
|
||||||
expect(childCommentRes.comment.content).toBe(childCommentContent);
|
expect(childCommentRes.comment.content).toBe(childCommentContent);
|
||||||
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.local).toBe(false);
|
||||||
expect(follow.community.name).toBe('main');
|
expect(follow.community.name).toBe('main');
|
||||||
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';
|
||||||
|
@ -378,12 +345,10 @@ test('Fetch in_reply_tos: A is unsubbed from B, B makes a post, and some embedde
|
||||||
updatedCommentContent
|
updatedCommentContent
|
||||||
);
|
);
|
||||||
expect(updateRes.comment.content).toBe(updatedCommentContent);
|
expect(updateRes.comment.content).toBe(updatedCommentContent);
|
||||||
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);
|
||||||
let alphaPostB = search.posts[0];
|
let alphaPostB = search.posts[0];
|
||||||
await longDelay();
|
|
||||||
|
|
||||||
let alphaPost = await getPost(alpha, alphaPostB.id);
|
let alphaPost = await getPost(alpha, alphaPostB.id);
|
||||||
expect(alphaPost.post.name).toBeDefined();
|
expect(alphaPost.post.name).toBeDefined();
|
||||||
|
|
|
@ -3,15 +3,12 @@ import {
|
||||||
alpha,
|
alpha,
|
||||||
beta,
|
beta,
|
||||||
setupLogins,
|
setupLogins,
|
||||||
searchForBetaCommunity,
|
|
||||||
searchForCommunity,
|
searchForCommunity,
|
||||||
createCommunity,
|
createCommunity,
|
||||||
deleteCommunity,
|
deleteCommunity,
|
||||||
removeCommunity,
|
removeCommunity,
|
||||||
getCommunity,
|
getCommunity,
|
||||||
followCommunity,
|
followCommunity,
|
||||||
delay,
|
|
||||||
longDelay,
|
|
||||||
} from './shared';
|
} from './shared';
|
||||||
import {
|
import {
|
||||||
Community,
|
Community,
|
||||||
|
@ -46,7 +43,6 @@ test('Create community', async () => {
|
||||||
let prevName = communityRes.community.name;
|
let prevName = communityRes.community.name;
|
||||||
let communityRes2 = await createCommunity(alpha, prevName);
|
let communityRes2 = await createCommunity(alpha, prevName);
|
||||||
expect(communityRes2['error']).toBe('community_already_exists');
|
expect(communityRes2['error']).toBe('community_already_exists');
|
||||||
await delay();
|
|
||||||
|
|
||||||
// Cache the community on beta, make sure it has the other fields
|
// Cache the community on beta, make sure it has the other fields
|
||||||
let searchShort = `!${prevName}@lemmy-alpha:8541`;
|
let searchShort = `!${prevName}@lemmy-alpha:8541`;
|
||||||
|
@ -57,21 +53,18 @@ test('Create community', async () => {
|
||||||
|
|
||||||
test('Delete community', async () => {
|
test('Delete community', async () => {
|
||||||
let communityRes = await createCommunity(beta);
|
let communityRes = await createCommunity(beta);
|
||||||
await delay();
|
|
||||||
|
|
||||||
// Cache the community on Alpha
|
// Cache the community on Alpha
|
||||||
let searchShort = `!${communityRes.community.name}@lemmy-beta:8551`;
|
let searchShort = `!${communityRes.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);
|
||||||
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.id);
|
||||||
|
|
||||||
// Make sure the follow response went through
|
// Make sure the follow response went through
|
||||||
expect(follow.community.local).toBe(false);
|
expect(follow.community.local).toBe(false);
|
||||||
await delay();
|
|
||||||
|
|
||||||
let deleteCommunityRes = await deleteCommunity(
|
let deleteCommunityRes = await deleteCommunity(
|
||||||
beta,
|
beta,
|
||||||
|
@ -79,12 +72,10 @@ test('Delete community', async () => {
|
||||||
communityRes.community.id
|
communityRes.community.id
|
||||||
);
|
);
|
||||||
expect(deleteCommunityRes.community.deleted).toBe(true);
|
expect(deleteCommunityRes.community.deleted).toBe(true);
|
||||||
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(alpha, communityOnAlpha.id);
|
||||||
expect(communityOnAlphaDeleted.community.deleted).toBe(true);
|
expect(communityOnAlphaDeleted.community.deleted).toBe(true);
|
||||||
await delay();
|
|
||||||
|
|
||||||
// Undelete
|
// Undelete
|
||||||
let undeleteCommunityRes = await deleteCommunity(
|
let undeleteCommunityRes = await deleteCommunity(
|
||||||
|
@ -93,7 +84,6 @@ test('Delete community', async () => {
|
||||||
communityRes.community.id
|
communityRes.community.id
|
||||||
);
|
);
|
||||||
expect(undeleteCommunityRes.community.deleted).toBe(false);
|
expect(undeleteCommunityRes.community.deleted).toBe(false);
|
||||||
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(alpha, communityOnAlpha.id);
|
||||||
|
@ -102,21 +92,18 @@ test('Delete community', async () => {
|
||||||
|
|
||||||
test('Remove community', async () => {
|
test('Remove community', async () => {
|
||||||
let communityRes = await createCommunity(beta);
|
let communityRes = await createCommunity(beta);
|
||||||
await delay();
|
|
||||||
|
|
||||||
// Cache the community on Alpha
|
// Cache the community on Alpha
|
||||||
let searchShort = `!${communityRes.community.name}@lemmy-beta:8551`;
|
let searchShort = `!${communityRes.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);
|
||||||
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.id);
|
||||||
|
|
||||||
// Make sure the follow response went through
|
// Make sure the follow response went through
|
||||||
expect(follow.community.local).toBe(false);
|
expect(follow.community.local).toBe(false);
|
||||||
await delay();
|
|
||||||
|
|
||||||
let removeCommunityRes = await removeCommunity(
|
let removeCommunityRes = await removeCommunity(
|
||||||
beta,
|
beta,
|
||||||
|
@ -124,12 +111,10 @@ test('Remove community', async () => {
|
||||||
communityRes.community.id
|
communityRes.community.id
|
||||||
);
|
);
|
||||||
expect(removeCommunityRes.community.removed).toBe(true);
|
expect(removeCommunityRes.community.removed).toBe(true);
|
||||||
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(alpha, communityOnAlpha.id);
|
||||||
expect(communityOnAlphaRemoved.community.removed).toBe(true);
|
expect(communityOnAlphaRemoved.community.removed).toBe(true);
|
||||||
await delay();
|
|
||||||
|
|
||||||
// unremove
|
// unremove
|
||||||
let unremoveCommunityRes = await removeCommunity(
|
let unremoveCommunityRes = await removeCommunity(
|
||||||
|
@ -138,7 +123,6 @@ test('Remove community', async () => {
|
||||||
communityRes.community.id
|
communityRes.community.id
|
||||||
);
|
);
|
||||||
expect(unremoveCommunityRes.community.removed).toBe(false);
|
expect(unremoveCommunityRes.community.removed).toBe(false);
|
||||||
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(alpha, communityOnAlpha.id);
|
||||||
|
@ -148,7 +132,6 @@ test('Remove community', async () => {
|
||||||
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.name).toBeDefined();
|
||||||
await delay();
|
|
||||||
|
|
||||||
let searchShort = `!${communityRes.community.name}@lemmy-beta:8551`;
|
let searchShort = `!${communityRes.community.name}@lemmy-beta:8551`;
|
||||||
let search = await searchForCommunity(alpha, searchShort);
|
let search = await searchForCommunity(alpha, searchShort);
|
||||||
|
|
|
@ -6,8 +6,6 @@ import {
|
||||||
followCommunity,
|
followCommunity,
|
||||||
checkFollowedCommunities,
|
checkFollowedCommunities,
|
||||||
unfollowRemotes,
|
unfollowRemotes,
|
||||||
delay,
|
|
||||||
longDelay,
|
|
||||||
} from './shared';
|
} from './shared';
|
||||||
|
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
|
@ -25,11 +23,9 @@ test('Follow federated community', async () => {
|
||||||
// Make sure the follow response went through
|
// Make sure the follow response went through
|
||||||
expect(follow.community.local).toBe(false);
|
expect(follow.community.local).toBe(false);
|
||||||
expect(follow.community.name).toBe('main');
|
expect(follow.community.name).toBe('main');
|
||||||
await longDelay();
|
|
||||||
|
|
||||||
// Check it from local
|
// Check it from local
|
||||||
let followCheck = await checkFollowedCommunities(alpha);
|
let followCheck = await checkFollowedCommunities(alpha);
|
||||||
await delay();
|
|
||||||
let remoteCommunityId = followCheck.communities.filter(
|
let remoteCommunityId = followCheck.communities.filter(
|
||||||
c => c.community_local == false
|
c => c.community_local == false
|
||||||
)[0].community_id;
|
)[0].community_id;
|
||||||
|
@ -38,7 +34,6 @@ test('Follow federated community', async () => {
|
||||||
// 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.local).toBe(false);
|
||||||
await delay();
|
|
||||||
|
|
||||||
// Make sure you are unsubbed locally
|
// Make sure you are unsubbed locally
|
||||||
let unfollowCheck = await checkFollowedCommunities(alpha);
|
let unfollowCheck = await checkFollowedCommunities(alpha);
|
||||||
|
|
|
@ -19,8 +19,6 @@ import {
|
||||||
removePost,
|
removePost,
|
||||||
getPost,
|
getPost,
|
||||||
unfollowRemotes,
|
unfollowRemotes,
|
||||||
delay,
|
|
||||||
longDelay,
|
|
||||||
searchForUser,
|
searchForUser,
|
||||||
banUserFromSite,
|
banUserFromSite,
|
||||||
searchPostLocal,
|
searchPostLocal,
|
||||||
|
@ -28,15 +26,15 @@ import {
|
||||||
} from './shared';
|
} from './shared';
|
||||||
import {
|
import {
|
||||||
Post,
|
Post,
|
||||||
|
Community,
|
||||||
} from 'lemmy-js-client';
|
} from 'lemmy-js-client';
|
||||||
|
|
||||||
|
let betaCommunity: Community;
|
||||||
|
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
await setupLogins();
|
await setupLogins();
|
||||||
await followBeta(alpha);
|
let search = await searchForBetaCommunity(alpha);
|
||||||
await followBeta(gamma);
|
betaCommunity = search.communities[0];
|
||||||
await followBeta(delta);
|
|
||||||
await followBeta(epsilon);
|
|
||||||
await longDelay();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
afterAll(async () => {
|
afterAll(async () => {
|
||||||
|
@ -65,14 +63,11 @@ function assertPostFederation(
|
||||||
}
|
}
|
||||||
|
|
||||||
test('Create a post', async () => {
|
test('Create a post', async () => {
|
||||||
let search = await searchForBetaCommunity(alpha);
|
let postRes = await createPost(alpha, betaCommunity.id);
|
||||||
await delay();
|
|
||||||
let postRes = await createPost(alpha, search.communities[0].id);
|
|
||||||
expect(postRes.post).toBeDefined();
|
expect(postRes.post).toBeDefined();
|
||||||
expect(postRes.post.community_local).toBe(false);
|
expect(postRes.post.community_local).toBe(false);
|
||||||
expect(postRes.post.creator_local).toBe(true);
|
expect(postRes.post.creator_local).toBe(true);
|
||||||
expect(postRes.post.score).toBe(1);
|
expect(postRes.post.score).toBe(1);
|
||||||
await delay();
|
|
||||||
|
|
||||||
// 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);
|
||||||
|
@ -99,9 +94,7 @@ 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 postRes = await createPost(alpha, betaCommunity.id);
|
||||||
await delay();
|
|
||||||
let postRes = await createPost(alpha, search.communities[0].id);
|
|
||||||
let unlike = await likePost(alpha, 0, postRes.post);
|
let unlike = await likePost(alpha, 0, postRes.post);
|
||||||
expect(unlike.post.score).toBe(0);
|
expect(unlike.post.score).toBe(0);
|
||||||
|
|
||||||
|
@ -120,16 +113,13 @@ test('Unlike a post', async () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Update a post', async () => {
|
test('Update a post', async () => {
|
||||||
let search = await searchForBetaCommunity(alpha);
|
let postRes = await createPost(alpha, betaCommunity.id);
|
||||||
let postRes = await createPost(alpha, search.communities[0].id);
|
|
||||||
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 updatePost(alpha, postRes.post);
|
||||||
expect(updatedPost.post.name).toBe(updatedName);
|
expect(updatedPost.post.name).toBe(updatedName);
|
||||||
expect(updatedPost.post.community_local).toBe(false);
|
expect(updatedPost.post.community_local).toBe(false);
|
||||||
expect(updatedPost.post.creator_local).toBe(true);
|
expect(updatedPost.post.creator_local).toBe(true);
|
||||||
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);
|
||||||
|
@ -138,7 +128,6 @@ test('Update a post', async () => {
|
||||||
expect(betaPost.creator_local).toBe(false);
|
expect(betaPost.creator_local).toBe(false);
|
||||||
expect(betaPost.name).toBe(updatedName);
|
expect(betaPost.name).toBe(updatedName);
|
||||||
assertPostFederation(betaPost, updatedPost.post);
|
assertPostFederation(betaPost, updatedPost.post);
|
||||||
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 updatePost(beta, betaPost);
|
||||||
|
@ -146,26 +135,20 @@ test('Update a post', async () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Sticky a post', async () => {
|
test('Sticky a post', async () => {
|
||||||
let search = await searchForBetaCommunity(alpha);
|
let postRes = await createPost(alpha, betaCommunity.id);
|
||||||
let postRes = await createPost(alpha, search.communities[0].id);
|
|
||||||
await delay();
|
|
||||||
|
|
||||||
let stickiedPostRes = await stickyPost(alpha, true, postRes.post);
|
let stickiedPostRes = await stickyPost(alpha, true, postRes.post);
|
||||||
expect(stickiedPostRes.post.stickied).toBe(true);
|
expect(stickiedPostRes.post.stickied).toBe(true);
|
||||||
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);
|
||||||
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.stickied).toBe(true);
|
||||||
await delay();
|
|
||||||
|
|
||||||
// Unsticky a post
|
// Unsticky a post
|
||||||
let unstickiedPost = await stickyPost(alpha, false, postRes.post);
|
let unstickiedPost = await stickyPost(alpha, false, postRes.post);
|
||||||
expect(unstickiedPost.post.stickied).toBe(false);
|
expect(unstickiedPost.post.stickied).toBe(false);
|
||||||
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);
|
||||||
|
@ -173,14 +156,11 @@ test('Sticky a post', async () => {
|
||||||
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.stickied).toBe(false);
|
||||||
await delay();
|
|
||||||
|
|
||||||
// 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);
|
||||||
let gammaPost = searchGamma.posts[0];
|
let gammaPost = searchGamma.posts[0];
|
||||||
await delay();
|
|
||||||
let gammaTrySticky = await stickyPost(gamma, true, gammaPost);
|
let gammaTrySticky = await stickyPost(gamma, true, gammaPost);
|
||||||
await delay();
|
|
||||||
let searchBeta3 = await searchPost(beta, postRes.post);
|
let searchBeta3 = await searchPost(beta, postRes.post);
|
||||||
let betaPost3 = searchBeta3.posts[0];
|
let betaPost3 = searchBeta3.posts[0];
|
||||||
expect(gammaTrySticky.post.stickied).toBe(true);
|
expect(gammaTrySticky.post.stickied).toBe(true);
|
||||||
|
@ -188,31 +168,24 @@ test('Sticky a post', async () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Lock a post', async () => {
|
test('Lock a post', async () => {
|
||||||
let search = await searchForBetaCommunity(alpha);
|
let postRes = await createPost(alpha, betaCommunity.id);
|
||||||
await delay();
|
|
||||||
let postRes = await createPost(alpha, search.communities[0].id);
|
|
||||||
await delay();
|
|
||||||
|
|
||||||
// Lock the post
|
// Lock the post
|
||||||
let lockedPostRes = await lockPost(alpha, true, postRes.post);
|
let lockedPostRes = await lockPost(alpha, true, postRes.post);
|
||||||
expect(lockedPostRes.post.locked).toBe(true);
|
expect(lockedPostRes.post.locked).toBe(true);
|
||||||
await delay();
|
|
||||||
|
|
||||||
// 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);
|
||||||
let betaPost1 = searchBeta.posts[0];
|
let betaPost1 = searchBeta.posts[0];
|
||||||
expect(betaPost1.locked).toBe(true);
|
expect(betaPost1.locked).toBe(true);
|
||||||
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 = await createComment(alpha, postRes.post.id);
|
||||||
expect(comment['error']).toBe('locked');
|
expect(comment['error']).toBe('locked');
|
||||||
await delay();
|
|
||||||
|
|
||||||
// Unlock a post
|
// Unlock a post
|
||||||
let unlockedPost = await lockPost(alpha, false, postRes.post);
|
let unlockedPost = await lockPost(alpha, false, postRes.post);
|
||||||
expect(unlockedPost.post.locked).toBe(false);
|
expect(unlockedPost.post.locked).toBe(false);
|
||||||
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);
|
||||||
|
@ -220,7 +193,6 @@ test('Lock a post', async () => {
|
||||||
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.locked).toBe(false);
|
||||||
await delay();
|
|
||||||
|
|
||||||
// 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.id);
|
||||||
|
@ -228,9 +200,7 @@ test('Lock a post', async () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Delete a post', async () => {
|
test('Delete a post', async () => {
|
||||||
let search = await searchForBetaCommunity(alpha);
|
let postRes = await createPost(alpha, betaCommunity.id);
|
||||||
await delay();
|
|
||||||
let postRes = await createPost(alpha, search.communities[0].id);
|
|
||||||
|
|
||||||
let deletedPost = await deletePost(alpha, true, postRes.post);
|
let deletedPost = await deletePost(alpha, true, postRes.post);
|
||||||
expect(deletedPost.post.deleted).toBe(true);
|
expect(deletedPost.post.deleted).toBe(true);
|
||||||
|
@ -257,25 +227,19 @@ test('Delete a post', async () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
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 postRes = await createPost(alpha, betaCommunity.id);
|
||||||
await delay();
|
|
||||||
let postRes = await createPost(alpha, search.communities[0].id);
|
|
||||||
await delay();
|
|
||||||
|
|
||||||
let removedPost = await removePost(alpha, true, postRes.post);
|
let removedPost = await removePost(alpha, true, postRes.post);
|
||||||
expect(removedPost.post.removed).toBe(true);
|
expect(removedPost.post.removed).toBe(true);
|
||||||
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);
|
||||||
let betaPost = searchBeta.posts[0];
|
let betaPost = searchBeta.posts[0];
|
||||||
expect(betaPost.removed).toBe(false);
|
expect(betaPost.removed).toBe(false);
|
||||||
await delay();
|
|
||||||
|
|
||||||
// Undelete
|
// Undelete
|
||||||
let undeletedPost = await removePost(alpha, false, postRes.post);
|
let undeletedPost = await removePost(alpha, false, postRes.post);
|
||||||
expect(undeletedPost.post.removed).toBe(false);
|
expect(undeletedPost.post.removed).toBe(false);
|
||||||
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);
|
||||||
|
@ -285,52 +249,43 @@ test('Remove a post from admin and community on different instance', async () =>
|
||||||
});
|
});
|
||||||
|
|
||||||
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 postRes = await createPost(alpha, betaCommunity.id);
|
||||||
await delay();
|
|
||||||
let postRes = await createPost(alpha, search.communities[0].id);
|
|
||||||
await delay();
|
|
||||||
|
|
||||||
// Get the id for beta
|
// Get the id for beta
|
||||||
let searchBeta = await searchPost(beta, postRes.post);
|
let searchBeta = await searchPost(beta, postRes.post);
|
||||||
let betaPost = searchBeta.posts[0];
|
let betaPost = searchBeta.posts[0];
|
||||||
await delay();
|
|
||||||
|
await followBeta(alpha);
|
||||||
|
|
||||||
// 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);
|
||||||
expect(removePostRes.post.removed).toBe(true);
|
expect(removePostRes.post.removed).toBe(true);
|
||||||
await delay();
|
|
||||||
|
|
||||||
// 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.id);
|
||||||
expect(alphaPost.post.removed).toBe(true);
|
expect(alphaPost.post.removed).toBe(true);
|
||||||
assertPostFederation(alphaPost.post, removePostRes.post);
|
assertPostFederation(alphaPost.post, removePostRes.post);
|
||||||
await delay();
|
|
||||||
|
|
||||||
// Undelete
|
// Undelete
|
||||||
let undeletedPost = await removePost(beta, false, betaPost);
|
let undeletedPost = await removePost(beta, false, betaPost);
|
||||||
expect(undeletedPost.post.removed).toBe(false);
|
expect(undeletedPost.post.removed).toBe(false);
|
||||||
await delay();
|
|
||||||
|
|
||||||
// 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.id);
|
||||||
expect(alphaPost2.post.removed).toBe(false);
|
expect(alphaPost2.post.removed).toBe(false);
|
||||||
assertPostFederation(alphaPost2.post, undeletedPost.post);
|
assertPostFederation(alphaPost2.post, undeletedPost.post);
|
||||||
|
await unfollowRemotes(alpha);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Search for a post', async () => {
|
test('Search for a post', async () => {
|
||||||
let search = await searchForBetaCommunity(alpha);
|
let postRes = await createPost(alpha, betaCommunity.id);
|
||||||
await delay();
|
|
||||||
let postRes = await createPost(alpha, search.communities[0].id);
|
|
||||||
await delay();
|
|
||||||
let searchBeta = await searchPost(beta, postRes.post);
|
let searchBeta = await searchPost(beta, postRes.post);
|
||||||
|
|
||||||
expect(searchBeta.posts[0].name).toBeDefined();
|
expect(searchBeta.posts[0].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 postRes = await createPost(alpha, betaCommunity.id);
|
||||||
let postRes = await createPost(alpha, search.communities[0].id);
|
|
||||||
await delay();
|
|
||||||
|
|
||||||
let search2 = await searchPost(gamma, postRes.post);
|
let search2 = await searchPost(gamma, postRes.post);
|
||||||
expect(search2.posts[0].name).toBeDefined();
|
expect(search2.posts[0].name).toBeDefined();
|
||||||
|
@ -342,28 +297,22 @@ test('Enforce site ban for federated user', async () => {
|
||||||
let userSearch = await searchForUser(beta, alphaShortname);
|
let userSearch = await searchForUser(beta, alphaShortname);
|
||||||
let alphaUser = userSearch.users[0];
|
let alphaUser = userSearch.users[0];
|
||||||
expect(alphaUser).toBeDefined();
|
expect(alphaUser).toBeDefined();
|
||||||
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.id, true);
|
||||||
expect(banAlpha.banned).toBe(true);
|
expect(banAlpha.banned).toBe(true);
|
||||||
await delay();
|
|
||||||
|
|
||||||
// Alpha makes post on beta
|
// Alpha makes post on beta
|
||||||
let search = await searchForBetaCommunity(alpha);
|
let postRes = await createPost(alpha, betaCommunity.id);
|
||||||
await delay();
|
|
||||||
let postRes = await createPost(alpha, search.communities[0].id);
|
|
||||||
expect(postRes.post).toBeDefined();
|
expect(postRes.post).toBeDefined();
|
||||||
expect(postRes.post.community_local).toBe(false);
|
expect(postRes.post.community_local).toBe(false);
|
||||||
expect(postRes.post.creator_local).toBe(true);
|
expect(postRes.post.creator_local).toBe(true);
|
||||||
expect(postRes.post.score).toBe(1);
|
expect(postRes.post.score).toBe(1);
|
||||||
await delay();
|
|
||||||
|
|
||||||
// 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);
|
||||||
let betaPost = searchBeta.posts[0];
|
let betaPost = searchBeta.posts[0];
|
||||||
expect(betaPost).toBeUndefined();
|
expect(betaPost).toBeUndefined();
|
||||||
await delay();
|
|
||||||
|
|
||||||
// Unban alpha
|
// Unban alpha
|
||||||
let unBanAlpha = await banUserFromSite(beta, alphaUser.id, false);
|
let unBanAlpha = await banUserFromSite(beta, alphaUser.id, false);
|
||||||
|
@ -375,23 +324,18 @@ test('Enforce community ban for federated user', async () => {
|
||||||
let userSearch = await searchForUser(beta, alphaShortname);
|
let userSearch = await searchForUser(beta, alphaShortname);
|
||||||
let alphaUser = userSearch.users[0];
|
let alphaUser = userSearch.users[0];
|
||||||
expect(alphaUser).toBeDefined();
|
expect(alphaUser).toBeDefined();
|
||||||
await delay();
|
|
||||||
|
|
||||||
// ban alpha from beta site
|
// ban alpha from beta site
|
||||||
await banUserFromCommunity(beta, alphaUser.id, 2, false);
|
await banUserFromCommunity(beta, alphaUser.id, 2, false);
|
||||||
let banAlpha = await banUserFromCommunity(beta, alphaUser.id, 2, true);
|
let banAlpha = await banUserFromCommunity(beta, alphaUser.id, 2, true);
|
||||||
expect(banAlpha.banned).toBe(true);
|
expect(banAlpha.banned).toBe(true);
|
||||||
await delay();
|
|
||||||
|
|
||||||
// Alpha makes post on beta
|
// Alpha makes post on beta
|
||||||
let search = await searchForBetaCommunity(alpha);
|
let postRes = await createPost(alpha, betaCommunity.id);
|
||||||
await delay();
|
|
||||||
let postRes = await createPost(alpha, search.communities[0].id);
|
|
||||||
expect(postRes.post).toBeDefined();
|
expect(postRes.post).toBeDefined();
|
||||||
expect(postRes.post.community_local).toBe(false);
|
expect(postRes.post.community_local).toBe(false);
|
||||||
expect(postRes.post.creator_local).toBe(true);
|
expect(postRes.post.creator_local).toBe(true);
|
||||||
expect(postRes.post.score).toBe(1);
|
expect(postRes.post.score).toBe(1);
|
||||||
await delay();
|
|
||||||
|
|
||||||
// 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);
|
||||||
|
|
|
@ -9,8 +9,6 @@ import {
|
||||||
listPrivateMessages,
|
listPrivateMessages,
|
||||||
deletePrivateMessage,
|
deletePrivateMessage,
|
||||||
unfollowRemotes,
|
unfollowRemotes,
|
||||||
delay,
|
|
||||||
longDelay,
|
|
||||||
} from './shared';
|
} from './shared';
|
||||||
|
|
||||||
let recipient_id: number;
|
let recipient_id: number;
|
||||||
|
@ -18,7 +16,6 @@ let recipient_id: number;
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
await setupLogins();
|
await setupLogins();
|
||||||
let follow = await followBeta(alpha);
|
let follow = await followBeta(alpha);
|
||||||
await longDelay();
|
|
||||||
recipient_id = follow.community.creator_id;
|
recipient_id = follow.community.creator_id;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -32,7 +29,6 @@ test('Create a private message', async () => {
|
||||||
expect(pmRes.message.local).toBe(true);
|
expect(pmRes.message.local).toBe(true);
|
||||||
expect(pmRes.message.creator_local).toBe(true);
|
expect(pmRes.message.creator_local).toBe(true);
|
||||||
expect(pmRes.message.recipient_local).toBe(false);
|
expect(pmRes.message.recipient_local).toBe(false);
|
||||||
await delay();
|
|
||||||
|
|
||||||
let betaPms = await listPrivateMessages(beta);
|
let betaPms = await listPrivateMessages(beta);
|
||||||
expect(betaPms.messages[0].content).toBeDefined();
|
expect(betaPms.messages[0].content).toBeDefined();
|
||||||
|
@ -47,7 +43,6 @@ test('Update a private message', async () => {
|
||||||
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 updatePrivateMessage(alpha, pmRes.message.id);
|
||||||
expect(pmUpdated.message.content).toBe(updatedContent);
|
expect(pmUpdated.message.content).toBe(updatedContent);
|
||||||
await longDelay();
|
|
||||||
|
|
||||||
let betaPms = await listPrivateMessages(beta);
|
let betaPms = await listPrivateMessages(beta);
|
||||||
expect(betaPms.messages[0].content).toBe(updatedContent);
|
expect(betaPms.messages[0].content).toBe(updatedContent);
|
||||||
|
@ -55,18 +50,15 @@ test('Update a private message', async () => {
|
||||||
|
|
||||||
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();
|
|
||||||
let betaPms1 = await listPrivateMessages(beta);
|
let betaPms1 = await listPrivateMessages(beta);
|
||||||
let deletedPmRes = await deletePrivateMessage(alpha, true, pmRes.message.id);
|
let deletedPmRes = await deletePrivateMessage(alpha, true, pmRes.message.id);
|
||||||
expect(deletedPmRes.message.deleted).toBe(true);
|
expect(deletedPmRes.message.deleted).toBe(true);
|
||||||
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.messages.length).toBe(betaPms1.messages.length - 1);
|
||||||
await delay();
|
|
||||||
|
|
||||||
// Undelete
|
// Undelete
|
||||||
let undeletedPmRes = await deletePrivateMessage(
|
let undeletedPmRes = await deletePrivateMessage(
|
||||||
|
@ -75,7 +67,6 @@ test('Delete a private message', async () => {
|
||||||
pmRes.message.id
|
pmRes.message.id
|
||||||
);
|
);
|
||||||
expect(undeletedPmRes.message.deleted).toBe(false);
|
expect(undeletedPmRes.message.deleted).toBe(false);
|
||||||
await longDelay();
|
|
||||||
|
|
||||||
let betaPms3 = await listPrivateMessages(beta);
|
let betaPms3 = await listPrivateMessages(beta);
|
||||||
expect(betaPms3.messages.length).toBe(betaPms1.messages.length);
|
expect(betaPms3.messages.length).toBe(betaPms1.messages.length);
|
||||||
|
|
|
@ -602,8 +602,6 @@ export async function unfollowRemotes(
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function followBeta(api: API): Promise<CommunityResponse> {
|
export async function followBeta(api: API): Promise<CommunityResponse> {
|
||||||
await unfollowRemotes(api);
|
|
||||||
|
|
||||||
// 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.filter(c => c.local == false);
|
||||||
|
@ -615,7 +613,7 @@ export async function followBeta(api: API): Promise<CommunityResponse> {
|
||||||
|
|
||||||
export function delay(millis: number = 500) {
|
export function delay(millis: number = 500) {
|
||||||
return new Promise((resolve, _reject) => {
|
return new Promise((resolve, _reject) => {
|
||||||
setTimeout(_ => resolve(), 10);
|
setTimeout(_ => resolve(), millis);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,6 @@ import {
|
||||||
beta,
|
beta,
|
||||||
registerUser,
|
registerUser,
|
||||||
searchForUser,
|
searchForUser,
|
||||||
saveUserSettingsBio,
|
|
||||||
saveUserSettings,
|
saveUserSettings,
|
||||||
getSite,
|
getSite,
|
||||||
} from './shared';
|
} from './shared';
|
||||||
|
@ -38,23 +37,10 @@ test('Create user', async () => {
|
||||||
apShortname = `@${site.my_user.name}@lemmy-alpha:8541`;
|
apShortname = `@${site.my_user.name}@lemmy-alpha:8541`;
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Save user settings, check changed bio from beta', async () => {
|
test('Set some user settings, check that they are federated', async () => {
|
||||||
let bio = 'a changed bio';
|
|
||||||
let userRes = await saveUserSettingsBio(alpha, auth);
|
|
||||||
expect(userRes.jwt).toBeDefined();
|
|
||||||
|
|
||||||
let site = await getSite(alpha, auth);
|
|
||||||
expect(site.my_user.bio).toBe(bio);
|
|
||||||
let searchAlpha = await searchForUser(alpha, site.my_user.actor_id);
|
|
||||||
|
|
||||||
// Make sure beta sees this bio is changed
|
|
||||||
let searchBeta = await searchForUser(beta, apShortname);
|
|
||||||
assertUserFederation(searchAlpha.users[0], searchBeta.users[0]);
|
|
||||||
});
|
|
||||||
|
|
||||||
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 bio = 'a changed bio';
|
||||||
let form: UserSettingsForm = {
|
let form: UserSettingsForm = {
|
||||||
show_nsfw: false,
|
show_nsfw: false,
|
||||||
theme: "",
|
theme: "",
|
||||||
|
@ -66,11 +52,12 @@ test('Set avatar and banner, check that they are federated', async () => {
|
||||||
preferred_username: "user321",
|
preferred_username: "user321",
|
||||||
show_avatars: false,
|
show_avatars: false,
|
||||||
send_notifications_to_email: false,
|
send_notifications_to_email: false,
|
||||||
|
bio,
|
||||||
auth,
|
auth,
|
||||||
}
|
}
|
||||||
let settingsRes = await saveUserSettings(alpha, form);
|
await saveUserSettings(alpha, form);
|
||||||
|
|
||||||
let searchAlpha = await searchForUser(beta, apShortname);
|
let searchAlpha = await searchForUser(alpha, apShortname);
|
||||||
let userOnAlpha = searchAlpha.users[0];
|
let userOnAlpha = searchAlpha.users[0];
|
||||||
let searchBeta = await searchForUser(beta, apShortname);
|
let searchBeta = await searchForUser(beta, apShortname);
|
||||||
let userOnBeta = searchBeta.users[0];
|
let userOnBeta = searchBeta.users[0];
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use crate::{settings::Settings, APIError};
|
use crate::{settings::Settings, APIError};
|
||||||
use actix_web::dev::ConnectionInfo;
|
use actix_web::dev::ConnectionInfo;
|
||||||
use chrono::{DateTime, FixedOffset, Local, NaiveDateTime};
|
use chrono::{DateTime, FixedOffset, NaiveDateTime};
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
use rand::{distributions::Alphanumeric, thread_rng, Rng};
|
use rand::{distributions::Alphanumeric, thread_rng, Rng};
|
||||||
use regex::{Regex, RegexBuilder};
|
use regex::{Regex, RegexBuilder};
|
||||||
|
@ -22,8 +22,7 @@ pub fn naive_from_unix(time: i64) -> NaiveDateTime {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn convert_datetime(datetime: NaiveDateTime) -> DateTime<FixedOffset> {
|
pub fn convert_datetime(datetime: NaiveDateTime) -> DateTime<FixedOffset> {
|
||||||
let now = Local::now();
|
DateTime::<FixedOffset>::from_utc(datetime, FixedOffset::east(0))
|
||||||
DateTime::<FixedOffset>::from_utc(datetime, *now.offset())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn remove_slurs(test: &str) -> String {
|
pub fn remove_slurs(test: &str) -> String {
|
||||||
|
|
Loading…
Reference in a new issue