mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-10-01 01:36:12 -04:00
* Add test to ensure reports are sent to user's home instance (ref #4701) * enable all tests * set package-manager-strict=false
This commit is contained in:
parent
49bb17b583
commit
7fb03c502e
1
api_tests/.npmrc
Normal file
1
api_tests/.npmrc
Normal file
@ -0,0 +1 @@
|
|||||||
|
package-manager-strict=false
|
@ -661,40 +661,60 @@ test("A and G subscribe to B (center) A posts, it gets announced to G", async ()
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("Report a post", async () => {
|
test("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 New Issue
Block a user