1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
|
import React from 'react'
import {LogBox, Pressable, View} from 'react-native'
import {useQueryClient} from '@tanstack/react-query'
import {useModalControls} from '#/state/modals'
import {useSessionApi} from '#/state/session'
import {useLoggedOutViewControls} from '#/state/shell/logged-out'
import {useOnboardingDispatch} from '#/state/shell/onboarding'
import {navigate} from '../../../Navigation'
LogBox.ignoreAllLogs()
/**
* This utility component is only included in the test simulator
* build. It gives some quick triggers which help improve the pace
* of the tests dramatically.
*/
const BTN = {height: 1, width: 1, backgroundColor: 'red'}
export function TestCtrls() {
const queryClient = useQueryClient()
const {logoutEveryAccount, login} = useSessionApi()
const {openModal} = useModalControls()
const onboardingDispatch = useOnboardingDispatch()
const {setShowLoggedOut} = useLoggedOutViewControls()
const onPressSignInAlice = async () => {
await login(
{
service: 'http://localhost:3000',
identifier: 'alice.test',
password: 'hunter2',
},
'LoginForm',
)
}
const onPressSignInBob = async () => {
await login(
{
service: 'http://localhost:3000',
identifier: 'bob.test',
password: 'hunter2',
},
'LoginForm',
)
}
return (
<View style={{position: 'absolute', top: 100, right: 0, zIndex: 100}}>
<Pressable
testID="e2eSignInAlice"
onPress={onPressSignInAlice}
accessibilityRole="button"
style={BTN}
/>
<Pressable
testID="e2eSignInBob"
onPress={onPressSignInBob}
accessibilityRole="button"
style={BTN}
/>
<Pressable
testID="e2eSignOut"
onPress={() => logoutEveryAccount('Settings')}
accessibilityRole="button"
style={BTN}
/>
<Pressable
testID="e2eGotoHome"
onPress={() => navigate('Home')}
accessibilityRole="button"
style={BTN}
/>
<Pressable
testID="e2eGotoSettings"
onPress={() => navigate('Settings')}
accessibilityRole="button"
style={BTN}
/>
<Pressable
testID="e2eGotoModeration"
onPress={() => navigate('Moderation')}
accessibilityRole="button"
style={BTN}
/>
<Pressable
testID="e2eGotoLists"
onPress={() => navigate('Lists')}
accessibilityRole="button"
style={BTN}
/>
<Pressable
testID="e2eGotoFeeds"
onPress={() => navigate('Feeds')}
accessibilityRole="button"
style={BTN}
/>
<Pressable
testID="e2eRefreshHome"
onPress={() => queryClient.invalidateQueries({queryKey: ['post-feed']})}
accessibilityRole="button"
style={BTN}
/>
<Pressable
testID="e2eOpenInviteCodesModal"
onPress={() => openModal({name: 'invite-codes'})}
accessibilityRole="button"
style={BTN}
/>
<Pressable
testID="e2eOpenLoggedOutView"
onPress={() => setShowLoggedOut(true)}
accessibilityRole="button"
style={BTN}
/>
<Pressable
testID="e2eStartOnboarding"
onPress={() => {
onboardingDispatch({type: 'start'})
}}
accessibilityRole="button"
style={BTN}
/>
{/* TODO remove this entire control when experiment is over */}
<Pressable
testID="e2eStartLongboarding"
onPress={() => {
onboardingDispatch({type: 'start'})
}}
accessibilityRole="button"
style={BTN}
/>
</View>
)
}
|