Add saved_only post_view test.

This commit is contained in:
Dessalines 2024-09-23 08:04:49 -04:00
parent 5ee689397d
commit 67f4d1c773

View file

@ -765,10 +765,20 @@ mod tests {
local_user_vote_display_mode::LocalUserVoteDisplayMode,
person::{Person, PersonInsertForm},
person_block::{PersonBlock, PersonBlockForm},
post::{Post, PostHide, PostInsertForm, PostLike, PostLikeForm, PostRead, PostUpdateForm},
post::{
Post,
PostHide,
PostInsertForm,
PostLike,
PostLikeForm,
PostRead,
PostSaved,
PostSavedForm,
PostUpdateForm,
},
site::Site,
},
traits::{Bannable, Blockable, Crud, Joinable, Likeable},
traits::{Bannable, Blockable, Crud, Joinable, Likeable, Saveable},
utils::{build_db_pool, build_db_pool_for_tests, DbPool, RANK_DEFAULT},
CommunityVisibility,
PostSortType,
@ -1219,6 +1229,36 @@ mod tests {
cleanup(data, pool).await
}
#[tokio::test]
#[serial]
async fn post_listing_saved_only() -> LemmyResult<()> {
let pool = &build_db_pool().await?;
let pool = &mut pool.into();
let data = init_data(pool).await?;
// Save only the bot post
// The saved_only should only show the bot post
let post_save_form = PostSavedForm {
post_id: data.inserted_bot_post.id,
person_id: data.local_user_view.person.id,
};
PostSaved::save(pool, &post_save_form).await?;
// Read the saved only
let read_saved_post_listing = PostQuery {
community_id: Some(data.inserted_community.id),
saved_only: Some(true),
..data.default_post_query()
}
.list(&data.site, pool)
.await?;
// This should only include the bot post, not the one you created
assert_eq!(vec![POST_BY_BOT], names(&read_saved_post_listing));
cleanup(data, pool).await
}
#[tokio::test]
#[serial]
async fn creator_info() -> LemmyResult<()> {