diff --git a/packages/core/src/routes/experience/classes/verifications/social-verification.ts b/packages/core/src/routes/experience/classes/verifications/social-verification.ts index 4284f643676..5027272c702 100644 --- a/packages/core/src/routes/experience/classes/verifications/social-verification.ts +++ b/packages/core/src/routes/experience/classes/verifications/social-verification.ts @@ -210,9 +210,15 @@ export class SocialVerification implements IdentifierVerificationRecord { expect(primaryEmail).toBe(email); }); + it('should successfully sign-up with social but not sync email if the email is registered by another user', async () => { + const { userProfile, user } = await generateNewUser({ + primaryEmail: true, + }); + + const { primaryEmail } = userProfile; + + const userId = await signInWithSocial( + connectorIdMap.get(mockSocialConnectorId)!, + { + id: generateStandardId(), + email: primaryEmail, + }, + { + registerNewUser: true, + } + ); + + expect(userId).not.toBe(user.id); + const { primaryEmail: newUserPrimaryEmail } = await getUser(userId); + expect(newUserPrimaryEmail).toBeNull(); + + await Promise.all([deleteUser(userId), deleteUser(user.id)]); + }); + it('should successfully sign-in with social and sync name', async () => { const userId = await signInWithSocial(connectorIdMap.get(mockSocialConnectorId)!, { id: socialUserId,