Removing createFakes.

This commit is contained in:
Dessalines 2020-08-30 10:52:37 -05:00
parent 8f85ff995e
commit f814fa5577
2 changed files with 30 additions and 28 deletions

View file

@ -75,6 +75,7 @@ test('Update a comment', async () => {
); );
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 searchBeta = await searchComment(beta, commentRes.comment); let searchBeta = await searchComment(beta, commentRes.comment);
@ -125,7 +126,7 @@ 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 delay(5000); await delay();
// 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);
@ -353,9 +354,11 @@ test('Fetch in_reply_tos: A is unsubbed from B, B makes a post, and some embedde
await delay(); await delay();
// Get the post from alpha // Get the post from alpha
let createFakeAlphaPostToGetId = await createPost(alpha, 2); let search = await searchPost(alpha, postRes.post);
let alphaPostB = search.posts[0];
await delay(); await delay();
let alphaPost = await getPost(alpha, createFakeAlphaPostToGetId.post.id - 1);
let alphaPost = await getPost(alpha, alphaPostB.id);
expect(alphaPost.post.name).toBeDefined(); expect(alphaPost.post.name).toBeDefined();
expect(alphaPost.comments[1].content).toBe(parentCommentContent); expect(alphaPost.comments[1].content).toBe(parentCommentContent);
expect(alphaPost.comments[0].content).toBe(updatedCommentContent); expect(alphaPost.comments[0].content).toBe(updatedCommentContent);

View file

@ -46,7 +46,7 @@ test('Create a post', async () => {
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(5000); 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);
@ -208,25 +208,24 @@ test('Delete a post', async () => {
await delay(); await delay();
// Make sure lemmy beta sees post is deleted // Make sure lemmy beta sees post is deleted
let newPost = await createPost(beta, 2); let searchBeta = await searchPost(beta, postRes.post);
await delay(5000); let betaPost = searchBeta.posts[0];
let createFakeBetaPostToGetId = newPost.post.id - 1; // This will be undefined because of the tombstone
let betaPost = await getPost(beta, createFakeBetaPostToGetId); expect(betaPost).toBeUndefined();
// TODO this doesn't work for some reason await delay();
// expect(betaPost.post.deleted).toBe(true);
// await delay();
// Undelete // Undelete
let undeletedPost = await deletePost(alpha, false, postRes.post); let undeletedPost = await deletePost(alpha, false, postRes.post);
expect(undeletedPost.post.deleted).toBe(false); expect(undeletedPost.post.deleted).toBe(false);
await delay(5000); await delay();
// Make sure lemmy beta sees post is undeleted // Make sure lemmy beta sees post is undeleted
let betaPost2 = await getPost(beta, createFakeBetaPostToGetId); let searchBeta2 = await searchPost(beta, postRes.post);
expect(betaPost2.post.deleted).toBe(false); let betaPost2 = searchBeta2.posts[0];
expect(betaPost2.deleted).toBe(false);
// Make sure lemmy beta cannot delete the post // Make sure lemmy beta cannot delete the post
let deletedPostBeta = await deletePost(beta, true, betaPost2.post); let deletedPostBeta = await deletePost(beta, true, betaPost2);
expect(deletedPostBeta).toStrictEqual({ error: 'no_post_edit_allowed' }); expect(deletedPostBeta).toStrictEqual({ error: 'no_post_edit_allowed' });
}); });
@ -237,14 +236,12 @@ test('Remove a post from admin and community on different instance', async () =>
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(5000); await delay();
// Make sure lemmy beta sees post is NOT removed // Make sure lemmy beta sees post is NOT removed
// TODO add these back in at some point let searchBeta = await searchPost(beta, postRes.post);
let createFakeBetaPostToGetId = (await createPost(beta, 2)).post.id - 1; let betaPost = searchBeta.posts[0];
await delay(); expect(betaPost.removed).toBe(false);
let betaPost = await getPost(beta, createFakeBetaPostToGetId);
// expect(betaPost.post.removed).toBe(false);
await delay(); await delay();
// Undelete // Undelete
@ -253,8 +250,9 @@ test('Remove a post from admin and community on different instance', async () =>
await delay(); await delay();
// Make sure lemmy beta sees post is undeleted // Make sure lemmy beta sees post is undeleted
let betaPost2 = await getPost(beta, createFakeBetaPostToGetId); let searchBeta2 = await searchPost(beta, postRes.post);
// expect(betaPost2.post.removed).toBe(false); let betaPost2 = searchBeta2.posts[0];
expect(betaPost2.removed).toBe(false);
}); });
test('Remove a post from admin and community on same instance', async () => { test('Remove a post from admin and community on same instance', async () => {
@ -263,12 +261,12 @@ test('Remove a post from admin and community on same instance', async () => {
await delay(); await delay();
// Get the id for beta // Get the id for beta
let createFakeBetaPostToGetId = (await createPost(beta, 2)).post.id - 1; let searchBeta = await searchPost(beta, postRes.post);
let betaPost = await getPost(beta, createFakeBetaPostToGetId); let betaPost = searchBeta.posts[0];
await delay(5000); await delay();
// 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.post); let removePostRes = await removePost(beta, true, betaPost);
expect(removePostRes.post.removed).toBe(true); expect(removePostRes.post.removed).toBe(true);
await delay(); await delay();
@ -278,7 +276,7 @@ test('Remove a post from admin and community on same instance', async () => {
await delay(); await delay();
// Undelete // Undelete
let undeletedPost = await removePost(beta, false, betaPost.post); let undeletedPost = await removePost(beta, false, betaPost);
expect(undeletedPost.post.removed).toBe(false); expect(undeletedPost.post.removed).toBe(false);
await delay(); await delay();
@ -289,6 +287,7 @@ test('Remove a post from admin and community on same instance', async () => {
test('Search for a post', async () => { test('Search for a post', async () => {
let search = await searchForBetaCommunity(alpha); let search = await searchForBetaCommunity(alpha);
await delay();
let postRes = await createPost(alpha, search.communities[0].id); let postRes = await createPost(alpha, search.communities[0].id);
await delay(); await delay();
let searchBeta = await searchPost(beta, postRes.post); let searchBeta = await searchPost(beta, postRes.post);