From 954b3f443d18bca428f01c2a24447b312851420d Mon Sep 17 00:00:00 2001 From: phiresky Date: Mon, 18 Sep 2023 17:04:46 +0000 Subject: [PATCH] fix wait --- api_tests/src/comment.spec.ts | 2 +- api_tests/src/post.spec.ts | 14 ++++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/api_tests/src/comment.spec.ts b/api_tests/src/comment.spec.ts index 9011fb8f1..2314205d1 100644 --- a/api_tests/src/comment.spec.ts +++ b/api_tests/src/comment.spec.ts @@ -511,7 +511,7 @@ test("A and G subscribe to B (center) A posts, G mentions B, it gets announced t // Make sure alpha sees it let alphaPostComments2 = await waitUntil( () => getComments(alpha, alphaPost.post_view.post.id), - e => !!e.comments[0], + e => e.comments[0]?.counts.score === 1, ); expect(alphaPostComments2.comments[0].comment.content).toBe(commentContent); expect(alphaPostComments2.comments[0].community.local).toBe(true); diff --git a/api_tests/src/post.spec.ts b/api_tests/src/post.spec.ts index b2d07c291..89dfaa35f 100644 --- a/api_tests/src/post.spec.ts +++ b/api_tests/src/post.spec.ts @@ -365,16 +365,22 @@ test("Remove a post from admin and community on same instance", async () => { expect(removePostRes.post_view.post.removed).toBe(true); // Make sure lemmy alpha sees post is removed - // let alphaPost = await getPost(alpha, postRes.post_view.post.id); - // expect(alphaPost.post_view.post.removed).toBe(true); // TODO this shouldn't be commented - // assertPostFederation(alphaPost.post_view, removePostRes.post_view); + let alphaPost = await waitUntil( + () => getPost(alpha, postRes.post_view.post.id), + p => p.post_view.post.removed, + ); + expect(alphaPost.post_view.post.removed).toBe(true); + assertPostFederation(alphaPost.post_view, removePostRes.post_view); // Undelete let undeletedPost = await removePost(beta, false, betaPost.post); expect(undeletedPost.post_view.post.removed).toBe(false); // Make sure lemmy alpha sees post is undeleted - let alphaPost2 = await getPost(alpha, postRes.post_view.post.id); + let alphaPost2 = await waitUntil( + () => getPost(alpha, postRes.post_view.post.id), + p => !p.post_view.post.removed, + ); expect(alphaPost2.post_view.post.removed).toBe(false); assertPostFederation(alphaPost2.post_view, undeletedPost.post_view); await unfollowRemotes(alpha);