Skip to content
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

fix(onboarding): revert default of CPV screen to be in onboarding #4876

Merged
merged 3 commits into from
Feb 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/RevokePhoneNumber.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
}, [revokeNumberAsync.status])

const handleNavigateToVerifiedNumber = () => {
navigate(Screens.VerificationStartScreen)
navigate(Screens.VerificationStartScreen, { hasOnboarded: true })

Check warning on line 54 in src/RevokePhoneNumber.tsx

View check run for this annotation

Codecov / codecov/patch

src/RevokePhoneNumber.tsx#L54

Added line #L54 was not covered by tests
}

const handleRevokePhoneNumber = async () => {
Expand Down
2 changes: 1 addition & 1 deletion src/account/Settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@

const goToConfirmNumber = () => {
ValoraAnalytics.track(SettingsEvents.settings_verify_number)
navigate(Screens.VerificationStartScreen)
navigate(Screens.VerificationStartScreen, { hasOnboarded: true })

Check warning on line 119 in src/account/Settings.tsx

View check run for this annotation

Codecov / codecov/patch

src/account/Settings.tsx#L119

Added line #L119 was not covered by tests
}

const goToLanguageSetting = () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ describe('ConsumerIncentivesHomeScreen', () => {

fireEvent.press(getByTestId('ConsumerIncentives/CTA'))

expect(navigate).toHaveBeenCalledWith(Screens.VerificationStartScreen)
expect(navigate).toHaveBeenCalledWith(Screens.VerificationStartScreen, { hasOnboarded: true })
})

it('opens a WebView when Learn More is tapped', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/consumerIncentives/ConsumerIncentivesHomeScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ export default function ConsumerIncentivesHomeScreen() {
buttonPressed: RewardsScreenCta.CashIn,
})
} else {
navigate(Screens.VerificationStartScreen)
navigate(Screens.VerificationStartScreen, { hasOnboarded: true })
ValoraAnalytics.track(RewardsEvents.rewards_screen_cta_pressed, {
buttonPressed: RewardsScreenCta.VerifyPhone,
})
Expand Down
2 changes: 1 addition & 1 deletion src/home/NotificationBox.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ describe('NotificationBox', () => {
expect(getByText('reverifyUsingCPVHomecard.description')).toBeTruthy()

fireEvent.press(getByText('reverifyUsingCPVHomecard.buttonLabel'))
expect(navigate).toHaveBeenCalledWith(Screens.VerificationStartScreen)
expect(navigate).toHaveBeenCalledWith(Screens.VerificationStartScreen, { hasOnboarded: true })
})

it('renders educations when not complete yet', () => {
Expand Down
4 changes: 2 additions & 2 deletions src/home/NotificationBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ export function useSimpleActions() {
notificationId: NotificationType.reverify_using_CPV,
notificationPositionInList: params?.index,
})
navigate(Screens.VerificationStartScreen)
navigate(Screens.VerificationStartScreen, { hasOnboarded: true })
},
},
],
Expand Down Expand Up @@ -282,7 +282,7 @@ export function useSimpleActions() {
notificationId: NotificationType.verification_prompt,
notificationPositionInList: params?.index,
})
navigate(Screens.VerificationStartScreen)
navigate(Screens.VerificationStartScreen, { hasOnboarded: true })
},
},
{
Expand Down
2 changes: 1 addition & 1 deletion src/home/NotificationCenter.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ describe('NotificationCenter', () => {
expect(getByText('reverifyUsingCPVHomecard.description')).toBeTruthy()

fireEvent.press(getByText('reverifyUsingCPVHomecard.buttonLabel'))
expect(navigate).toHaveBeenCalledWith(Screens.VerificationStartScreen)
expect(navigate).toHaveBeenCalledWith(Screens.VerificationStartScreen, { hasOnboarded: true })
})

it('emits correct analytics event when CTA button is pressed', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/keylessBackup/LinkPhoneNumber.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ describe('LinkPhoneNumber', () => {

expect(navigate).toHaveBeenCalledTimes(1)
expect(navigate).toHaveBeenCalledWith(Screens.VerificationStartScreen, {
isOnboarding: false,
hasOnboarded: false,
})
expect(ValoraAnalytics.track).toHaveBeenCalledWith(OnboardingEvents.link_phone_number)
})
Expand Down
2 changes: 1 addition & 1 deletion src/keylessBackup/LinkPhoneNumber.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export default function LinkPhoneNumber({ navigation }: Props) {

const continueButtonOnPress = async () => {
ValoraAnalytics.track(OnboardingEvents.link_phone_number)
navigate(Screens.VerificationStartScreen, { isOnboarding: false })
navigate(Screens.VerificationStartScreen, { hasOnboarded: false })
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Setting this to false here since it's technically still onboarding, we can reconsider this if we change the initial screen to be LinkPhoneNumber if the user completes cloud recovery and bails on this screen or the phone verification screen. cc @finnian0826

}
const laterButtonOnPress = async () => {
ValoraAnalytics.track(OnboardingEvents.link_phone_number_later)
Expand Down
2 changes: 1 addition & 1 deletion src/navigator/types.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ export type StackParamList = {
[Screens.ValidateRecipientAccount]: ValidateRecipientParams
[Screens.VerificationStartScreen]:
| {
isOnboarding?: boolean
hasOnboarded?: boolean
selectedCountryCodeAlpha2?: string
}
| undefined
Expand Down
52 changes: 20 additions & 32 deletions src/onboarding/steps.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ describe('onboarding steps', () => {
chooseAdventureEnabled: false,
},
screens: [
{ screen: Screens.NameAndPicture, props: undefined },
{ screen: Screens.PincodeSet, props: undefined },
{ screen: Screens.EnableBiometry, props: undefined },
{ screen: Screens.ProtectWallet, props: undefined },
{ screen: Screens.VerificationStartScreen, props: { isOnboarding: true } },
Screens.NameAndPicture,
Screens.PincodeSet,
Screens.EnableBiometry,
Screens.ProtectWallet,
Screens.VerificationStartScreen,
],
name: 'newUserFlowWithEverythingEnabled',
finalScreen: Screens.WalletHome,
Expand All @@ -47,10 +47,10 @@ describe('onboarding steps', () => {
onboardingNameScreenEnabled: false,
},
screens: [
{ screen: Screens.PincodeSet, props: undefined },
{ screen: Screens.EnableBiometry, props: undefined },
{ screen: Screens.ProtectWallet, props: undefined },
{ screen: Screens.VerificationStartScreen, props: { isOnboarding: true } },
Screens.PincodeSet,
Screens.EnableBiometry,
Screens.ProtectWallet,
Screens.VerificationStartScreen,
],
name: 'newUserChooseAdventure',
finalScreen: Screens.ChooseYourAdventure,
Expand All @@ -64,11 +64,7 @@ describe('onboarding steps', () => {
recoveringFromStoreWipe: false,
chooseAdventureEnabled: false,
},
screens: [
{ screen: Screens.NameAndPicture, props: undefined },
{ screen: Screens.PincodeSet, props: undefined },
{ screen: Screens.ProtectWallet, props: undefined },
],
screens: [Screens.NameAndPicture, Screens.PincodeSet, Screens.ProtectWallet],
name: 'newUserFlowWithEverythingDisabled',
finalScreen: Screens.WalletHome,
}
Expand All @@ -83,11 +79,11 @@ describe('onboarding steps', () => {
chooseAdventureEnabled: false,
},
screens: [
{ screen: Screens.NameAndPicture, props: undefined },
{ screen: Screens.PincodeSet, props: undefined },
{ screen: Screens.EnableBiometry, props: undefined },
{ screen: Screens.ImportWallet, props: undefined },
{ screen: Screens.VerificationStartScreen, props: { isOnboarding: true } },
Screens.NameAndPicture,
Screens.PincodeSet,
Screens.EnableBiometry,
Screens.ImportWallet,
Screens.VerificationStartScreen,
],
name: 'importWalletFlowEverythingEnabled',
finalScreen: Screens.WalletHome,
Expand All @@ -106,7 +102,7 @@ describe('onboarding steps', () => {
'goToNextOnboardingScreen and getOnboardingStepValues work as expected for $name',
({ onboardingProps, screens, name, finalScreen }) => {
const expectedTotalSteps = screens.length
screens.forEach(({ screen, props }, index) => {
screens.forEach((screen, index) => {
const { totalSteps, step } = getOnboardingStepValues(screen, onboardingProps)
// Checking that the step number is correct
try {
Expand All @@ -130,16 +126,12 @@ describe('onboarding steps', () => {
updateStatsigAndNavigate(finalScreen as keyof StackParamList)
)
} else {
const args: any[] = [screens[index + 1].screen]
if (screens[index + 1].props) {
args.push(screens[index + 1].props)
}
try {
// eslint-disable-next-line jest/no-conditional-expect
expect(navigate).toHaveBeenCalledWith(...args)
expect(navigate).toHaveBeenCalledWith(screens[index + 1])
} catch {
// eslint-disable-next-line jest/no-conditional-expect
expect(navigateClearingStack).toHaveBeenCalledWith(...args)
expect(navigateClearingStack).toHaveBeenCalledWith(screens[index + 1])
}
}
})
Expand Down Expand Up @@ -298,9 +290,7 @@ describe('onboarding steps', () => {
},
})
expect(mockStore.dispatch).not.toHaveBeenCalled()
expect(navigate).toHaveBeenCalledWith(Screens.VerificationStartScreen, {
isOnboarding: true,
})
expect(navigate).toHaveBeenCalledWith(Screens.VerificationStartScreen)
})
})
describe('Screens.VerificationStartScreen', () => {
Expand Down Expand Up @@ -344,9 +334,7 @@ describe('onboarding steps', () => {
},
})
expect(mockStore.dispatch).not.toHaveBeenCalled()
expect(navigate).toHaveBeenCalledWith(Screens.VerificationStartScreen, {
isOnboarding: true,
})
expect(navigate).toHaveBeenCalledWith(Screens.VerificationStartScreen)
})
})
})
Expand Down
4 changes: 2 additions & 2 deletions src/onboarding/steps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ export function _getStepInfo({ firstScreenInStep, navigator, dispatch, props }:
navigateHomeOrChooseAdventure()
} else {
// DO NOT CLEAR NAVIGATION STACK HERE - breaks restore flow on initial app open in native-stack v6
navigate(Screens.VerificationStartScreen, { isOnboarding: true })
navigate(Screens.VerificationStartScreen)
}
},
}
Expand All @@ -298,7 +298,7 @@ export function _getStepInfo({ firstScreenInStep, navigator, dispatch, props }:
dispatch(setHasSeenVerificationNux(true))
finishOnboarding(Screens.WalletHome)
} else {
navigate(Screens.VerificationStartScreen, { isOnboarding: true })
navigate(Screens.VerificationStartScreen)
}
},
}
Expand Down
2 changes: 1 addition & 1 deletion src/send/SelectRecipientButtons.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ describe('SelectRecipientButtons', () => {
expect(getByTestId('SelectRecipient/PhoneNumberModal')).not.toBeVisible()
})
await waitFor(() => {
expect(navigate).toHaveBeenCalledWith(Screens.VerificationStartScreen)
expect(navigate).toHaveBeenCalledWith(Screens.VerificationStartScreen, { hasOnboarded: true })
})
})

Expand Down
2 changes: 1 addition & 1 deletion src/send/SelectRecipientButtons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ export default function SelectRecipientButtons({ onContactsPermissionGranted }:
// reset state so the next time the modal is dismissed, this doesn't end
// up navigating
setNavigateToPhoneVerification(false)
navigate(Screens.VerificationStartScreen)
navigate(Screens.VerificationStartScreen, { hasOnboarded: true })
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/send/Send.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@
}

const onPressStartVerification = () => {
navigate(Screens.VerificationStartScreen)
navigate(Screens.VerificationStartScreen, { hasOnboarded: true })

Check warning on line 195 in src/send/Send.tsx

View check run for this annotation

Codecov / codecov/patch

src/send/Send.tsx#L195

Added line #L195 was not covered by tests
}

const onPressContactsSettings = () => {
Expand Down
12 changes: 6 additions & 6 deletions src/verify/VerificationStartScreen.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const renderComponent = (
component={VerificationStartScreen}
params={{
selectedCountryCodeAlpha2: 'NL',
isOnboarding: false,
hasOnboarded: true,
...navParams,
}}
/>
Expand Down Expand Up @@ -81,7 +81,7 @@ describe('VerificationStartScreen', () => {
service: 'service',
storage: 'storage',
})
const { getByText, getByTestId } = renderComponent({ isOnboarding: true })
const { getByText, getByTestId } = renderComponent({ hasOnboarded: false })

await act(() => {
jest.advanceTimersByTime(5000)
Expand All @@ -106,7 +106,7 @@ describe('VerificationStartScreen', () => {
service: 'service',
storage: 'storage',
})
const { getByText, getByTestId, queryByTestId } = renderComponent({ isOnboarding: true }, true)
const { getByText, getByTestId, queryByTestId } = renderComponent({ hasOnboarded: false }, true)

await act(() => {
jest.advanceTimersByTime(5000)
Expand Down Expand Up @@ -152,7 +152,7 @@ describe('VerificationStartScreen', () => {
})

it('skip button works', async () => {
const { getByText } = renderComponent({ isOnboarding: true })
const { getByText } = renderComponent({ hasOnboarded: false })

await act(() => {
fireEvent.press(getByText('skip'))
Expand All @@ -171,7 +171,7 @@ describe('VerificationStartScreen', () => {
service: 'service',
storage: 'storage',
})
const { getByText, getByTestId } = renderComponent({ isOnboarding: true })
const { getByText, getByTestId } = renderComponent({ hasOnboarded: false })

await act(() => {
jest.advanceTimersByTime(5000)
Expand All @@ -196,7 +196,7 @@ describe('VerificationStartScreen', () => {
service: 'service',
storage: 'storage',
})
const { getByText, getByTestId } = renderComponent({ isOnboarding: true }, true)
const { getByText, getByTestId } = renderComponent({ hasOnboarded: false }, true)

await act(() => {
jest.advanceTimersByTime(5000)
Expand Down
12 changes: 6 additions & 6 deletions src/verify/VerificationStartScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ function VerificationStartScreen({
onboardingProps
)
const choseToRestoreAccount = useSelector(choseToRestoreAccountSelector)
const showSteps = route.params?.isOnboarding && !choseToRestoreAccount
const showSteps = !route.params?.hasOnboarded && !choseToRestoreAccount

const countries = useMemo(() => new Countries(i18n.language), [i18n.language])
const country = phoneNumberInfo.countryCodeAlpha2
Expand Down Expand Up @@ -121,23 +121,23 @@ function VerificationStartScreen({
navigation.setOptions({
headerTitle: title,
headerRight: () =>
route.params?.isOnboarding && (
!route.params?.hasOnboarded && (
<TopBarTextButton
title={t('skip')}
testID="PhoneVerificationSkipHeader"
onPress={onPressSkip}
titleStyle={{ color: colors.onboardingBrownLight }}
/>
),
headerLeft: () => !route.params?.isOnboarding && <BackButton />,
headerLeft: () => route.params?.hasOnboarded && <BackButton />,
// Disable iOS back during onboarding
gestureEnabled: !route.params?.isOnboarding,
gestureEnabled: !!route.params?.hasOnboarded,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Does this need to be forced to a boolean?

Suggested change
gestureEnabled: !!route.params?.hasOnboarded,
gestureEnabled: route.params?.hasOnboarded,

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it has to be forced to a boolean. The default value is true

})
}, [navigation, step, totalSteps, route.params, showSteps])

// Prevent device back on Android during onboarding
useEffect(() => {
if (route.params?.isOnboarding) {
if (!route.params?.hasOnboarded) {
const backPressListener = () => true
BackHandler.addEventListener('hardwareBackPress', backPressListener)
return () => BackHandler.removeEventListener('hardwareBackPress', backPressListener)
Expand Down Expand Up @@ -184,7 +184,7 @@ function VerificationStartScreen({
selectedCountryCodeAlpha2: phoneNumberInfo.countryCodeAlpha2,
onSelectCountry: (countryCodeAlpha2: string) => {
navigate(Screens.VerificationStartScreen, {
isOnboarding: !!route.params?.isOnboarding,
hasOnboarded: !!route.params?.hasOnboarded,
selectedCountryCodeAlpha2: countryCodeAlpha2,
})
},
Expand Down
Loading