Fixing api tests.

This commit is contained in:
Dessalines 2024-12-07 21:19:49 -05:00
parent a940ce38ef
commit 67d72e36ac
9 changed files with 24 additions and 38 deletions

View file

@ -28,7 +28,7 @@
"eslint": "^9.14.0", "eslint": "^9.14.0",
"eslint-plugin-prettier": "^5.1.3", "eslint-plugin-prettier": "^5.1.3",
"jest": "^29.5.0", "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", "prettier": "^3.2.5",
"ts-jest": "^29.1.0", "ts-jest": "^29.1.0",
"typescript": "^5.5.4", "typescript": "^5.5.4",

View file

@ -30,8 +30,8 @@ importers:
specifier: ^29.5.0 specifier: ^29.5.0
version: 29.7.0(@types/node@22.9.0) version: 29.7.0(@types/node@22.9.0)
lemmy-js-client: lemmy-js-client:
specifier: 0.20.0-api-v4.16 specifier: 0.20.0-reports-combined.3
version: 0.20.0-api-v4.16 version: 0.20.0-reports-combined.3
prettier: prettier:
specifier: ^3.2.5 specifier: ^3.2.5
version: 3.3.3 version: 3.3.3
@ -1167,8 +1167,8 @@ packages:
resolution: {integrity: sha512-eTIzlVOSUR+JxdDFepEYcBMtZ9Qqdef+rnzWdRZuMbOywu5tO2w2N7rqjoANZ5k9vywhL6Br1VRjUIgTQx4E8w==} resolution: {integrity: sha512-eTIzlVOSUR+JxdDFepEYcBMtZ9Qqdef+rnzWdRZuMbOywu5tO2w2N7rqjoANZ5k9vywhL6Br1VRjUIgTQx4E8w==}
engines: {node: '>=6'} engines: {node: '>=6'}
lemmy-js-client@0.20.0-api-v4.16: lemmy-js-client@0.20.0-reports-combined.3:
resolution: {integrity: sha512-9Wn7b8YT2KnEA286+RV1B3mLmecAynvAERoC0ZZiccfSgkEvd3rG9A5X9ejiPqp+JzDZJeisO57+Ut4QHr5oTw==} resolution: {integrity: sha512-0Z/9S41r6NM8f09Gkxerq9zYBE6UcywXfeWNxsYknkyh0ZnKbtNxjTkSxE6JpRbz7wokKFRSH9NpwgNloQY5uw==}
leven@3.1.0: leven@3.1.0:
resolution: {integrity: sha512-qsda+H8jTaUaN/x5vzW2rzc+8Rw4TAQ/4KjB46IwK5VH+IlVeeeje/EoZRpiXvIqjFgK84QffqPztGI3VBLG1A==} resolution: {integrity: sha512-qsda+H8jTaUaN/x5vzW2rzc+8Rw4TAQ/4KjB46IwK5VH+IlVeeeje/EoZRpiXvIqjFgK84QffqPztGI3VBLG1A==}
@ -3077,7 +3077,7 @@ snapshots:
kleur@3.0.3: {} 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: {} leven@3.1.0: {}

View file

@ -16,7 +16,6 @@ import {
followCommunity, followCommunity,
banPersonFromCommunity, banPersonFromCommunity,
resolvePerson, resolvePerson,
getSite,
createPost, createPost,
getPost, getPost,
resolvePost, resolvePost,
@ -36,7 +35,7 @@ import {
userBlockInstance, userBlockInstance,
} from "./shared"; } from "./shared";
import { AdminAllowInstanceParams } from "lemmy-js-client/dist/types/AdminAllowInstanceParams"; 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); beforeAll(setupLogins);
afterAll(unfollows); afterAll(unfollows);
@ -573,7 +572,7 @@ test("Remote mods can edit communities", async () => {
communityRes.community_view.community.id, communityRes.community_view.community.id,
); );
await expect(alphaCommunity.community_view.community.description).toBe( expect(alphaCommunity.community_view.community.description).toBe(
"Example description", "Example description",
); );
}); });

View file

@ -5,7 +5,6 @@ import {
setupLogins, setupLogins,
resolveBetaCommunity, resolveBetaCommunity,
followCommunity, followCommunity,
getSite,
waitUntil, waitUntil,
beta, beta,
betaUrl, betaUrl,

View file

@ -18,7 +18,6 @@ import {
epsilon, epsilon,
followCommunity, followCommunity,
gamma, gamma,
getSite,
imageFetchLimit, imageFetchLimit,
registerUser, registerUser,
resolveBetaCommunity, resolveBetaCommunity,

View file

@ -29,7 +29,6 @@ import {
reportPost, reportPost,
randomString, randomString,
registerUser, registerUser,
getSite,
unfollows, unfollows,
resolveCommunity, resolveCommunity,
waitUntil, waitUntil,

View file

@ -207,7 +207,9 @@ async function allowInstance(api: LemmyHttp, instance: string) {
// Ignore errors from duplicate allows (because setup gets called for each test file) // Ignore errors from duplicate allows (because setup gets called for each test file)
try { try {
await api.adminAllowInstance(params); await api.adminAllowInstance(params);
} catch {} } catch (error) {
console.error(error);
}
} }
export async function createPost( export async function createPost(

View file

@ -58,7 +58,6 @@ use lemmy_api::{
comment_report::{create::create_comment_report, resolve::resolve_comment_report}, comment_report::{create::create_comment_report, resolve::resolve_comment_report},
post_report::{create::create_post_report, resolve::resolve_post_report}, post_report::{create::create_post_report, resolve::resolve_post_report},
private_message_report::{create::create_pm_report, resolve::resolve_pm_report}, private_message_report::{create::create_pm_report, resolve::resolve_pm_report},
report_combined::list::list_reports,
}, },
site::{ site::{
federated_instances::get_federated_instances, 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", post().to(create_comment_report))
.route("/report/resolve", put().to(resolve_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 // Private Message
.service( .service(
scope("/private_message") scope("/private_message")

View file

@ -6,11 +6,6 @@ use lemmy_api::{
list_comment_likes::list_comment_likes, list_comment_likes::list_comment_likes,
save::save_comment, save::save_comment,
}, },
comment_report::{
create::create_comment_report,
list::list_comment_reports,
resolve::resolve_comment_report,
},
community::{ community::{
add_mod::add_mod_to_community, add_mod::add_mod_to_community,
ban::ban_from_community, ban::ban_from_community,
@ -65,16 +60,12 @@ use lemmy_api::{
mark_read::mark_post_as_read, mark_read::mark_post_as_read,
save::save_post, 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::mark_read::mark_pm_as_read,
private_message_report::{ reports::{
create::create_pm_report, comment_report::{create::create_comment_report, resolve::resolve_comment_report},
list::list_pm_reports, post_report::{create::create_post_report, resolve::resolve_post_report},
resolve::resolve_pm_report, private_message_report::{create::create_pm_report, resolve::resolve_pm_report},
report_combined::list::list_reports,
}, },
site::{ site::{
admin_allow_instance::admin_allow_instance, 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("/save", put().to(save_post))
.route("/report", post().to(create_post_report)) .route("/report", post().to(create_post_report))
.route("/report/resolve", put().to(resolve_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)), .route("/site_metadata", get().to(get_link_metadata)),
) )
// Comment // Comment
@ -259,8 +249,7 @@ pub fn config(cfg: &mut ServiceConfig, rate_limit: &RateLimitCell) {
.route("/save", put().to(save_comment)) .route("/save", put().to(save_comment))
.route("/list", get().to(list_comments)) .route("/list", get().to(list_comments))
.route("/report", post().to(create_comment_report)) .route("/report", post().to(create_comment_report))
.route("/report/resolve", put().to(resolve_comment_report)) .route("/report/resolve", put().to(resolve_comment_report)),
.route("/report/list", get().to(list_comment_reports)),
) )
// Private Message // Private Message
.service( .service(
@ -271,8 +260,13 @@ pub fn config(cfg: &mut ServiceConfig, rate_limit: &RateLimitCell) {
.route("/delete", post().to(delete_private_message)) .route("/delete", post().to(delete_private_message))
.route("/mark_as_read", post().to(mark_pm_as_read)) .route("/mark_as_read", post().to(mark_pm_as_read))
.route("/report", post().to(create_pm_report)) .route("/report", post().to(create_pm_report))
.route("/report/resolve", put().to(resolve_pm_report)) .route("/report/resolve", put().to(resolve_pm_report)),
.route("/report/list", get().to(list_pm_reports)), )
// Reports
.service(
scope("/report")
.wrap(rate_limit.message())
.route("/list", get().to(list_reports)),
) )
// User // User
.service( .service(