diff --git a/api_tests/src/post.spec.ts b/api_tests/src/post.spec.ts index bd8b0051f6..154ffe186d 100644 --- a/api_tests/src/post.spec.ts +++ b/api_tests/src/post.spec.ts @@ -55,7 +55,20 @@ afterAll(() => { unfollows(); }); -function assertPostFederation(postOne?: PostView, postTwo?: PostView) { +async function assertPostFederation(postOne: PostView, postTwo: PostView) { + // Link metadata is generated in background task and may not be ready yet at this time, + // so wait for it explicitly. + postOne = await waitForPost( + beta, + postOne.post, + res => res?.post.embed_title != null, + ); + postTwo = await waitForPost( + beta, + postTwo.post, + res => res?.post.embed_title != null, + ); + expect(postOne?.post.ap_id).toBe(postTwo?.post.ap_id); expect(postOne?.post.name).toBe(postTwo?.post.name); expect(postOne?.post.body).toBe(postTwo?.post.body); @@ -372,7 +385,7 @@ test("Remove a post from admin and community on different instance", async () => // Make sure lemmy beta sees post is undeleted let betaPost2 = (await resolvePost(beta, postRes.post_view.post)).post; expect(betaPost2?.post.removed).toBe(false); - assertPostFederation(betaPost2, undeletedPost.post_view); + assertPostFederation(betaPost2!, undeletedPost.post_view); }); test("Remove a post from admin and community on same instance", async () => {