-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
61 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,17 @@ | ||
import { zodResolver } from '@hookform/resolvers/zod'; | ||
import { useEffect } from 'react'; | ||
import { useForm } from 'react-hook-form'; | ||
import { useLocation, useSearchParams } from 'react-router-dom'; | ||
import { useRecoilValue } from 'recoil'; | ||
import { z } from 'zod'; | ||
import { useLocation } from 'react-router-dom'; | ||
|
||
import { PASSWORD_REGEX } from '@/auth/utils/passwordRegex'; | ||
import { isDeveloperDefaultSignInPrefilledState } from '@/client-config/states/isDeveloperDefaultSignInPrefilledState'; | ||
import { useSearchParams } from 'react-router-dom'; | ||
import { isDefined } from '~/utils/isDefined'; | ||
import { | ||
SignInUpStep, | ||
signInUpStepState, | ||
} from '@/auth/states/signInUpStepState'; | ||
import { PASSWORD_REGEX } from '@/auth/utils/passwordRegex'; | ||
import { isDeveloperDefaultSignInPrefilledState } from '@/client-config/states/isDeveloperDefaultSignInPrefilledState'; | ||
import { isDefined } from '~/utils/isDefined'; | ||
|
||
const makeValidationSchema = (signInUpStep: SignInUpStep) => | ||
z | ||
|
@@ -63,6 +62,11 @@ export const useSignInUpForm = () => { | |
form.setValue('email', '[email protected]'); | ||
form.setValue('password', 'Applecar2025'); | ||
} | ||
}, [form, isDeveloperDefaultSignInPrefilled, prefilledEmail, location.search]); | ||
return { form: form }; | ||
}, [ | ||
form, | ||
isDeveloperDefaultSignInPrefilled, | ||
prefilledEmail, | ||
location.search, | ||
]); | ||
return { form, validationSchema }; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,22 +2,23 @@ import { HttpService } from '@nestjs/axios'; | |
import { Test, TestingModule } from '@nestjs/testing'; | ||
import { getRepositoryToken } from '@nestjs/typeorm'; | ||
|
||
import bcrypt from 'bcrypt'; | ||
import { expect, jest } from '@jest/globals'; | ||
import bcrypt from 'bcrypt'; | ||
|
||
import { AppToken } from 'src/engine/core-modules/app-token/app-token.entity'; | ||
import { SignInUpService } from 'src/engine/core-modules/auth/services/sign-in-up.service'; | ||
import { DomainManagerService } from 'src/engine/core-modules/domain-manager/service/domain-manager.service'; | ||
import { EnvironmentService } from 'src/engine/core-modules/environment/environment.service'; | ||
import { FileUploadService } from 'src/engine/core-modules/file/file-upload/services/file-upload.service'; | ||
import { OnboardingService } from 'src/engine/core-modules/onboarding/onboarding.service'; | ||
import { UserWorkspaceService } from 'src/engine/core-modules/user-workspace/user-workspace.service'; | ||
import { User } from 'src/engine/core-modules/user/user.entity'; | ||
import { WorkspaceInvitationService } from 'src/engine/core-modules/workspace-invitation/services/workspace-invitation.service'; | ||
import { WorkspaceService } from 'src/engine/core-modules/workspace/services/workspace.service'; | ||
import { | ||
Workspace, | ||
WorkspaceActivationStatus, | ||
} from 'src/engine/core-modules/workspace/workspace.entity'; | ||
import { EnvironmentService } from 'src/engine/core-modules/environment/environment.service'; | ||
import { AppToken } from 'src/engine/core-modules/app-token/app-token.entity'; | ||
import { WorkspaceInvitationService } from 'src/engine/core-modules/workspace-invitation/services/workspace-invitation.service'; | ||
import { WorkspaceService } from 'src/engine/core-modules/workspace/services/workspace.service'; | ||
|
||
jest.mock('bcrypt'); | ||
|
||
|
@@ -75,9 +76,7 @@ describe('SignInUpService', () => { | |
}, | ||
{ | ||
provide: WorkspaceService, | ||
useValue: { | ||
generateSubdomain: jest.fn().mockReturnValue('tartanpion'), | ||
}, | ||
useValue: {}, | ||
}, | ||
{ | ||
provide: UserWorkspaceService, | ||
|
@@ -114,6 +113,12 @@ describe('SignInUpService', () => { | |
workspaceInvitationFindInvitationByWorkspaceSubdomainAndUserEmailMock, | ||
}, | ||
}, | ||
{ | ||
provide: DomainManagerService, | ||
useValue: { | ||
generateSubdomain: jest.fn().mockReturnValue('testSubDomain'), | ||
}, | ||
}, | ||
], | ||
}).compile(); | ||
|
||
|
@@ -139,7 +144,7 @@ describe('SignInUpService', () => { | |
await service.signInUp({ | ||
email: '[email protected]', | ||
fromSSO: true, | ||
targetWorkspaceSubdomain: 'tartanpion', | ||
targetWorkspaceSubdomain: 'testSubDomain', | ||
}); | ||
|
||
expect(spy).toHaveBeenCalledWith( | ||
|
@@ -169,7 +174,7 @@ describe('SignInUpService', () => { | |
const result = await service.signInUp({ | ||
email, | ||
fromSSO: true, | ||
targetWorkspaceSubdomain: 'tartanpion', | ||
targetWorkspaceSubdomain: 'testSubDomain', | ||
}); | ||
|
||
expect(result).toEqual(existingUser); | ||
|
@@ -204,7 +209,7 @@ describe('SignInUpService', () => { | |
await service.signInUp({ | ||
email, | ||
fromSSO: true, | ||
targetWorkspaceSubdomain: 'tartanpion', | ||
targetWorkspaceSubdomain: 'testSubDomain', | ||
}); | ||
|
||
expect(spySignInUpOnExistingWorkspace).toHaveBeenCalledWith( | ||
|
@@ -257,7 +262,7 @@ describe('SignInUpService', () => { | |
const result = await service.signInUp({ | ||
email, | ||
fromSSO: true, | ||
targetWorkspaceSubdomain: 'tartanpion', | ||
targetWorkspaceSubdomain: 'testSubDomain', | ||
}); | ||
|
||
expect(result).toEqual(existingUser); | ||
|
@@ -297,7 +302,7 @@ describe('SignInUpService', () => { | |
email, | ||
fromSSO: true, | ||
workspacePersonalInviteToken, | ||
targetWorkspaceSubdomain: 'tartanpion', | ||
targetWorkspaceSubdomain: 'testSubDomain', | ||
}); | ||
|
||
expect(spySignInUpOnExistingWorkspace).toHaveBeenCalledWith( | ||
|
@@ -348,7 +353,7 @@ describe('SignInUpService', () => { | |
email, | ||
fromSSO: true, | ||
workspacePersonalInviteToken, | ||
targetWorkspaceSubdomain: 'tartanpion', | ||
targetWorkspaceSubdomain: 'testSubDomain', | ||
}); | ||
|
||
expect( | ||
|
@@ -375,7 +380,7 @@ describe('SignInUpService', () => { | |
email, | ||
password, | ||
fromSSO: false, | ||
targetWorkspaceSubdomain: 'tartanpion', | ||
targetWorkspaceSubdomain: 'testSubDomain', | ||
}); | ||
|
||
expect( | ||
|
@@ -400,7 +405,7 @@ describe('SignInUpService', () => { | |
email, | ||
password, | ||
fromSSO: false, | ||
targetWorkspaceSubdomain: 'tartanpion', | ||
targetWorkspaceSubdomain: 'testSubDomain', | ||
}); | ||
|
||
expect(UserCreateMock).toHaveBeenCalledTimes(1); | ||
|
@@ -436,7 +441,7 @@ describe('SignInUpService', () => { | |
password, | ||
fromSSO: false, | ||
workspacePersonalInviteToken, | ||
targetWorkspaceSubdomain: 'tartanpion', | ||
targetWorkspaceSubdomain: 'testSubDomain', | ||
}); | ||
|
||
expect(UserCreateMock).toHaveBeenCalledTimes(1); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters