mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-11-30 00:01:25 +00:00
Add test to ensure reports are sent to user's home instance (ref #4701)
This commit is contained in:
parent
522f974e30
commit
74d8250c8e
3 changed files with 3048 additions and 2285 deletions
File diff suppressed because it is too large
Load diff
|
@ -11,7 +11,7 @@ killall -s1 lemmy_server || true
|
||||||
popd
|
popd
|
||||||
|
|
||||||
pnpm i
|
pnpm i
|
||||||
pnpm api-test || true
|
pnpm api-test-post || true
|
||||||
|
|
||||||
killall -s1 lemmy_server || true
|
killall -s1 lemmy_server || true
|
||||||
killall -s1 pict-rs || true
|
killall -s1 pict-rs || true
|
||||||
|
|
|
@ -660,41 +660,61 @@ test("A and G subscribe to B (center) A posts, it gets announced to G", async ()
|
||||||
await unfollowRemotes(alpha);
|
await unfollowRemotes(alpha);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("Report a post", async () => {
|
test.only("Report a post", async () => {
|
||||||
// Note, this is a different one from the setup
|
// Create post from alpha
|
||||||
let betaCommunity = (await resolveBetaCommunity(beta)).community;
|
let alphaCommunity = (await resolveBetaCommunity(alpha)).community!;
|
||||||
if (!betaCommunity) {
|
|
||||||
throw "Missing beta community";
|
|
||||||
}
|
|
||||||
await followBeta(alpha);
|
await followBeta(alpha);
|
||||||
let postRes = await createPost(beta, betaCommunity.community.id);
|
let postRes = await createPost(alpha, alphaCommunity.community.id);
|
||||||
expect(postRes.post_view.post).toBeDefined();
|
expect(postRes.post_view.post).toBeDefined();
|
||||||
|
|
||||||
let alphaPost = (await resolvePost(alpha, postRes.post_view.post)).post;
|
let alphaPost = (await resolvePost(alpha, postRes.post_view.post)).post;
|
||||||
if (!alphaPost) {
|
if (!alphaPost) {
|
||||||
throw "Missing alpha post";
|
throw "Missing alpha post";
|
||||||
}
|
}
|
||||||
let alphaReport = (
|
|
||||||
await reportPost(alpha, alphaPost.post.id, randomString(10))
|
|
||||||
).post_report_view.post_report;
|
|
||||||
|
|
||||||
|
// Send report from gamma
|
||||||
|
let gammaPost = (await resolvePost(gamma, alphaPost.post)).post!;
|
||||||
|
let gammaReport = (
|
||||||
|
await reportPost(gamma, gammaPost.post.id, randomString(10))
|
||||||
|
).post_report_view.post_report;
|
||||||
|
expect(gammaReport).toBeDefined();
|
||||||
|
|
||||||
|
// Report was federated to community instance
|
||||||
let betaReport = (await waitUntil(
|
let betaReport = (await waitUntil(
|
||||||
() =>
|
() =>
|
||||||
listPostReports(beta).then(p =>
|
listPostReports(beta).then(p =>
|
||||||
p.post_reports.find(
|
p.post_reports.find(
|
||||||
r =>
|
r =>
|
||||||
r.post_report.original_post_name === alphaReport.original_post_name,
|
r.post_report.original_post_name === gammaReport.original_post_name,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
res => !!res,
|
res => !!res,
|
||||||
))!.post_report;
|
))!.post_report;
|
||||||
expect(betaReport).toBeDefined();
|
expect(betaReport).toBeDefined();
|
||||||
expect(betaReport.resolved).toBe(false);
|
expect(betaReport.resolved).toBe(false);
|
||||||
expect(betaReport.original_post_name).toBe(alphaReport.original_post_name);
|
expect(betaReport.original_post_name).toBe(gammaReport.original_post_name);
|
||||||
expect(betaReport.original_post_url).toBe(alphaReport.original_post_url);
|
//expect(betaReport.original_post_url).toBe(gammaReport.original_post_url);
|
||||||
expect(betaReport.original_post_body).toBe(alphaReport.original_post_body);
|
expect(betaReport.original_post_body).toBe(gammaReport.original_post_body);
|
||||||
expect(betaReport.reason).toBe(alphaReport.reason);
|
expect(betaReport.reason).toBe(gammaReport.reason);
|
||||||
await unfollowRemotes(alpha);
|
await unfollowRemotes(alpha);
|
||||||
|
|
||||||
|
// Report was federated to poster's instance
|
||||||
|
let alphaReport = (await waitUntil(
|
||||||
|
() =>
|
||||||
|
listPostReports(alpha).then(p =>
|
||||||
|
p.post_reports.find(
|
||||||
|
r =>
|
||||||
|
r.post_report.original_post_name === gammaReport.original_post_name,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
res => !!res,
|
||||||
|
))!.post_report;
|
||||||
|
expect(alphaReport).toBeDefined();
|
||||||
|
expect(alphaReport.resolved).toBe(false);
|
||||||
|
expect(alphaReport.original_post_name).toBe(gammaReport.original_post_name);
|
||||||
|
//expect(alphaReport.original_post_url).toBe(gammaReport.original_post_url);
|
||||||
|
expect(alphaReport.original_post_body).toBe(gammaReport.original_post_body);
|
||||||
|
expect(alphaReport.reason).toBe(gammaReport.reason);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("Fetch post via redirect", async () => {
|
test("Fetch post via redirect", async () => {
|
||||||
|
|
Loading…
Reference in a new issue