fix waits after all follow actions

This commit is contained in:
phiresky 2023-09-18 16:29:08 +00:00
parent 48496599b2
commit 943b960c32
4 changed files with 21 additions and 29 deletions

View file

@ -42,10 +42,7 @@ let postOnAlphaRes: PostResponse;
beforeAll(async () => {
await setupLogins();
await unfollows();
await followBeta(alpha);
await followBeta(gamma);
// wait for FOLLOW_ADDITIONS_RECHECK_DELAY
await delay(2000);
await Promise.all([followBeta(alpha), followBeta(gamma)]);
let betaCommunity = (await resolveBetaCommunity(alpha)).community;
if (betaCommunity) {
postOnAlphaRes = await createPost(alpha, betaCommunity.community.id);
@ -560,8 +557,6 @@ test("Check that activity from another instance is sent to third instance", asyn
() => resolveBetaCommunity(gamma),
c => c.community?.subscribed === "Subscribed",
);
// FOLLOW_ADDITIONS_RECHECK_DELAY
await delay(2000);
// Create a post on beta
let betaPost = await createPost(beta, 2);
@ -607,8 +602,7 @@ test("Check that activity from another instance is sent to third instance", asyn
commentRes.comment_view,
);
await unfollowRemotes(alpha);
await unfollowRemotes(gamma);
await Promise.all([unfollowRemotes(alpha), unfollowRemotes(gamma)]);
});
test("Fetch in_reply_tos: A is unsubbed from B, B makes a post, and some embedded comments, A subs to B, B updates the lowest level comment, A fetches both the post and all the inreplyto comments for that post.", async () => {
@ -671,7 +665,8 @@ test("Fetch in_reply_tos: A is unsubbed from B, B makes a post, and some embedde
() => getComments(alpha, alphaPostB!.post.id),
c =>
c.comments[1]?.comment.content ===
parentCommentRes.comment_view.comment.content,
parentCommentRes.comment_view.comment.content &&
c.comments[0]?.comment.content === updateRes.comment_view.comment.content,
);
expect(alphaPost.post_view.post.name).toBeDefined();
assertCommentFederation(

View file

@ -87,12 +87,6 @@ test("Delete community", async () => {
// Make sure the follow response went through
expect(follow.community_view.community.local).toBe(false);
await waitUntil(
() => resolveCommunity(alpha, searchShort),
g => g.community?.subscribed === "Subscribed",
);
// wait FOLLOW_ADDITIONS_RECHECK_DELAY
await delay(2000);
let deleteCommunityRes = await deleteCommunity(
beta,
true,
@ -145,10 +139,6 @@ test("Remove community", async () => {
// Make sure the follow response went through
expect(follow.community_view.community.local).toBe(false);
await waitUntil(
() => resolveCommunity(alpha, searchShort),
g => g.community?.subscribed === "Subscribed",
);
let removeCommunityRes = await removeCommunity(
beta,
true,

View file

@ -220,8 +220,6 @@ test("Lock a post", async () => {
() => resolveBetaCommunity(alpha),
c => c.community?.subscribed === "Subscribed",
);
// wait FOLLOW_ADDITIONS_RECHECK_DELAY (there's no API to wait for this currently)
await delay(2_000);
let postRes = await createPost(alpha, betaCommunity.community.id);
// wait for federation

View file

@ -447,7 +447,14 @@ export async function followCommunity(
follow,
auth: api.auth,
};
return api.client.followCommunity(form);
const res = await api.client.followCommunity(form);
await waitUntil(
() => resolveCommunity(api, res.community_view.community.actor_id),
g => g.community?.subscribed === (follow ? "Subscribed" : "NotSubscribed"),
);
// wait FOLLOW_ADDITIONS_RECHECK_DELAY (there's no API to wait for this currently)
await delay(2000);
return res;
}
export async function likePost(
@ -745,9 +752,9 @@ export async function unfollowRemotes(api: API): Promise<GetSiteResponse> {
let site = await getSite(api);
let remoteFollowed =
site.my_user?.follows.filter(c => c.community.local == false) ?? [];
for (let cu of remoteFollowed) {
await followCommunity(api, false, cu.community.id);
}
await Promise.all(
remoteFollowed.map(cu => followCommunity(api, false, cu.community.id)),
);
let siteRes = await getSite(api);
return siteRes;
}
@ -841,10 +848,12 @@ export function randomString(length: number): string {
}
export async function unfollows() {
await unfollowRemotes(alpha);
await unfollowRemotes(gamma);
await unfollowRemotes(delta);
await unfollowRemotes(epsilon);
await Promise.all([
unfollowRemotes(alpha),
unfollowRemotes(gamma),
unfollowRemotes(delta),
unfollowRemotes(epsilon),
]);
}
export function getCommentParentId(comment: Comment): number | undefined {