Skip to content

Commit

Permalink
Add better onboard testing (#4007)
Browse files Browse the repository at this point in the history
  • Loading branch information
pfrazee authored May 14, 2024
1 parent fd704bf commit 107760d
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 1 deletion.
31 changes: 31 additions & 0 deletions __e2e__/flows/onboarding-old.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Remove this test when the old onboarding is deprecated
appId: xyz.blueskyweb.app
---
- runScript:
file: ../setupServer.js
env:
SERVER_PATH: "?users"
- runFlow:
file: ../setupApp.yml
- tapOn:
id: "e2eSignInAlice"
- tapOn:
id: "e2eStartLongboarding"
- tapOn: "Continue to next step"
- tapOn: "Continue to the next step without following any accounts"
- tapOn: Show replies in Following feed
- tapOn: Show quote-posts in Following feed
- tapOn: Show re-posts in Following feed
- tapOn: Show replies in Following feed
- waitForAnimationToEnd
- tapOn: Continue to next step
- waitForAnimationToEnd
- tapOn: "Continue to the next step"
- waitForAnimationToEnd
- tapOn: Continue to next step
- waitForAnimationToEnd
- tapOn: Continue to next step
- waitForAnimationToEnd
- tapOn: "Complete onboarding and start using your account"
- waitForAnimationToEnd
- assertVisible: Following
22 changes: 22 additions & 0 deletions src/lib/statsig/statsig.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,28 @@ export function useGate(): (gateName: Gate) => boolean {
return gate
}

/**
* Debugging tool to override a gate. USE ONLY IN E2E TESTS!
*/
export function useDangerousSetGate(): (
gateName: Gate,
value: boolean,
) => void {
const cache = React.useContext(GateCache)
if (!cache) {
throw Error(
'useDangerousSetGate() cannot be called outside StatsigProvider.',
)
}
const dangerousSetGate = React.useCallback(
(gateName: Gate, value: boolean) => {
cache.set(gateName, value)
},
[cache],
)
return dangerousSetGate
}

function toStatsigUser(did: string | undefined): StatsigUser {
let userID: string | undefined
if (did) {
Expand Down
19 changes: 18 additions & 1 deletion src/view/com/testing/TestCtrls.e2e.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React from 'react'
import {LogBox, Pressable, View} from 'react-native'
import {useQueryClient} from '@tanstack/react-query'

import {useDangerousSetGate} from '#/lib/statsig/statsig'
import {useModalControls} from '#/state/modals'
import {useSessionApi} from '#/state/session'
import {useLoggedOutViewControls} from '#/state/shell/logged-out'
Expand All @@ -24,6 +25,7 @@ export function TestCtrls() {
const {openModal} = useModalControls()
const onboardingDispatch = useOnboardingDispatch()
const {setShowLoggedOut} = useLoggedOutViewControls()
const setGate = useDangerousSetGate()
const onPressSignInAlice = async () => {
await login(
{
Expand Down Expand Up @@ -108,7 +110,22 @@ export function TestCtrls() {
/>
<Pressable
testID="e2eStartOnboarding"
onPress={() => onboardingDispatch({type: 'start'})}
onPress={() => {
// TODO remove when experiment is over
setGate('reduced_onboarding_and_home_algo', true)
onboardingDispatch({type: 'start'})
}}
accessibilityRole="button"
style={BTN}
/>
{/* TODO remove this entire control when experiment is over */}
<Pressable
testID="e2eStartLongboarding"
onPress={() => {
// TODO remove when experiment is over
setGate('reduced_onboarding_and_home_algo', false)
onboardingDispatch({type: 'start'})
}}
accessibilityRole="button"
style={BTN}
/>
Expand Down

0 comments on commit 107760d

Please sign in to comment.