From ac209d58b48ecb60c80f6423e811f8d98aa548e6 Mon Sep 17 00:00:00 2001 From: Dessalines Date: Thu, 14 Dec 2023 10:26:42 -0500 Subject: [PATCH] Adding a retry on a few fetches. (#4267) --- api_tests/src/comment.spec.ts | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/api_tests/src/comment.spec.ts b/api_tests/src/comment.spec.ts index 1ce40a5cc..4655a81ff 100644 --- a/api_tests/src/comment.spec.ts +++ b/api_tests/src/comment.spec.ts @@ -344,17 +344,26 @@ test("Federated comment like", async () => { test("Reply to a comment from another instance, get notification", async () => { await alpha.markAllAsRead(); - let betaCommunity = (await resolveBetaCommunity(alpha)).community; + let betaCommunity = ( + await waitUntil( + () => resolveBetaCommunity(alpha), + c => !!c.community?.community.instance_id, + ) + ).community; if (!betaCommunity) { throw "Missing beta community"; } + const postOnAlphaRes = await createPost(alpha, betaCommunity.community.id); // Create a root-level trunk-branch comment on alpha let commentRes = await createComment(alpha, postOnAlphaRes.post_view.post.id); // find that comment id on beta let betaComment = ( - await resolveComment(beta, commentRes.comment_view.comment) + await waitUntil( + () => resolveComment(beta, commentRes.comment_view.comment), + c => c.comment?.counts.score === 1, + ) ).comment; if (!betaComment) { @@ -405,7 +414,10 @@ test("Reply to a comment from another instance, get notification", async () => { expect(alphaUnreadCountRes.replies).toBeGreaterThanOrEqual(1); // check inbox of replies on alpha, fetching read/unread both - let alphaRepliesRes = await getReplies(alpha); + let alphaRepliesRes = await waitUntil( + () => getReplies(alpha), + r => r.replies.length > 0, + ); const alphaReply = alphaRepliesRes.replies.find( r => r.comment.id === alphaComment.comment.id, );