Bluesky app fork with some witchin' additions 馃挮 witchsky.app
bluesky fork client
at main 145 lines 4.1 kB view raw
1import {useState} from 'react' 2import {LogBox, Pressable, TextInput, View} from 'react-native' 3import {useQueryClient} from '@tanstack/react-query' 4 5import {BLUESKY_PROXY_HEADER} from '#/lib/constants' 6import {useAgent, useSessionApi} from '#/state/session' 7import {useLoggedOutViewControls} from '#/state/shell/logged-out' 8import {useOnboardingDispatch} from '#/state/shell/onboarding' 9import {navigate} from '../../../Navigation' 10 11LogBox.ignoreAllLogs() 12 13/** 14 * This utility component is only included in the test simulator 15 * build. It gives some quick triggers which help improve the pace 16 * of the tests dramatically. 17 */ 18 19const BTN = {height: 1, width: 1, backgroundColor: 'red'} 20 21export function TestCtrls() { 22 const agent = useAgent() 23 const queryClient = useQueryClient() 24 const {logoutEveryAccount, login} = useSessionApi() 25 const onboardingDispatch = useOnboardingDispatch() 26 const {setShowLoggedOut} = useLoggedOutViewControls() 27 const onPressSignInAlice = async () => { 28 console.info('[E2E] Signing in as Alice') 29 await login( 30 { 31 service: 'http://localhost:3000', 32 identifier: 'alice.test', 33 password: 'hunter2', 34 }, 35 'LoginForm', 36 ) 37 setShowLoggedOut(false) 38 } 39 const onPressSignInBob = async () => { 40 console.info('[E2E] Signing in as Bob') 41 await login( 42 { 43 service: 'http://localhost:3000', 44 identifier: 'bob.test', 45 password: 'hunter2', 46 }, 47 'LoginForm', 48 ) 49 setShowLoggedOut(false) 50 } 51 const [proxyHeader, setProxyHeader] = useState('') 52 return ( 53 <View style={{position: 'absolute', top: 100, right: 0, zIndex: 100}}> 54 <TextInput 55 accessibilityLabel="Text input field" 56 accessibilityHint="Enter proxy header" 57 testID="e2eProxyHeaderInput" 58 onChangeText={val => setProxyHeader(val as any)} 59 autoComplete="off" 60 autoCorrect={false} 61 autoCapitalize="none" 62 onSubmitEditing={() => { 63 const header = `${proxyHeader}#bsky_appview` 64 BLUESKY_PROXY_HEADER.set(header) 65 agent.configureProxy(header as any) 66 }} 67 style={BTN} 68 /> 69 <Pressable 70 testID="e2eSignInAlice" 71 onPress={onPressSignInAlice} 72 accessibilityRole="button" 73 style={BTN} 74 /> 75 <Pressable 76 testID="e2eSignInBob" 77 onPress={onPressSignInBob} 78 accessibilityRole="button" 79 style={BTN} 80 /> 81 <Pressable 82 testID="e2eSignOut" 83 onPress={() => logoutEveryAccount('Settings')} 84 accessibilityRole="button" 85 style={BTN} 86 /> 87 <Pressable 88 testID="e2eGotoHome" 89 onPress={() => navigate('Home')} 90 accessibilityRole="button" 91 style={BTN} 92 /> 93 <Pressable 94 testID="e2eGotoSettings" 95 onPress={() => navigate('Settings')} 96 accessibilityRole="button" 97 style={BTN} 98 /> 99 <Pressable 100 testID="e2eGotoModeration" 101 onPress={() => navigate('Moderation')} 102 accessibilityRole="button" 103 style={BTN} 104 /> 105 <Pressable 106 testID="e2eGotoLists" 107 onPress={() => navigate('Lists')} 108 accessibilityRole="button" 109 style={BTN} 110 /> 111 <Pressable 112 testID="e2eGotoFeeds" 113 onPress={() => navigate('Feeds')} 114 accessibilityRole="button" 115 style={BTN} 116 /> 117 <Pressable 118 testID="storybookBtn" 119 onPress={() => navigate('Debug')} 120 accessibilityRole="button" 121 style={BTN} 122 /> 123 <Pressable 124 testID="e2eRefreshHome" 125 onPress={() => queryClient.invalidateQueries({queryKey: ['post-feed']})} 126 accessibilityRole="button" 127 style={BTN} 128 /> 129 <Pressable 130 testID="e2eOpenLoggedOutView" 131 onPress={() => setShowLoggedOut(true)} 132 accessibilityRole="button" 133 style={BTN} 134 /> 135 <Pressable 136 testID="e2eStartOnboarding" 137 onPress={() => { 138 onboardingDispatch({type: 'start'}) 139 }} 140 accessibilityRole="button" 141 style={BTN} 142 /> 143 </View> 144 ) 145}