From f8260133c82b26abdde189f9a0a7bfdd93cae4d4 Mon Sep 17 00:00:00 2001 From: Sebastian-Webster <84299475+Sebastian-Webster@users.noreply.github.com> Date: Thu, 26 Sep 2024 05:02:34 +1200 Subject: [PATCH 1/4] filter extra information like __v and _id from filterUserInformationToSend --- libraries/User.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/libraries/User.js b/libraries/User.js index b786975f..14db4cc4 100644 --- a/libraries/User.js +++ b/libraries/User.js @@ -33,7 +33,11 @@ class User { 'authenticationFactorsEnabled', 'MFAEmail', 'followers', - 'following' + 'following', + '__v', + '_id', + 'totalLikes', + 'settings' ] const followers = userObject.followers.length; From fb931370571f497e84c3e8562f5dd75d870ed53d Mon Sep 17 00:00:00 2001 From: Sebastian-Webster <84299475+Sebastian-Webster@users.noreply.github.com> Date: Thu, 26 Sep 2024 05:06:15 +1200 Subject: [PATCH 2/4] remove userId stringification step --- libraries/User.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/libraries/User.js b/libraries/User.js index 14db4cc4..d5c2868e 100644 --- a/libraries/User.js +++ b/libraries/User.js @@ -43,15 +43,11 @@ class User { const followers = userObject.followers.length; const following = userObject.following.length; - console.log('Followers length:', followers, ' | Followers Type:', typeof followers) - notIncludedKeys.forEach(x => delete userObject[x]) userObject.followers = followers userObject.following = following - userObject._id = userObject._id.toString() - return userObject; } From 2394cc54773e3a2e9a1a610679630c2d0a7d81c7 Mon Sep 17 00:00:00 2001 From: Sebastian-Webster <84299475+Sebastian-Webster@users.noreply.github.com> Date: Thu, 26 Sep 2024 05:08:32 +1200 Subject: [PATCH 3/4] remove _id requirement from tests --- tests/user/signup.test.js | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/user/signup.test.js b/tests/user/signup.test.js index 175c62cd..cbec0d2f 100644 --- a/tests/user/signup.test.js +++ b/tests/user/signup.test.js @@ -344,7 +344,6 @@ for (const validUserEmail of VALID_EMAILS) { expect(includesNotIncludedKey).toBe(false); expect(typeof returned.data.data.followers).toBe("number"); expect(typeof returned.data.data.following).toBe("number"); - expect(typeof returned.data.data._id).toBe("string"); expect(await DB.changedCollections()).toIncludeSameMembers(['User', 'RefreshToken']) }) } From abb62fb74a8b0967219ac3e7aa5c9d3ac14958a7 Mon Sep 17 00:00:00 2001 From: Sebastian-Webster <84299475+Sebastian-Webster@users.noreply.github.com> Date: Thu, 26 Sep 2024 05:10:07 +1200 Subject: [PATCH 4/4] remove _id requirement from signin tests --- tests/user/signin.test.js | 3 +-- tests/user/signup.test.js | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/tests/user/signin.test.js b/tests/user/signin.test.js index 47c215b5..55a0596c 100644 --- a/tests/user/signin.test.js +++ b/tests/user/signin.test.js @@ -291,7 +291,7 @@ describe('When Email 2FA is not enabled', () => { } test('if login works', async () => { - expect.assertions(12); + expect.assertions(11); await new User(userData).save(); @@ -343,7 +343,6 @@ describe('When Email 2FA is not enabled', () => { expect(includesNotIncludedKey).toBe(false); expect(typeof returned.data.data.followers).toBe("number"); expect(typeof returned.data.data.following).toBe("number"); - expect(typeof returned.data.data._id).toBe("string"); //End of test if correct user data gets returned diff --git a/tests/user/signup.test.js b/tests/user/signup.test.js index cbec0d2f..191a5ecb 100644 --- a/tests/user/signup.test.js +++ b/tests/user/signup.test.js @@ -264,7 +264,7 @@ test('if signup fails if a user with the same name already exists', async () => for (const validUserEmail of VALID_EMAILS) { test(`if user account creation is successful with correct inputs. Email tested: ${validUserEmail}`, async () => { - expect.assertions(21); + expect.assertions(20); const benchmarkUserData = { name: validName,