mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-12-22 19:01:32 +00:00
More test coverage for user deletion (#5259)
This commit is contained in:
parent
2467a0af12
commit
6a9f924d20
2 changed files with 13 additions and 1 deletions
|
@ -74,6 +74,9 @@ test("Set some user settings, check that they are federated", async () => {
|
|||
|
||||
test("Delete user", async () => {
|
||||
let user = await registerUser(alpha, alphaUrl);
|
||||
let user_profile = await getMyUser(user);
|
||||
let person_id = user_profile.local_user_view.person.id;
|
||||
let actor_id = user_profile.local_user_view.person.actor_id;
|
||||
|
||||
// make a local post and comment
|
||||
let alphaCommunity = (await resolveCommunity(user, "main@lemmy-alpha:8541"))
|
||||
|
@ -101,6 +104,10 @@ test("Delete user", async () => {
|
|||
expect(remoteComment).toBeDefined();
|
||||
|
||||
await deleteUser(user);
|
||||
await expect(getMyUser(user)).rejects.toStrictEqual(Error("incorrect_login"));
|
||||
await expect(getPersonDetails(user, person_id)).rejects.toStrictEqual(
|
||||
Error("not_found"),
|
||||
);
|
||||
|
||||
// check that posts and comments are marked as deleted on other instances.
|
||||
// use get methods to avoid refetching from origin instance
|
||||
|
@ -118,6 +125,9 @@ test("Delete user", async () => {
|
|||
(await getComments(alpha, remoteComment.post_id)).comments[0].comment
|
||||
.deleted,
|
||||
).toBe(true);
|
||||
await expect(
|
||||
getPersonDetails(user, remoteComment.creator_id),
|
||||
).rejects.toStrictEqual(Error("not_found"));
|
||||
});
|
||||
|
||||
test("Requests with invalid auth should be treated as unauthenticated", async () => {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use actix_web::web::{Data, Json};
|
||||
use lemmy_api_common::{context::LemmyContext, site::MyUserInfo};
|
||||
use lemmy_api_common::{context::LemmyContext, site::MyUserInfo, utils::check_user_valid};
|
||||
use lemmy_db_schema::source::{
|
||||
actor_language::LocalUserLanguage,
|
||||
community_block::CommunityBlock,
|
||||
|
@ -15,6 +15,8 @@ pub async fn get_my_user(
|
|||
local_user_view: LocalUserView,
|
||||
context: Data<LemmyContext>,
|
||||
) -> LemmyResult<Json<MyUserInfo>> {
|
||||
check_user_valid(&local_user_view.person)?;
|
||||
|
||||
// Build the local user with parallel queries and add it to site response
|
||||
let person_id = local_user_view.person.id;
|
||||
let local_user_id = local_user_view.local_user.id;
|
||||
|
|
Loading…
Reference in a new issue