Adding tests for admin remove for posts and comments on different

instances.
This commit is contained in:
Dessalines 2020-08-07 10:51:53 -04:00
parent cabbbf0afd
commit 4896e7d096
2 changed files with 30 additions and 5 deletions

View file

@ -105,7 +105,7 @@ test('Delete a comment', async () => {
expect(betaComment2.deleted).toBe(false); 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); let commentRes = await createComment(alpha, postRes.post.id);
// Get the id for beta // Get the id for beta
@ -128,7 +128,7 @@ test('Remove a comment', async () => {
expect(refetchedPost2.comments[0].removed).toBe(false); 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 alphaUser = await registerUser(alpha);
let newAlphaApi: API = { let newAlphaApi: API = {
url: alpha.url, url: alpha.url,

View file

@ -154,17 +154,17 @@ test('Delete a post', async () => {
expect(betaPost2.post.deleted).toBe(false); 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 search = await searchForBetaCommunity(alpha);
let postRes = await createPost(alpha, search.communities[0].id); let postRes = await createPost(alpha, search.communities[0].id);
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);
// 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 createFakeBetaPostToGetId = (await createPost(beta, 2)).post.id - 1;
let betaPost = await getPost(beta, createFakeBetaPostToGetId); let betaPost = await getPost(beta, createFakeBetaPostToGetId);
expect(betaPost.post.removed).toBe(true); expect(betaPost.post.removed).toBe(false);
// Undelete // Undelete
let undeletedPost = await removePost(alpha, false, postRes.post); let undeletedPost = await removePost(alpha, false, postRes.post);
@ -175,6 +175,31 @@ test('Remove a post', async () => {
expect(betaPost2.post.removed).toBe(false); 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 () => { test('Search for 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].id);