mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-11-22 06:36:14 +00:00
fix
This commit is contained in:
parent
2e7d2d1956
commit
ae3b8f4f76
|
@ -125,7 +125,7 @@ test("Unlike a post", async () => {
|
||||||
const betaPost = await waitForPost(
|
const betaPost = await waitForPost(
|
||||||
beta,
|
beta,
|
||||||
postRes.post_view.post,
|
postRes.post_view.post,
|
||||||
post => post.counts.score === 0,
|
post => post?.counts.score === 0,
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(betaPost).toBeDefined();
|
expect(betaPost).toBeDefined();
|
||||||
|
@ -222,7 +222,7 @@ test("Lock a post", async () => {
|
||||||
let alphaPost1 = await waitForPost(
|
let alphaPost1 = await waitForPost(
|
||||||
alpha,
|
alpha,
|
||||||
postRes.post_view.post,
|
postRes.post_view.post,
|
||||||
post => post.post.locked,
|
post => !!post && post.post.locked,
|
||||||
);
|
);
|
||||||
|
|
||||||
// Try to make a new comment there, on alpha
|
// Try to make a new comment there, on alpha
|
||||||
|
@ -236,7 +236,7 @@ test("Lock a post", async () => {
|
||||||
let alphaPost2 = await waitForPost(
|
let alphaPost2 = await waitForPost(
|
||||||
alpha,
|
alpha,
|
||||||
postRes.post_view.post,
|
postRes.post_view.post,
|
||||||
post => !post.post.locked,
|
post => !!post && !post.post.locked,
|
||||||
);
|
);
|
||||||
expect(alphaPost2.community.local).toBe(false);
|
expect(alphaPost2.community.local).toBe(false);
|
||||||
expect(alphaPost2.creator.local).toBe(true);
|
expect(alphaPost2.creator.local).toBe(true);
|
||||||
|
@ -336,13 +336,12 @@ test("Remove a post from admin and community on same instance", async () => {
|
||||||
expect(removePostRes.post_view.post.removed).toBe(true);
|
expect(removePostRes.post_view.post.removed).toBe(true);
|
||||||
|
|
||||||
// Make sure lemmy alpha sees post is removed
|
// Make sure lemmy alpha sees post is removed
|
||||||
let alphaPost = await waitForPost(
|
let alphaPost = await waitUntil(
|
||||||
alpha,
|
() => getPost(alpha, postRes.post_view.post.id),
|
||||||
postRes.post_view.post,
|
p => p?.post_view.post.removed ?? false,
|
||||||
p => p.post.removed,
|
|
||||||
);
|
);
|
||||||
expect(alphaPost.post.removed).toBe(true);
|
expect(alphaPost.post_view?.post.removed).toBe(true);
|
||||||
assertPostFederation(alphaPost, removePostRes.post_view);
|
assertPostFederation(alphaPost.post_view, removePostRes.post_view);
|
||||||
|
|
||||||
// Undelete
|
// Undelete
|
||||||
let undeletedPost = await removePost(beta, false, betaPost.post);
|
let undeletedPost = await removePost(beta, false, betaPost.post);
|
||||||
|
@ -352,7 +351,7 @@ test("Remove a post from admin and community on same instance", async () => {
|
||||||
let alphaPost2 = await waitForPost(
|
let alphaPost2 = await waitForPost(
|
||||||
alpha,
|
alpha,
|
||||||
postRes.post_view.post,
|
postRes.post_view.post,
|
||||||
p => !p.post.removed,
|
p => !!p && !p.post.removed,
|
||||||
);
|
);
|
||||||
expect(alphaPost2.post.removed).toBe(false);
|
expect(alphaPost2.post.removed).toBe(false);
|
||||||
assertPostFederation(alphaPost2, undeletedPost.post_view);
|
assertPostFederation(alphaPost2, undeletedPost.post_view);
|
||||||
|
@ -367,7 +366,7 @@ test("Search for a post", async () => {
|
||||||
let postRes = await createPost(alpha, betaCommunity.community.id);
|
let postRes = await createPost(alpha, betaCommunity.community.id);
|
||||||
expect(postRes.post_view.post).toBeDefined();
|
expect(postRes.post_view.post).toBeDefined();
|
||||||
|
|
||||||
let betaPost = (await resolvePost(beta, postRes.post_view.post)).post;
|
let betaPost = await waitForPost(beta, postRes.post_view.post);
|
||||||
expect(betaPost?.post.name).toBeDefined();
|
expect(betaPost?.post.name).toBeDefined();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -323,10 +323,10 @@ export async function searchPostLocal(
|
||||||
export async function waitForPost(
|
export async function waitForPost(
|
||||||
api: API,
|
api: API,
|
||||||
post: Post,
|
post: Post,
|
||||||
checker: (t: PostView) => boolean = p => !!p,
|
checker: (t: PostView | undefined) => boolean = p => !!p,
|
||||||
) {
|
) {
|
||||||
return waitUntil(
|
return waitUntil<PostView>(
|
||||||
() => searchPostLocal(api, post).then(p => p.posts[0] as PostView),
|
() => searchPostLocal(api, post).then(p => p.posts[0]),
|
||||||
checker,
|
checker,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue