Add better onboard testing (#4007)

zio/stable
Paul Frazee 2024-05-13 20:23:31 -07:00 committed by GitHub
parent fd704bfd44
commit 107760d551
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 71 additions and 1 deletions

View File

@ -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

View File

@ -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) {

View File

@ -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'
@ -24,6 +25,7 @@ export function TestCtrls() {
const {openModal} = useModalControls()
const onboardingDispatch = useOnboardingDispatch()
const {setShowLoggedOut} = useLoggedOutViewControls()
const setGate = useDangerousSetGate()
const onPressSignInAlice = async () => {
await login(
{
@ -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}
/>