-
Notifications
You must be signed in to change notification settings - Fork 3.1k
5509 remove flash on intermediate verify step when sign in with sso #5526
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
charlesBochet
merged 29 commits into
main
from
5509-remove-flash-on-intermediate-verify-step-when-sign-in-with-sso
May 25, 2024
Merged
Changes from all commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
99429b7
Remove modal layout on /verify
martmull 7f0c6d9
Update page layout
martmull ace8814
Remove useless navigate
martmull d9f8895
Remove useNavigateAfterSignUp
martmull c135077
Merge branch 'main' into 5509-remove-flash-on-intermediate-verify-ste…
martmull 466ad47
Merge branch 'main' into 5509-remove-flash-on-intermediate-verify-ste…
martmull 5733004
Remove navigate from PasswordReset.tsx
martmull 9ed2615
Remove navigate from Invite.tsx
martmull 33c2d54
Remove navigate from signOutAndRedirect
martmull 59e9773
Add back navigate from passwordReset and Invite
martmull 51d539a
Remove workspaceInviteHashVerificationState
martmull 39ad86a
Remove passwordResetTokenVerificationState
martmull 8f7a73e
Simplify DefaultLayout
martmull afca6a4
Update PageChangeEffect
martmull e560468
TO BE VALIDATED: cleaning code + remove DefaultHomePage component
martmull 71d2638
Clean code
martmull d9ae886
Use onboarding status in default layout
martmull b72a440
Split show auth modal and add test
martmull 851265a
Split pageChangeEffect and add test
martmull f72e1fd
Correct typo
martmull c9effc2
Merge branch 'main' into 5509-remove-flash-on-intermediate-verify-ste…
martmull 8385a7c
Fix refresh token expired blank screen
martmull aa093a9
Fix tests
martmull 33ca4ef
Add test for defaultHomePagePath
martmull 7281db1
Fix multiple info messages
martmull de73721
Simplify code
martmull f8765ea
Update isDefaultLayoutAuthModalVisibleState type
martmull 6078480
Remove navigate from useSignInUp
martmull f14bdc2
Fix invitation
martmull File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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
72 changes: 72 additions & 0 deletions
72
packages/twenty-front/src/hooks/__tests__/useDefaultHomePagePath.test.ts
This file contains hidden or 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 |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import { renderHook } from '@testing-library/react'; | ||
import { RecoilRoot, useSetRecoilState } from 'recoil'; | ||
|
||
import { currentUserState } from '@/auth/states/currentUserState'; | ||
import { useObjectMetadataItem } from '@/object-metadata/hooks/useObjectMetadataItem'; | ||
import { getObjectMetadataItemsMock } from '@/object-metadata/utils/getObjectMetadataItemsMock'; | ||
import { usePrefetchedData } from '@/prefetch/hooks/usePrefetchedData'; | ||
import { AppPath } from '@/types/AppPath'; | ||
import { useDefaultHomePagePath } from '~/hooks/useDefaultHomePagePath'; | ||
import { mockedUsersData } from '~/testing/mock-data/users'; | ||
|
||
const objectMetadataItem = getObjectMetadataItemsMock()[0]; | ||
jest.mock('@/object-metadata/hooks/useObjectMetadataItem'); | ||
jest.mocked(useObjectMetadataItem).mockReturnValue({ | ||
objectMetadataItem, | ||
}); | ||
|
||
jest.mock('@/prefetch/hooks/usePrefetchedData'); | ||
const setupMockPrefetchedData = (viewId?: string) => { | ||
jest.mocked(usePrefetchedData).mockReturnValue({ | ||
isDataPrefetched: true, | ||
records: viewId | ||
? [ | ||
{ | ||
id: viewId, | ||
__typename: 'object', | ||
objectMetadataId: objectMetadataItem.id, | ||
}, | ||
] | ||
: [], | ||
}); | ||
}; | ||
|
||
const renderHooks = (withCurrentUser: boolean) => { | ||
const { result } = renderHook( | ||
() => { | ||
const setCurrentUser = useSetRecoilState(currentUserState); | ||
if (withCurrentUser) { | ||
setCurrentUser(mockedUsersData[0]); | ||
} | ||
return useDefaultHomePagePath(); | ||
}, | ||
{ | ||
wrapper: RecoilRoot, | ||
}, | ||
); | ||
return { result }; | ||
}; | ||
describe('useDefaultHomePagePath', () => { | ||
it('should return proper path when no currentUser', () => { | ||
setupMockPrefetchedData(); | ||
const { result } = renderHooks(false); | ||
expect(result.current.defaultHomePagePath).toEqual(AppPath.SignInUp); | ||
}); | ||
it('should return proper path when no currentUser and existing view', () => { | ||
setupMockPrefetchedData('viewId'); | ||
const { result } = renderHooks(false); | ||
expect(result.current.defaultHomePagePath).toEqual(AppPath.SignInUp); | ||
}); | ||
it('should return proper path when currentUser is defined', () => { | ||
setupMockPrefetchedData(); | ||
const { result } = renderHooks(true); | ||
expect(result.current.defaultHomePagePath).toEqual('/objects/companies'); | ||
}); | ||
it('should return proper path when currentUser is defined and view exists', () => { | ||
setupMockPrefetchedData('viewId'); | ||
const { result } = renderHooks(true); | ||
expect(result.current.defaultHomePagePath).toEqual( | ||
'/objects/companies?view=viewId', | ||
); | ||
}); | ||
}); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
awesome
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for adding tests