mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-11-25 07:36:01 +00:00
minor test improvement
This commit is contained in:
parent
007f4f5319
commit
d58e2e9db7
|
@ -36,14 +36,16 @@ import {
|
||||||
delay,
|
delay,
|
||||||
} from "./shared";
|
} from "./shared";
|
||||||
import { CommentView } from "lemmy-js-client/dist/types/CommentView";
|
import { CommentView } from "lemmy-js-client/dist/types/CommentView";
|
||||||
|
import { CommunityView } from "lemmy-js-client";
|
||||||
|
|
||||||
|
let betaCommunity: CommunityView | undefined;
|
||||||
let postOnAlphaRes: PostResponse;
|
let postOnAlphaRes: PostResponse;
|
||||||
|
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
await setupLogins();
|
await setupLogins();
|
||||||
await unfollows();
|
await unfollows();
|
||||||
await Promise.all([followBeta(alpha), followBeta(gamma)]);
|
await Promise.all([followBeta(alpha), followBeta(gamma)]);
|
||||||
let betaCommunity = (await resolveBetaCommunity(alpha)).community;
|
betaCommunity = (await resolveBetaCommunity(alpha)).community;
|
||||||
if (betaCommunity) {
|
if (betaCommunity) {
|
||||||
postOnAlphaRes = await createPost(alpha, betaCommunity.community.id);
|
postOnAlphaRes = await createPost(alpha, betaCommunity.community.id);
|
||||||
}
|
}
|
||||||
|
@ -397,7 +399,7 @@ test("Reply to a comment from another instance, get notification", async () => {
|
||||||
() => getUnreadCount(alpha),
|
() => getUnreadCount(alpha),
|
||||||
e => e.replies >= 1,
|
e => e.replies >= 1,
|
||||||
);
|
);
|
||||||
expect(alphaUnreadCountRes.replies).toBe(1);
|
expect(alphaUnreadCountRes.replies).toBeGreaterThanOrEqual(1);
|
||||||
|
|
||||||
// check inbox of replies on alpha, fetching read/unread both
|
// check inbox of replies on alpha, fetching read/unread both
|
||||||
let alphaRepliesRes = await getReplies(alpha);
|
let alphaRepliesRes = await getReplies(alpha);
|
||||||
|
@ -414,6 +416,8 @@ test("Reply to a comment from another instance, get notification", async () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
test("Mention beta from alpha", async () => {
|
test("Mention beta from alpha", async () => {
|
||||||
|
if (!betaCommunity) throw Error("no community");
|
||||||
|
const postOnAlphaRes = await createPost(alpha, betaCommunity.community.id);
|
||||||
// Create a new branch, trunk-level comment branch, from alpha instance
|
// Create a new branch, trunk-level comment branch, from alpha instance
|
||||||
let commentRes = await createComment(alpha, postOnAlphaRes.post_view.post.id);
|
let commentRes = await createComment(alpha, postOnAlphaRes.post_view.post.id);
|
||||||
// Create a reply comment to previous comment, this has a mention in body
|
// Create a reply comment to previous comment, this has a mention in body
|
||||||
|
@ -440,9 +444,9 @@ test("Mention beta from alpha", async () => {
|
||||||
// Make sure that both new comments are seen on beta and have parent/child relationship
|
// Make sure that both new comments are seen on beta and have parent/child relationship
|
||||||
let betaPostComments = await waitUntil(
|
let betaPostComments = await waitUntil(
|
||||||
() => getComments(beta, betaPost!.post.id),
|
() => getComments(beta, betaPost!.post.id),
|
||||||
c => c.comments[1].counts.score === 1,
|
c => c.comments[1]?.counts.score === 1,
|
||||||
);
|
);
|
||||||
expect(betaPostComments.comments.length).toBeGreaterThanOrEqual(2);
|
expect(betaPostComments.comments.length).toEqual(2);
|
||||||
// the trunk-branch root comment will be older than the mention reply comment, so index 1
|
// the trunk-branch root comment will be older than the mention reply comment, so index 1
|
||||||
let betaRootComment = betaPostComments.comments[1];
|
let betaRootComment = betaPostComments.comments[1];
|
||||||
// the trunk-branch root comment should not have a parent
|
// the trunk-branch root comment should not have a parent
|
||||||
|
@ -700,16 +704,17 @@ test("Report a comment", async () => {
|
||||||
throw "Missing alpha comment";
|
throw "Missing alpha comment";
|
||||||
}
|
}
|
||||||
|
|
||||||
let alphaReport = (
|
const reason = randomString(10);
|
||||||
await reportComment(alpha, alphaComment.id, randomString(10))
|
let alphaReport = (await reportComment(alpha, alphaComment.id, reason))
|
||||||
).comment_report_view.comment_report;
|
.comment_report_view.comment_report;
|
||||||
|
|
||||||
let betaReport = (
|
let betaReport = (await waitUntil(
|
||||||
await waitUntil(
|
() =>
|
||||||
() => listCommentReports(beta),
|
listCommentReports(beta).then(r =>
|
||||||
e => !!e.comment_reports[0],
|
r.comment_reports.find(rep => rep.comment_report.reason === reason),
|
||||||
)
|
),
|
||||||
).comment_reports[0].comment_report;
|
e => !!e,
|
||||||
|
))!.comment_report;
|
||||||
expect(betaReport).toBeDefined();
|
expect(betaReport).toBeDefined();
|
||||||
expect(betaReport.resolved).toBe(false);
|
expect(betaReport.resolved).toBe(false);
|
||||||
expect(betaReport.original_comment_text).toBe(
|
expect(betaReport.original_comment_text).toBe(
|
||||||
|
|
Loading…
Reference in a new issue