-
Notifications
You must be signed in to change notification settings - Fork 3.9k
[Part 1] Remove Onyx.connect(ONYXKEYS.SESSION) in /Session/index.ts: thread sesion through isSupportAuthToken #96368
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
Open
truph01
wants to merge
6
commits into
Expensify:main
Choose a base branch
from
truph01:fix/67782-v1
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
d2c751e
refactor: thread session to isSupportAuthToken
truph01 4b55783
fix: add test
truph01 297fd3d
fix: remove session from useEffect dep
truph01 e275d10
fix: type
truph01 93959fa
Merge branch 'Expensify:main' into fix/67782-v1
truph01 fc0285b
fix: move fullstory stuff to FullStory folder
truph01 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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| import {isSupportAuthToken} from '@libs/actions/Session'; | ||
| import {shouldInitializeFullstory} from '@libs/Fullstory/common'; | ||
|
|
||
| import CONST from '@src/CONST'; | ||
| import type {Session, UserMetadata} from '@src/types/onyx'; | ||
|
|
||
| const regularSession: Session = {authToken: 'token', accountID: 1, creationDate: Date.now()}; | ||
| const supportSession: Session = {authTokenType: CONST.AUTH_TOKEN_TYPES.SUPPORT, authToken: 'supportToken', accountID: 2, creationDate: Date.now()}; | ||
|
|
||
| describe('Fullstory', () => { | ||
| describe('shouldInitializeFullstory', () => { | ||
| const productionEnv = CONST.ENVIRONMENT.PRODUCTION; | ||
|
|
||
| test('returns true for production environment with non-expensify email', () => { | ||
| const metadata: UserMetadata = {accountID: 1, email: 'user@example.com'}; | ||
| expect(shouldInitializeFullstory(metadata, productionEnv, regularSession)).toBe(true); | ||
| }); | ||
|
|
||
| test('returns false for non-production environment', () => { | ||
| const metadata: UserMetadata = {accountID: 1, email: 'user@example.com'}; | ||
| expect(shouldInitializeFullstory(metadata, CONST.ENVIRONMENT.DEV, regularSession)).toBe(false); | ||
| }); | ||
|
|
||
| test('returns false for expensify partner email in production', () => { | ||
| const metadata: UserMetadata = {accountID: 1, email: 'user@expensify.com'}; | ||
| expect(shouldInitializeFullstory(metadata, productionEnv, regularSession)).toBe(false); | ||
| }); | ||
|
|
||
| test('returns true for fullstory QA test email in non-production', () => { | ||
| const metadata: UserMetadata = {accountID: 1, email: `fullstory-test${CONST.EMAIL.QA_DOMAIN}`}; | ||
| expect(shouldInitializeFullstory(metadata, CONST.ENVIRONMENT.DEV, regularSession)).toBe(true); | ||
| }); | ||
| }); | ||
|
|
||
| describe('shouldInitialize with isSupportAuthToken', () => { | ||
| test('isSupportAuthToken returns true for support session', () => { | ||
| expect(isSupportAuthToken(supportSession)).toBe(true); | ||
| }); | ||
|
|
||
| test('isSupportAuthToken returns false for regular session', () => { | ||
| expect(isSupportAuthToken(regularSession)).toBe(false); | ||
| }); | ||
|
|
||
| test('Fullstory should not initialize when session is support token', () => { | ||
| const metadata: UserMetadata = {accountID: 1, email: 'user@example.com'}; | ||
| const result = shouldInitializeFullstory(metadata, CONST.ENVIRONMENT.PRODUCTION, supportSession) && !isSupportAuthToken(supportSession); | ||
| expect(result).toBe(false); | ||
| }); | ||
|
|
||
| test('Fullstory should initialize when session is not support token', () => { | ||
| const metadata: UserMetadata = {accountID: 1, email: 'user@example.com'}; | ||
| const result = shouldInitializeFullstory(metadata, CONST.ENVIRONMENT.PRODUCTION, regularSession) && !isSupportAuthToken(regularSession); | ||
| expect(result).toBe(true); | ||
| }); | ||
| }); | ||
| }); |
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.
I'd really love for all the full story stuff to exist in its own module. That will also help isolate the
connectWithoutView()calls a bit more. Would you mind doing the small refactor? I'm not sure how much it would involve, so we could do that in a separate issue if it's too much.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.
@MelvinBot, give me plan to do it
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.
@tgolen Resolved via fc0285b