more robust 'delete a comment' test, confirm replication

This commit is contained in:
RocketDerp 2023-07-18 05:53:33 -07:00 committed by GitHub
parent fb7df85bd9
commit 83cdac21e6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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,