Add api test for synchronizing featured posts (ref #4475) (#4476)

* Correctly synchronize collection of community featured posts (fixes #3867)

* Add api test for synchronizing featured posts (ref #4475)

* prettier
This commit is contained in:
Nutomic 2024-02-27 15:11:41 +01:00 committed by GitHub
parent e01ea32928
commit ab4deaa49a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 2152 additions and 967 deletions

File diff suppressed because it is too large Load diff

View file

@ -14,7 +14,7 @@ export RUST_LOG="warn,lemmy_server=$LEMMY_LOG_LEVEL,lemmy_federate=$LEMMY_LOG_LE
export LEMMY_TEST_FAST_FEDERATION=1 # by default, the persistent federation queue has delays in the scale of 30s-5min
# pictrs setup
if [ ! -f "pict-rs" ]; then
if [ ! -f "api_tests/pict-rs" ]; then
curl "https://git.asonix.dog/asonix/pict-rs/releases/download/v0.5.0-beta.2/pict-rs-linux-amd64" -o api_tests/pict-rs
chmod +x api_tests/pict-rs
fi

View file

@ -37,9 +37,11 @@ import {
waitForPost,
alphaUrl,
loginUser,
createCommunity,
getPosts,
} from "./shared";
import { PostView } from "lemmy-js-client/dist/types/PostView";
import { EditSite, ResolveObject } from "lemmy-js-client";
import { EditSite, ListingType, ResolveObject } from "lemmy-js-client";
let betaCommunity: CommunityView | undefined;
@ -225,6 +227,26 @@ test("Sticky a post", async () => {
expect(betaPost3?.post.featured_community).toBe(false);
});
test("Collection of featured posts gets federated", async () => {
// create a new community and feature a post
let community = await createCommunity(alpha);
let post = await createPost(alpha, community.community_view.community.id);
let featuredPost = await featurePost(alpha, true, post.post_view.post);
expect(featuredPost.post_view.post.featured_community).toBe(true);
// fetch the community, ensure that post is also fetched and marked as featured
let betaCommunity = await resolveCommunity(
beta,
community.community_view.community.actor_id,
);
const betaPost = await waitForPost(
beta,
post.post_view.post,
post => post?.post.featured_community === true,
);
});
test("Lock a post", async () => {
if (!betaCommunity) {
throw "Missing beta community";