From: Dessalines Date: Fri, 7 Aug 2020 14:51:53 +0000 (-0400) Subject: Adding tests for admin remove for posts and comments on different X-Git-Url: http://these/git/%22https:/image.com/readmes/%7Bthis.captchaPngSrc%28%29%7D?a=commitdiff_plain;h=4896e7d0967825ba0b22bb9d3a45fccd9870b791;p=lemmy.git Adding tests for admin remove for posts and comments on different instances. --- diff --git a/ui/src/api_tests/comment.spec.ts b/ui/src/api_tests/comment.spec.ts index ab5418e1..02cc683c 100644 --- a/ui/src/api_tests/comment.spec.ts +++ b/ui/src/api_tests/comment.spec.ts @@ -105,7 +105,7 @@ test('Delete a comment', async () => { expect(betaComment2.deleted).toBe(false); }); -test('Remove a comment', async () => { +test('Remove a comment from admin and community on the same instance', async () => { let commentRes = await createComment(alpha, postRes.post.id); // Get the id for beta @@ -128,7 +128,7 @@ test('Remove a comment', async () => { expect(refetchedPost2.comments[0].removed).toBe(false); }); -test('Remove a comment from an admin on a different instance, make sure its not removed on the original', async () => { +test('Remove a comment from admin and community on different instance', async () => { let alphaUser = await registerUser(alpha); let newAlphaApi: API = { url: alpha.url, diff --git a/ui/src/api_tests/post.spec.ts b/ui/src/api_tests/post.spec.ts index f2cb6678..5da72e5a 100644 --- a/ui/src/api_tests/post.spec.ts +++ b/ui/src/api_tests/post.spec.ts @@ -154,17 +154,17 @@ test('Delete a post', async () => { expect(betaPost2.post.deleted).toBe(false); }); -test('Remove a post', async () => { +test('Remove a post from admin and community on different instance', async () => { let search = await searchForBetaCommunity(alpha); let postRes = await createPost(alpha, search.communities[0].id); let removedPost = await removePost(alpha, true, postRes.post); expect(removedPost.post.removed).toBe(true); - // Make sure lemmy beta sees post is removed + // Make sure lemmy beta sees post is NOT removed let createFakeBetaPostToGetId = (await createPost(beta, 2)).post.id - 1; let betaPost = await getPost(beta, createFakeBetaPostToGetId); - expect(betaPost.post.removed).toBe(true); + expect(betaPost.post.removed).toBe(false); // Undelete let undeletedPost = await removePost(alpha, false, postRes.post); @@ -175,6 +175,31 @@ test('Remove a post', async () => { expect(betaPost2.post.removed).toBe(false); }); +test('Remove a post from admin and community on same instance', async () => { + let search = await searchForBetaCommunity(alpha); + let postRes = await createPost(alpha, search.communities[0].id); + + // Get the id for beta + let createFakeBetaPostToGetId = (await createPost(beta, 2)).post.id - 1; + let betaPost = await getPost(beta, createFakeBetaPostToGetId); + + // The beta admin removes it (the community lives on beta) + let removePostRes = await removePost(beta, true, betaPost.post); + expect(removePostRes.post.removed).toBe(true); + + // Make sure lemmy alpha sees post is removed + let alphaPost = await getPost(alpha, postRes.post.id); + expect(alphaPost.post.removed).toBe(true); + + // Undelete + let undeletedPost = await removePost(beta, false, betaPost.post); + expect(undeletedPost.post.removed).toBe(false); + + // Make sure lemmy alpha sees post is undeleted + let alphaPost2 = await getPost(alpha, postRes.post.id); + expect(alphaPost2.post.removed).toBe(false); +}); + test('Search for a post', async () => { let search = await searchForBetaCommunity(alpha); let postRes = await createPost(alpha, search.communities[0].id);