Files
bsky-social-app/src/view/com/testing/TestCtrls.e2e.tsx
T
Eric Bailey 05b728fffc Eric/preferences (#1873)
* Add initial preferences query, couple mutations

* Remove unused

* Clean up labels, migrate getModerationOpts

* Add birth date handling

* Migrate feed prefs

* Migrate thread view prefs

* Migrate homeFeed to use existing key name

* Fix up saved feeds in response, no impl yet

* Migrate saved feeds to new hooks

* Clean up more of preferences

* Fix PreferencesThreads load state

* Fix modal dismissal

* Small spacing fix

---------

Co-authored-by: Paul Frazee <pfrazee@gmail.com>
2023-11-12 11:31:11 -08:00

101 lines
2.8 KiB
TypeScript

import React from 'react'
import {Pressable, View} from 'react-native'
import {navigate} from '../../../Navigation'
import {useModalControls} from '#/state/modals'
import {useQueryClient} from '@tanstack/react-query'
import {useSessionApi} from '#/state/session'
import {useSetFeedViewPreferencesMutation} from '#/state/queries/preferences'
/**
* 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 {logout, login} = useSessionApi()
const {openModal} = useModalControls()
const {mutate: setFeedViewPref} = useSetFeedViewPreferencesMutation()
const onPressSignInAlice = async () => {
await login({
service: 'http://localhost:3000',
identifier: 'alice.test',
password: 'hunter2',
})
}
const onPressSignInBob = async () => {
await login({
service: 'http://localhost:3000',
identifier: 'bob.test',
password: 'hunter2',
})
}
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={() => logout()}
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="e2eToggleMergefeed"
onPress={() => setFeedViewPref({lab_mergeFeedEnabled: true})}
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}
/>
</View>
)
}