+ let postRes3 = await createPost(alpha, betaCommunity.community.id);
+ expect(postRes3.post_view.post).toBeDefined();
+ expect(postRes3.post_view.community.local).toBe(false);
+ expect(postRes3.post_view.creator.local).toBe(true);
+ expect(postRes3.post_view.counts.score).toBe(1);
+
+ // Make sure that post makes it to beta community
+ let searchBeta2 = await searchPostLocal(beta, postRes3.post_view.post);
+ expect(searchBeta2.posts[0]).toBeDefined();
+});
+
+test("A and G subscribe to B (center) A posts, it gets announced to G", async () => {
+ if (!betaCommunity) {
+ throw "Missing beta community";
+ }
+ let postRes = await createPost(alpha, betaCommunity.community.id);
+ expect(postRes.post_view.post).toBeDefined();
+
+ let betaPost = (await resolvePost(gamma, postRes.post_view.post)).post;
+ expect(betaPost?.post.name).toBeDefined();
+});
+
+test("Report a post", async () => {
+ // Note, this is a different one from the setup
+ let betaCommunity = (await resolveBetaCommunity(beta)).community;
+ if (!betaCommunity) {
+ throw "Missing beta community";
+ }
+ let postRes = await createPost(beta, betaCommunity.community.id);
+ expect(postRes.post_view.post).toBeDefined();
+
+ let alphaPost = (await resolvePost(alpha, postRes.post_view.post)).post;
+ if (!alphaPost) {
+ throw "Missing alpha post";
+ }
+ let alphaReport = (
+ await reportPost(alpha, alphaPost.post.id, randomString(10))
+ ).post_report_view.post_report;
+
+ let betaReport = (await listPostReports(beta)).post_reports[0].post_report;
+ expect(betaReport).toBeDefined();
+ expect(betaReport.resolved).toBe(false);
+ expect(betaReport.original_post_name).toBe(alphaReport.original_post_name);
+ expect(betaReport.original_post_url).toBe(alphaReport.original_post_url);
+ expect(betaReport.original_post_body).toBe(alphaReport.original_post_body);
+ expect(betaReport.reason).toBe(alphaReport.reason);
+});
+
+test("Sanitize HTML", async () => {
+ let betaCommunity = (await resolveBetaCommunity(beta)).community;
+ if (!betaCommunity) {
+ throw "Missing beta community";
+ }
+
+ let name = randomString(5);
+ let body = "<script>alert('xss');</script> hello";
+ let form: CreatePost = {
+ name,
+ body,
+ auth: beta.auth,
+ community_id: betaCommunity.community.id,
+ };
+ let post = await beta.client.createPost(form);
+ expect(post.post_view.post.body).toBe(" hello");