From 67d72e36ac2c52932067fa9f3d447cf1c4c459db Mon Sep 17 00:00:00 2001 From: Dessalines Date: Sat, 7 Dec 2024 21:19:49 -0500 Subject: [PATCH] Fixing api tests. --- api_tests/package.json | 2 +- api_tests/pnpm-lock.yaml | 10 +++++----- api_tests/src/community.spec.ts | 5 ++--- api_tests/src/follow.spec.ts | 1 - api_tests/src/image.spec.ts | 1 - api_tests/src/post.spec.ts | 1 - api_tests/src/shared.ts | 4 +++- src/api_routes_v3.rs | 6 ------ src/api_routes_v4.rs | 32 +++++++++++++------------------- 9 files changed, 24 insertions(+), 38 deletions(-) diff --git a/api_tests/package.json b/api_tests/package.json index 7ea21d0ba..965388625 100644 --- a/api_tests/package.json +++ b/api_tests/package.json @@ -28,7 +28,7 @@ "eslint": "^9.14.0", "eslint-plugin-prettier": "^5.1.3", "jest": "^29.5.0", - "lemmy-js-client": "0.20.0-api-v4.16", + "lemmy-js-client": "0.20.0-reports-combined.3", "prettier": "^3.2.5", "ts-jest": "^29.1.0", "typescript": "^5.5.4", diff --git a/api_tests/pnpm-lock.yaml b/api_tests/pnpm-lock.yaml index 496606e6c..198062652 100644 --- a/api_tests/pnpm-lock.yaml +++ b/api_tests/pnpm-lock.yaml @@ -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-api-v4.16 - version: 0.20.0-api-v4.16 + specifier: 0.20.0-reports-combined.3 + version: 0.20.0-reports-combined.3 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-api-v4.16: - resolution: {integrity: sha512-9Wn7b8YT2KnEA286+RV1B3mLmecAynvAERoC0ZZiccfSgkEvd3rG9A5X9ejiPqp+JzDZJeisO57+Ut4QHr5oTw==} + lemmy-js-client@0.20.0-reports-combined.3: + resolution: {integrity: sha512-0Z/9S41r6NM8f09Gkxerq9zYBE6UcywXfeWNxsYknkyh0ZnKbtNxjTkSxE6JpRbz7wokKFRSH9NpwgNloQY5uw==} 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-api-v4.16: {} + lemmy-js-client@0.20.0-reports-combined.3: {} leven@3.1.0: {} diff --git a/api_tests/src/community.spec.ts b/api_tests/src/community.spec.ts index 2bb092088..2d1570ea6 100644 --- a/api_tests/src/community.spec.ts +++ b/api_tests/src/community.spec.ts @@ -16,7 +16,6 @@ import { followCommunity, banPersonFromCommunity, resolvePerson, - getSite, createPost, getPost, resolvePost, @@ -36,7 +35,7 @@ import { userBlockInstance, } from "./shared"; import { AdminAllowInstanceParams } from "lemmy-js-client/dist/types/AdminAllowInstanceParams"; -import { EditCommunity, EditSite, GetPosts } from "lemmy-js-client"; +import { EditCommunity, GetPosts } from "lemmy-js-client"; beforeAll(setupLogins); afterAll(unfollows); @@ -573,7 +572,7 @@ test("Remote mods can edit communities", async () => { communityRes.community_view.community.id, ); - await expect(alphaCommunity.community_view.community.description).toBe( + expect(alphaCommunity.community_view.community.description).toBe( "Example description", ); }); diff --git a/api_tests/src/follow.spec.ts b/api_tests/src/follow.spec.ts index 936ce2606..c447e14cd 100644 --- a/api_tests/src/follow.spec.ts +++ b/api_tests/src/follow.spec.ts @@ -5,7 +5,6 @@ import { setupLogins, resolveBetaCommunity, followCommunity, - getSite, waitUntil, beta, betaUrl, diff --git a/api_tests/src/image.spec.ts b/api_tests/src/image.spec.ts index a3478081a..4d1abbdfd 100644 --- a/api_tests/src/image.spec.ts +++ b/api_tests/src/image.spec.ts @@ -18,7 +18,6 @@ import { epsilon, followCommunity, gamma, - getSite, imageFetchLimit, registerUser, resolveBetaCommunity, diff --git a/api_tests/src/post.spec.ts b/api_tests/src/post.spec.ts index 13c436e68..37381d302 100644 --- a/api_tests/src/post.spec.ts +++ b/api_tests/src/post.spec.ts @@ -29,7 +29,6 @@ import { reportPost, randomString, registerUser, - getSite, unfollows, resolveCommunity, waitUntil, diff --git a/api_tests/src/shared.ts b/api_tests/src/shared.ts index a3c560d8f..b10d57002 100644 --- a/api_tests/src/shared.ts +++ b/api_tests/src/shared.ts @@ -207,7 +207,9 @@ async function allowInstance(api: LemmyHttp, instance: string) { // Ignore errors from duplicate allows (because setup gets called for each test file) try { await api.adminAllowInstance(params); - } catch {} + } catch (error) { + console.error(error); + } } export async function createPost( diff --git a/src/api_routes_v3.rs b/src/api_routes_v3.rs index be1ae14ef..5e8fb741d 100644 --- a/src/api_routes_v3.rs +++ b/src/api_routes_v3.rs @@ -58,7 +58,6 @@ use lemmy_api::{ comment_report::{create::create_comment_report, resolve::resolve_comment_report}, post_report::{create::create_post_report, resolve::resolve_post_report}, private_message_report::{create::create_pm_report, resolve::resolve_pm_report}, - report_combined::list::list_reports, }, site::{ federated_instances::get_federated_instances, @@ -239,11 +238,6 @@ pub fn config(cfg: &mut ServiceConfig, rate_limit: &RateLimitCell) { .route("/report", post().to(create_comment_report)) .route("/report/resolve", put().to(resolve_comment_report)), ) - .service( - scope("report") - .wrap(rate_limit.message()) - .route("/list", get().to(list_reports)), - ) // Private Message .service( scope("/private_message") diff --git a/src/api_routes_v4.rs b/src/api_routes_v4.rs index a9f71c9da..b03be60f2 100644 --- a/src/api_routes_v4.rs +++ b/src/api_routes_v4.rs @@ -6,11 +6,6 @@ use lemmy_api::{ list_comment_likes::list_comment_likes, save::save_comment, }, - comment_report::{ - create::create_comment_report, - list::list_comment_reports, - resolve::resolve_comment_report, - }, community::{ add_mod::add_mod_to_community, ban::ban_from_community, @@ -65,16 +60,12 @@ use lemmy_api::{ mark_read::mark_post_as_read, save::save_post, }, - post_report::{ - create::create_post_report, - list::list_post_reports, - resolve::resolve_post_report, - }, private_message::mark_read::mark_pm_as_read, - private_message_report::{ - create::create_pm_report, - list::list_pm_reports, - resolve::resolve_pm_report, + reports::{ + comment_report::{create::create_comment_report, resolve::resolve_comment_report}, + post_report::{create::create_post_report, resolve::resolve_post_report}, + private_message_report::{create::create_pm_report, resolve::resolve_pm_report}, + report_combined::list::list_reports, }, site::{ admin_allow_instance::admin_allow_instance, @@ -235,7 +226,6 @@ pub fn config(cfg: &mut ServiceConfig, rate_limit: &RateLimitCell) { .route("/save", put().to(save_post)) .route("/report", post().to(create_post_report)) .route("/report/resolve", put().to(resolve_post_report)) - .route("/report/list", get().to(list_post_reports)) .route("/site_metadata", get().to(get_link_metadata)), ) // Comment @@ -259,8 +249,7 @@ pub fn config(cfg: &mut ServiceConfig, rate_limit: &RateLimitCell) { .route("/save", put().to(save_comment)) .route("/list", get().to(list_comments)) .route("/report", post().to(create_comment_report)) - .route("/report/resolve", put().to(resolve_comment_report)) - .route("/report/list", get().to(list_comment_reports)), + .route("/report/resolve", put().to(resolve_comment_report)), ) // Private Message .service( @@ -271,8 +260,13 @@ pub fn config(cfg: &mut ServiceConfig, rate_limit: &RateLimitCell) { .route("/delete", post().to(delete_private_message)) .route("/mark_as_read", post().to(mark_pm_as_read)) .route("/report", post().to(create_pm_report)) - .route("/report/resolve", put().to(resolve_pm_report)) - .route("/report/list", get().to(list_pm_reports)), + .route("/report/resolve", put().to(resolve_pm_report)), + ) + // Reports + .service( + scope("/report") + .wrap(rate_limit.message()) + .route("/list", get().to(list_reports)), ) // User .service(