From bc7e8010634b96da6d96ff351815e37c3717df2a Mon Sep 17 00:00:00 2001 From: Namekuji Date: Mon, 17 Apr 2023 11:44:54 -0400 Subject: [PATCH] add e2e test of accepting the new account automatically --- .../backend/src/core/UserFollowingService.ts | 1 + packages/backend/test/e2e/move.ts | 25 +++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/packages/backend/src/core/UserFollowingService.ts b/packages/backend/src/core/UserFollowingService.ts index 8a1026f6e3..2f52d91b4d 100644 --- a/packages/backend/src/core/UserFollowingService.ts +++ b/packages/backend/src/core/UserFollowingService.ts @@ -160,6 +160,7 @@ export class UserFollowingService implements OnModuleInit { followerId: oldAccount.id, }, }); + if (autoAccept) break; } catch { /* skip if any error happens */ } diff --git a/packages/backend/test/e2e/move.ts b/packages/backend/test/e2e/move.ts index 6f581a00ef..79d2496aa1 100644 --- a/packages/backend/test/e2e/move.ts +++ b/packages/backend/test/e2e/move.ts @@ -19,6 +19,7 @@ describe('Account Move', () => { let carol: any; let dave: any; let eve: any; + let frank: any; let Users: UsersRepository; let Followings: FollowingsRepository; @@ -37,6 +38,7 @@ describe('Account Move', () => { carol = await signup({ username: 'carol' }); dave = await signup({ username: 'dave' }); eve = await signup({ username: 'eve' }); + frank = await signup({ username: 'frank' }); Users = connection.getRepository(User); Followings = connection.getRepository(Following); Blockings = connection.getRepository(Blocking); @@ -151,6 +153,16 @@ describe('Account Move', () => { await api('/following/create', { userId: dave.id, }, eve); + + await api('/i/update', { + isLocked: true, + }, frank); + await api('/following/create', { + userId: frank.id, + }, alice); + await api('/following/requests/accept', { + userId: alice.id, + }, frank); }, 1000 * 10); test('Prohibit the root account from moving', async () => { @@ -239,6 +251,19 @@ describe('Account Move', () => { assert.strictEqual(newEve.followersCount, 1); }); + test('A locked account automatically accept the follow request if it had already accepted the old account.', async () => { + await api('/following/create', { + userId: frank.id, + }, bob); + const followers = await api('/users/followers', { + userId: frank.id, + }, frank); + + assert.strictEqual(followers.status, 200); + assert.strictEqual(followers.body.length, 2); + assert.strictEqual(followers.body[0].followerId, bob.id); + }); + test.each([ '/antennas/create', '/channels/create',