From 83cdac21e6ed4dcc838af96810171f541b57d069 Mon Sep 17 00:00:00 2001 From: RocketDerp <113625597+RocketDerp@users.noreply.github.com> Date: Tue, 18 Jul 2023 05:53:33 -0700 Subject: [PATCH] more robust 'delete a comment' test, confirm replication --- api_tests/src/comment.spec.ts | 39 ++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/api_tests/src/comment.spec.ts b/api_tests/src/comment.spec.ts index e4a4b8e4b..4dcb405af 100644 --- a/api_tests/src/comment.spec.ts +++ b/api_tests/src/comment.spec.ts @@ -112,8 +112,28 @@ test("Update a comment", async () => { }); test("Delete a comment", async () => { + // creating a comment on alpha (remote from home of community) let commentRes = await createComment(alpha, postRes.post_view.post.id); + // Find the comment on beta (home of community) + let betaComment = ( + await resolveComment(beta, commentRes.comment_view.comment) + ).comment; + + if (!betaComment) { + throw "Missing beta comment before delete"; + } + + // Find the comment on gamma + // This is testing replication from remote-home-remote (alpha-beta-gamma) + let gammaComment = ( + await resolveComment(gamma, commentRes.comment_view.comment) + ).comment; + + if (!gammaComment) { + throw "Missing gamma comment (remote-home-remote replication) before delete"; + } + let deleteCommentRes = await deleteComment( alpha, true, @@ -121,13 +141,30 @@ test("Delete a comment", async () => { ); expect(deleteCommentRes.comment_view.comment.deleted).toBe(true); - // Make sure that comment is undefined on beta + // Make sure that comment is undefined on beta after delete let betaCommentRes = (await resolveComment( beta, commentRes.comment_view.comment, )) as any; + if (betaCommentRes) { + console.log(betaCommentRes.comment); + } expect(betaCommentRes.error).toBe("couldnt_find_object"); + // Make sure that comment is undefined on gamma after delete + // This is testing replication from remote-home-remote (alpha-beta-gamma) + let gammaCommentRes = (await resolveComment( + gamma, + commentRes.comment_view.comment, + )) as any; + if (gammaCommentRes) { + if (gammaCommentRes.comment) { + console.log("gamma has deleted comment", gammaCommentRes.comment.comment); + } + } + expect(gammaCommentRes.error).toBe("couldnt_find_object"); + + // Test undeleting the comment let undeleteCommentRes = await deleteComment( alpha, false,