Skip to content

Commit

Permalink
fix api tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Nutomic committed Mar 25, 2024
1 parent 456054f commit 9f1635b
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions api_tests/src/post.spec.ts
Expand Up @@ -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);
Expand Down Expand Up @@ -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 () => {
Expand Down

0 comments on commit 9f1635b

Please sign in to comment.