mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-12-22 19:01:32 +00:00
Fixing api tests.
This commit is contained in:
parent
83988cd9bf
commit
82a14fc5fa
5 changed files with 73 additions and 51 deletions
|
@ -28,7 +28,7 @@
|
|||
"eslint": "^9.14.0",
|
||||
"eslint-plugin-prettier": "^5.1.3",
|
||||
"jest": "^29.5.0",
|
||||
"lemmy-js-client": "0.20.0-instance-blocks.5",
|
||||
"lemmy-js-client": "0.20.0-reports-combined.2",
|
||||
"prettier": "^3.2.5",
|
||||
"ts-jest": "^29.1.0",
|
||||
"typescript": "^5.5.4",
|
||||
|
|
|
@ -30,8 +30,8 @@ importers:
|
|||
specifier: ^29.5.0
|
||||
version: 29.7.0(@types/node@22.9.0)
|
||||
lemmy-js-client:
|
||||
specifier: 0.20.0-instance-blocks.5
|
||||
version: 0.20.0-instance-blocks.5
|
||||
specifier: 0.20.0-reports-combined.2
|
||||
version: 0.20.0-reports-combined.2
|
||||
prettier:
|
||||
specifier: ^3.2.5
|
||||
version: 3.3.3
|
||||
|
@ -1167,8 +1167,8 @@ packages:
|
|||
resolution: {integrity: sha512-eTIzlVOSUR+JxdDFepEYcBMtZ9Qqdef+rnzWdRZuMbOywu5tO2w2N7rqjoANZ5k9vywhL6Br1VRjUIgTQx4E8w==}
|
||||
engines: {node: '>=6'}
|
||||
|
||||
lemmy-js-client@0.20.0-instance-blocks.5:
|
||||
resolution: {integrity: sha512-wDuRFzg32lbbJr4cNmd+cbzjgw+okw2/d5AujYjAm4gv0OEFfsYhP3QQ2WscwUR5HJTdzsR7IIyiBnvmaEUzUw==}
|
||||
lemmy-js-client@0.20.0-reports-combined.2:
|
||||
resolution: {integrity: sha512-ZquK08ggeHhFVHMxz42vZvZ3/UgPHYcvMT3MaNevqCJFMFgiXg0+1HWUctVAaZrj8ooiRTiVqupelEhq6LKKTQ==}
|
||||
|
||||
leven@3.1.0:
|
||||
resolution: {integrity: sha512-qsda+H8jTaUaN/x5vzW2rzc+8Rw4TAQ/4KjB46IwK5VH+IlVeeeje/EoZRpiXvIqjFgK84QffqPztGI3VBLG1A==}
|
||||
|
@ -3077,7 +3077,7 @@ snapshots:
|
|||
|
||||
kleur@3.0.3: {}
|
||||
|
||||
lemmy-js-client@0.20.0-instance-blocks.5: {}
|
||||
lemmy-js-client@0.20.0-reports-combined.2: {}
|
||||
|
||||
leven@3.1.0: {}
|
||||
|
||||
|
|
|
@ -22,7 +22,6 @@ import {
|
|||
createCommunity,
|
||||
registerUser,
|
||||
reportComment,
|
||||
listCommentReports,
|
||||
randomString,
|
||||
unfollows,
|
||||
getComments,
|
||||
|
@ -38,8 +37,14 @@ import {
|
|||
blockCommunity,
|
||||
delay,
|
||||
saveUserSettings,
|
||||
listReports,
|
||||
} from "./shared";
|
||||
import { CommentView, CommunityView, SaveUserSettings } from "lemmy-js-client";
|
||||
import {
|
||||
CommentReportView,
|
||||
CommentView,
|
||||
CommunityView,
|
||||
SaveUserSettings,
|
||||
} from "lemmy-js-client";
|
||||
|
||||
let betaCommunity: CommunityView | undefined;
|
||||
let postOnAlphaRes: PostResponse;
|
||||
|
@ -796,13 +801,22 @@ test("Report a comment", async () => {
|
|||
let alphaReport = (await reportComment(alpha, alphaComment.id, reason))
|
||||
.comment_report_view.comment_report;
|
||||
|
||||
let betaReport = (await waitUntil(
|
||||
() =>
|
||||
listCommentReports(beta).then(r =>
|
||||
r.comment_reports.find(rep => rep.comment_report.reason === reason),
|
||||
),
|
||||
e => !!e,
|
||||
))!.comment_report;
|
||||
let betaReport = (
|
||||
(await waitUntil(
|
||||
() =>
|
||||
listReports(beta).then(p =>
|
||||
p.reports.find(r => {
|
||||
switch (r.type_) {
|
||||
case "Comment":
|
||||
return r.comment_report.reason === reason;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}),
|
||||
),
|
||||
e => !!e,
|
||||
)!) as CommentReportView
|
||||
).comment_report;
|
||||
expect(betaReport).toBeDefined();
|
||||
expect(betaReport.resolved).toBe(false);
|
||||
expect(betaReport.original_comment_text).toBe(
|
||||
|
|
|
@ -27,7 +27,6 @@ import {
|
|||
followCommunity,
|
||||
banPersonFromCommunity,
|
||||
reportPost,
|
||||
listPostReports,
|
||||
randomString,
|
||||
registerUser,
|
||||
getSite,
|
||||
|
@ -38,10 +37,11 @@ import {
|
|||
alphaUrl,
|
||||
loginUser,
|
||||
createCommunity,
|
||||
listReports,
|
||||
} from "./shared";
|
||||
import { PostView } from "lemmy-js-client/dist/types/PostView";
|
||||
import { AdminBlockInstanceParams } from "lemmy-js-client/dist/types/AdminBlockInstanceParams";
|
||||
import { EditSite, ResolveObject } from "lemmy-js-client";
|
||||
import { EditSite, PostReportView, ResolveObject } from "lemmy-js-client";
|
||||
|
||||
let betaCommunity: CommunityView | undefined;
|
||||
|
||||
|
@ -690,16 +690,25 @@ test("Report a post", async () => {
|
|||
expect(gammaReport).toBeDefined();
|
||||
|
||||
// Report was federated to community instance
|
||||
let betaReport = (await waitUntil(
|
||||
() =>
|
||||
listPostReports(beta).then(p =>
|
||||
p.post_reports.find(
|
||||
r =>
|
||||
r.post_report.original_post_name === gammaReport.original_post_name,
|
||||
let betaReport = (
|
||||
(await waitUntil(
|
||||
() =>
|
||||
listReports(beta).then(p =>
|
||||
p.reports.find(r => {
|
||||
switch (r.type_) {
|
||||
case "Post":
|
||||
return (
|
||||
r.post_report.original_post_name ===
|
||||
gammaReport.original_post_name
|
||||
);
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}),
|
||||
),
|
||||
),
|
||||
res => !!res,
|
||||
))!.post_report;
|
||||
res => !!res,
|
||||
))! as PostReportView
|
||||
).post_report;
|
||||
expect(betaReport).toBeDefined();
|
||||
expect(betaReport.resolved).toBe(false);
|
||||
expect(betaReport.original_post_name).toBe(gammaReport.original_post_name);
|
||||
|
@ -709,16 +718,25 @@ test("Report a post", async () => {
|
|||
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,
|
||||
let alphaReport = (
|
||||
(await waitUntil(
|
||||
() =>
|
||||
listReports(alpha).then(p =>
|
||||
p.reports.find(r => {
|
||||
switch (r.type_) {
|
||||
case "Post":
|
||||
return (
|
||||
r.post_report.original_post_name ===
|
||||
gammaReport.original_post_name
|
||||
);
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}),
|
||||
),
|
||||
),
|
||||
res => !!res,
|
||||
))!.post_report;
|
||||
res => !!res,
|
||||
))! as PostReportView
|
||||
).post_report;
|
||||
expect(alphaReport).toBeDefined();
|
||||
expect(alphaReport.resolved).toBe(false);
|
||||
expect(alphaReport.original_post_name).toBe(gammaReport.original_post_name);
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
import {
|
||||
AdminBlockInstanceParams,
|
||||
ApproveCommunityPendingFollower,
|
||||
BlockCommunity,
|
||||
BlockCommunityResponse,
|
||||
|
@ -16,6 +15,8 @@ import {
|
|||
LemmyHttp,
|
||||
ListCommunityPendingFollows,
|
||||
ListCommunityPendingFollowsResponse,
|
||||
ListReports,
|
||||
ListReportsResponse,
|
||||
PersonId,
|
||||
PostView,
|
||||
PrivateMessageReportResponse,
|
||||
|
@ -74,12 +75,8 @@ import { PrivateMessagesResponse } from "lemmy-js-client/dist/types/PrivateMessa
|
|||
import { GetPrivateMessages } from "lemmy-js-client/dist/types/GetPrivateMessages";
|
||||
import { PostReportResponse } from "lemmy-js-client/dist/types/PostReportResponse";
|
||||
import { CreatePostReport } from "lemmy-js-client/dist/types/CreatePostReport";
|
||||
import { ListPostReportsResponse } from "lemmy-js-client/dist/types/ListPostReportsResponse";
|
||||
import { ListPostReports } from "lemmy-js-client/dist/types/ListPostReports";
|
||||
import { CommentReportResponse } from "lemmy-js-client/dist/types/CommentReportResponse";
|
||||
import { CreateCommentReport } from "lemmy-js-client/dist/types/CreateCommentReport";
|
||||
import { ListCommentReportsResponse } from "lemmy-js-client/dist/types/ListCommentReportsResponse";
|
||||
import { ListCommentReports } from "lemmy-js-client/dist/types/ListCommentReports";
|
||||
import { GetPostsResponse } from "lemmy-js-client/dist/types/GetPostsResponse";
|
||||
import { GetPosts } from "lemmy-js-client/dist/types/GetPosts";
|
||||
import { GetPersonDetailsResponse } from "lemmy-js-client/dist/types/GetPersonDetailsResponse";
|
||||
|
@ -807,11 +804,11 @@ export async function reportPost(
|
|||
return api.createPostReport(form);
|
||||
}
|
||||
|
||||
export async function listPostReports(
|
||||
export async function listReports(
|
||||
api: LemmyHttp,
|
||||
): Promise<ListPostReportsResponse> {
|
||||
let form: ListPostReports = {};
|
||||
return api.listPostReports(form);
|
||||
): Promise<ListReportsResponse> {
|
||||
let form: ListReports = {};
|
||||
return api.listReports(form);
|
||||
}
|
||||
|
||||
export async function reportComment(
|
||||
|
@ -838,13 +835,6 @@ export async function reportPrivateMessage(
|
|||
return api.createPrivateMessageReport(form);
|
||||
}
|
||||
|
||||
export async function listCommentReports(
|
||||
api: LemmyHttp,
|
||||
): Promise<ListCommentReportsResponse> {
|
||||
let form: ListCommentReports = {};
|
||||
return api.listCommentReports(form);
|
||||
}
|
||||
|
||||
export function getPosts(
|
||||
api: LemmyHttp,
|
||||
listingType?: ListingType,
|
||||
|
|
Loading…
Reference in a new issue