From c2d18d3ca3926a1267864de94a4ba63ccebae574 Mon Sep 17 00:00:00 2001 From: phiresky Date: Fri, 31 May 2024 11:56:43 +0200 Subject: [PATCH] prettier --- api_tests/src/follow.spec.ts | 54 +++++++++++++++++++++++++++--------- api_tests/src/post.spec.ts | 14 ++++++++-- api_tests/src/user.spec.ts | 6 +++- 3 files changed, 57 insertions(+), 17 deletions(-) diff --git a/api_tests/src/follow.spec.ts b/api_tests/src/follow.spec.ts index 031809113..6d52b11c8 100644 --- a/api_tests/src/follow.spec.ts +++ b/api_tests/src/follow.spec.ts @@ -26,14 +26,22 @@ test("Follow local community", async () => { // Make sure the follow response went through expect(follow.community_view.community.local).toBe(true); expect(follow.community_view.subscribed).toBe("Subscribed"); - expect(follow.community_view.counts.subscribers).toBe(community.counts.subscribers + 1); - expect(follow.community_view.counts.subscribers_local).toBe(community.counts.subscribers_local + 1); + expect(follow.community_view.counts.subscribers).toBe( + community.counts.subscribers + 1, + ); + expect(follow.community_view.counts.subscribers_local).toBe( + community.counts.subscribers_local + 1, + ); // Test an unfollow let unfollow = await followCommunity(user, false, community.community.id); expect(unfollow.community_view.subscribed).toBe("NotSubscribed"); - expect(unfollow.community_view.counts.subscribers).toBe(community.counts.subscribers); - expect(unfollow.community_view.counts.subscribers_local).toBe(community.counts.subscribers_local); + expect(unfollow.community_view.counts.subscribers).toBe( + community.counts.subscribers, + ); + expect(unfollow.community_view.counts.subscribers_local).toBe( + community.counts.subscribers_local, + ); }); test("Follow federated community", async () => { @@ -41,14 +49,17 @@ test("Follow federated community", async () => { const betaCommunityInitial = ( await waitUntil( () => resolveBetaCommunity(alpha), - c => - !!c.community && (c.community?.counts.subscribers >= 1) + c => !!c.community && c.community?.counts.subscribers >= 1, ) ).community; if (!betaCommunityInitial) { throw "Missing beta community"; } - let follow = await followCommunity(alpha, true, betaCommunityInitial.community.id); + let follow = await followCommunity( + alpha, + true, + betaCommunityInitial.community.id, + ); expect(follow.community_view.subscribed).toBe("Pending"); const betaCommunity = ( await waitUntil( @@ -61,16 +72,22 @@ test("Follow federated community", async () => { expect(betaCommunity?.community.local).toBe(false); expect(betaCommunity?.community.name).toBe("main"); expect(betaCommunity?.subscribed).toBe("Subscribed"); - expect(betaCommunity?.counts.subscribers_local).toBe(betaCommunityInitial.counts.subscribers_local + 1); + expect(betaCommunity?.counts.subscribers_local).toBe( + betaCommunityInitial.counts.subscribers_local + 1, + ); // check that unfollow was federated let communityOnBeta1 = await resolveBetaCommunity(beta); - expect(communityOnBeta1.community?.counts.subscribers).toBe(betaCommunityInitial.counts.subscribers + 1); + expect(communityOnBeta1.community?.counts.subscribers).toBe( + betaCommunityInitial.counts.subscribers + 1, + ); // Check it from local let site = await getSite(alpha); let remoteCommunityId = site.my_user?.follows.find( - c => c.community.local == false && c.community.id === betaCommunityInitial.community.id, + c => + c.community.local == false && + c.community.id === betaCommunityInitial.community.id, )?.community.id; expect(remoteCommunityId).toBeDefined(); @@ -84,10 +101,21 @@ test("Follow federated community", async () => { // Make sure you are unsubbed locally let siteUnfollowCheck = await getSite(alpha); - expect(siteUnfollowCheck.my_user?.follows.find(c => c.community.id === betaCommunityInitial.community.id)).toBe(undefined); + expect( + siteUnfollowCheck.my_user?.follows.find( + c => c.community.id === betaCommunityInitial.community.id, + ), + ).toBe(undefined); // check that unfollow was federated - let communityOnBeta2 = await waitUntil(() => resolveBetaCommunity(beta), c => c.community?.counts.subscribers === betaCommunityInitial.counts.subscribers); - expect(communityOnBeta2.community?.counts.subscribers).toBe(betaCommunityInitial.counts.subscribers); + let communityOnBeta2 = await waitUntil( + () => resolveBetaCommunity(beta), + c => + c.community?.counts.subscribers === + betaCommunityInitial.counts.subscribers, + ); + expect(communityOnBeta2.community?.counts.subscribers).toBe( + betaCommunityInitial.counts.subscribers, + ); expect(communityOnBeta2.community?.counts.subscribers_local).toBe(1); }); diff --git a/api_tests/src/post.spec.ts b/api_tests/src/post.spec.ts index f77dbb2ae..75df80775 100644 --- a/api_tests/src/post.spec.ts +++ b/api_tests/src/post.spec.ts @@ -52,10 +52,14 @@ beforeAll(async () => { afterAll(unfollows); -async function assertPostFederation(postOne: PostView, postTwo: PostView, waitForMeta = true) { +async function assertPostFederation( + postOne: PostView, + postTwo: PostView, + waitForMeta = true, +) { // Link metadata is generated in background task and may not be ready yet at this time, // so wait for it explicitly. For removed posts we cant refetch anything. -if(waitForMeta) { + if (waitForMeta) { postOne = await waitForPost(beta, postOne.post, res => { return res === null || !!res?.post.embed_title; }); @@ -410,7 +414,11 @@ test("Remove a post from admin and community on same instance", async () => { p => p?.post_view.post.removed ?? false, ); expect(alphaPost?.post_view.post.removed).toBe(true); - await assertPostFederation(alphaPost.post_view, removePostRes.post_view, false); + await assertPostFederation( + alphaPost.post_view, + removePostRes.post_view, + false, + ); // Undelete let undeletedPost = await removePost(beta, false, betaPost.post); diff --git a/api_tests/src/user.spec.ts b/api_tests/src/user.spec.ts index 302e0c0b0..5d9a321a1 100644 --- a/api_tests/src/user.spec.ts +++ b/api_tests/src/user.spec.ts @@ -130,7 +130,11 @@ test("Requests with invalid auth should be treated as unauthenticated", async () }); test("Create user with Arabic name", async () => { - let user = await registerUser(alpha, alphaUrl, "تجريب" + Math.random().toString().slice(2, 5)); + let user = await registerUser( + alpha, + alphaUrl, + "تجريب" + Math.random().toString().slice(2, 5), + ); let site = await getSite(user); expect(site.my_user).toBeDefined();