Skip to content

Commit

Permalink
chore: ajout de testIds manquant pour test automatisé (#252)
Browse files Browse the repository at this point in the history
Signed-off-by: fc-santos <[email protected]>
  • Loading branch information
fc-santos authored Feb 3, 2025
1 parent 93d9a41 commit a6791ad
Show file tree
Hide file tree
Showing 9 changed files with 109 additions and 78 deletions.
69 changes: 2 additions & 67 deletions app/container-imp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,21 @@ import {
ToursState,
OnboardingState,
DispatchAction,
Screens,
defaultConfig as bifoldDefaultConfig,
} from '@hyperledger/aries-bifold-core'
import { Locales } from '@hyperledger/aries-bifold-core/App/localization'
import { DefaultScreenOptionsDictionary } from '@hyperledger/aries-bifold-core/App/navigators/defaultStackOptions'
import { Config as BifoldConfig } from '@hyperledger/aries-bifold-core/App/types/config'
import { InlineErrorPosition } from '@hyperledger/aries-bifold-core/App/types/error'
import { getProofRequestTemplates } from '@hyperledger/aries-bifold-verifier'
import { BrandingOverlayType, RemoteOCABundleResolver } from '@hyperledger/aries-oca/build/legacy'
import AsyncStorage from '@react-native-async-storage/async-storage'
import { StackNavigationOptions } from '@react-navigation/stack'
import { Platform } from 'react-native'
import { Config } from 'react-native-config'
import { DependencyContainer } from 'tsyringe'

import ledgers from './config/ledgers'
import AddCredentialButton from './src/components/AddCredentialButton'
import AddCredentialSlider from './src/components/AddCredentialSlider'
import EmptyList from './src/components/EmptyList'
import HelpCenterButton from './src/components/Help/HelpCenterButton'
import HomeEmptyList from './src/components/HomeEmptyList'
import HomeFooter from './src/components/HomeFooter'
import HomeHeader from './src/components/HomeHeader'
Expand All @@ -40,6 +35,7 @@ import ConnectionAlert from './src/components/modals/ConnectionAlert'
import { PINValidationRules } from './src/constants'
import { useNotifications } from './src/hooks/notifications'
import TermsStack from './src/navigators/TermsStack'
import { getScreenOptions } from './src/navigators/screen-options'
import DefaultNotification from './src/screens/DefaultNotification'
import Developer from './src/screens/Developer'
import { pages } from './src/screens/OnboardingPages'
Expand Down Expand Up @@ -105,68 +101,7 @@ export class AppContainer implements Container {
const indyLedgers = this._container.resolve(TOKENS.UTIL_LEDGERS) satisfies IndyVdrPoolConfig[]
const allLedgers = [...qcLedgers, ...indyLedgers]

const defaultScreenOptionsDict = DefaultScreenOptionsDictionary

const onboardingScreenOptions: StackNavigationOptions = {
headerShown: Platform.OS == 'ios',
headerTitle: '',
headerStyle: {
height: 50,
},
}

defaultScreenOptionsDict[Screens.Home] = {
...defaultScreenOptionsDict[Screens.Home],
headerLeft: undefined,
headerRight: HelpCenterButton,
}
defaultScreenOptionsDict[Screens.Connection] = {
...defaultScreenOptionsDict[Screens.Connection],
headerLeft: undefined,
headerRight: HelpCenterButton,
}
defaultScreenOptionsDict[Screens.CredentialDetails] = {
...defaultScreenOptionsDict[Screens.CredentialDetails],
headerShown: true,
headerLeft: undefined,
headerRight: HelpCenterButton,
}

defaultScreenOptionsDict[Screens.OpenIDCredentialDetails] = {
...defaultScreenOptionsDict[Screens.OpenIDCredentialDetails],
headerShown: true,
headerLeft: undefined,
headerRight: HelpCenterButton,
}

defaultScreenOptionsDict[Screens.Credentials] = {
...defaultScreenOptionsDict[Screens.Credentials],
headerLeft: undefined,
headerRight: HelpCenterButton,
}
defaultScreenOptionsDict[Screens.Language] = {
...defaultScreenOptionsDict[Screens.Language],
headerRight: HelpCenterButton,
}
defaultScreenOptionsDict[Screens.Scan] = {
...defaultScreenOptionsDict[Screens.Scan],
headerRight: HelpCenterButton,
}

defaultScreenOptionsDict[Screens.UseBiometry] = {
...defaultScreenOptionsDict[Screens.UseBiometry],
...onboardingScreenOptions,
}

defaultScreenOptionsDict[Screens.CreatePIN] = {
...defaultScreenOptionsDict[Screens.CreatePIN],
...onboardingScreenOptions,
gestureEnabled: true,
}
defaultScreenOptionsDict[Screens.Terms] = {
...defaultScreenOptionsDict[Screens.Terms],
...onboardingScreenOptions,
}
const defaultScreenOptionsDict = getScreenOptions()

// Here you can register any component to override components in core package
// Example: Replacing button in core with custom button
Expand Down
3 changes: 2 additions & 1 deletion app/src/components/Help/HelpCenterButton.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useTheme } from '@hyperledger/aries-bifold-core'
import { testIdWithKey, useTheme } from '@hyperledger/aries-bifold-core'
import { getDefaultHeaderHeight } from '@react-navigation/elements'
import { useRoute } from '@react-navigation/native'
import React, { useCallback } from 'react'
Expand Down Expand Up @@ -39,6 +39,7 @@ const HelpCenterButton = () => {
onPress={activateSlider}
accessibilityHint={t('HelpCenter.OptionsList')}
accessibilityRole="button"
testID={testIdWithKey('HelpCenterButton')}
>
<Text style={styles.text}>{t('HelpCenter.Help')}</Text>
</TouchableOpacity>
Expand Down
3 changes: 2 additions & 1 deletion app/src/components/Help/HelpListSlider.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useTheme } from '@hyperledger/aries-bifold-core'
import { testIdWithKey, useTheme } from '@hyperledger/aries-bifold-core'
import { i18n } from '@hyperledger/aries-bifold-core/App/localization'
import { useNavigation } from '@react-navigation/native'
import { StackNavigationProp } from '@react-navigation/stack'
Expand Down Expand Up @@ -163,6 +163,7 @@ const HelpListSlider: React.FC = () => {
<TouchableOpacity
style={styles.drawerRow}
accessibilityRole="button"
testID={testIdWithKey('ConsultHelpCenter')}
onPress={() => {
deactivateSlider()
navigation.navigate(Stacks.HelpCenterStack, { screen: Screens.HelpCenter })
Expand Down
4 changes: 2 additions & 2 deletions app/src/navigators/AboutStack.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useTheme } from '@hyperledger/aries-bifold-core'
import { testIdWithKey, useTheme } from '@hyperledger/aries-bifold-core'
import { useDefaultStackOptions } from '@hyperledger/aries-bifold-core/App/navigators/defaultStackOptions'
import { createStackNavigator } from '@react-navigation/stack'
import React from 'react'
Expand All @@ -17,7 +17,7 @@ const AboutStack: React.FC = () => {
return (
<StackAbout.Navigator
initialRouteName={Screens.About}
screenOptions={{ ...defaultStackOptions, headerShown: true }}
screenOptions={{ ...defaultStackOptions, headerShown: true, headerBackTestID: testIdWithKey('Back') }}
>
<StackAbout.Screen
name={Screens.About}
Expand Down
4 changes: 2 additions & 2 deletions app/src/navigators/HelpCenterStack.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useTheme } from '@hyperledger/aries-bifold-core'
import { testIdWithKey, useTheme } from '@hyperledger/aries-bifold-core'
import { useDefaultStackOptions } from '@hyperledger/aries-bifold-core/App/navigators/defaultStackOptions'
import { createStackNavigator } from '@react-navigation/stack'
import React from 'react'
Expand All @@ -18,7 +18,7 @@ const HelpCenterStack: React.FC = () => {
return (
<StackHelp.Navigator
initialRouteName={Screens.HelpCenter}
screenOptions={{ ...defaultStackOptions, headerShown: true }}
screenOptions={{ ...defaultStackOptions, headerShown: true, headerBackTestID: testIdWithKey('Back') }}
>
<StackHelp.Screen
name={Screens.HelpCenter}
Expand Down
6 changes: 4 additions & 2 deletions app/src/navigators/HistoryStack.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useTheme } from '@hyperledger/aries-bifold-core'
import { testIdWithKey, useTheme } from '@hyperledger/aries-bifold-core'
import { useDefaultStackOptions } from '@hyperledger/aries-bifold-core/App/navigators/defaultStackOptions'
import { createStackNavigator } from '@react-navigation/stack'
import React from 'react'
Expand All @@ -19,7 +19,9 @@ const HistoryStack: React.FC = () => {
const { t } = useTranslation()

return (
<StackHistory.Navigator screenOptions={{ ...defaultStackOptions, headerShown: true }}>
<StackHistory.Navigator
screenOptions={{ ...defaultStackOptions, headerShown: true, headerBackTestID: testIdWithKey('Back') }}
>
<StackHistory.Screen
name={Screens.PinChangeDetails}
component={PinChangeDetails}
Expand Down
7 changes: 5 additions & 2 deletions app/src/navigators/SettingStack.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { TOKENS, useServices, useTheme } from '@hyperledger/aries-bifold-core'
import { testIdWithKey, TOKENS, useServices, useTheme } from '@hyperledger/aries-bifold-core'
import { useDefaultStackOptions } from '@hyperledger/aries-bifold-core/App/navigators/defaultStackOptions'
import PINCreate from '@hyperledger/aries-bifold-core/App/screens/PINCreate'
import { createStackNavigator } from '@react-navigation/stack'
Expand All @@ -20,7 +20,10 @@ const SettingsStack: React.FC = () => {
const { t } = useTranslation()

return (
<StackSettings.Navigator initialRouteName={Screens.Settings} screenOptions={{ ...defaultStackOptions }}>
<StackSettings.Navigator
initialRouteName={Screens.Settings}
screenOptions={{ ...defaultStackOptions, headerBackTestID: testIdWithKey('Back') }}
>
<StackSettings.Screen
name={Screens.Settings}
component={Settings}
Expand Down
87 changes: 87 additions & 0 deletions app/src/navigators/screen-options.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
import { DefaultScreenOptionsDictionary, Screens, testIdWithKey } from '@hyperledger/aries-bifold-core'
import { StackNavigationOptions } from '@react-navigation/stack'
import { Platform } from 'react-native'

import HelpCenterButton from '../components/Help/HelpCenterButton'

export const getScreenOptions = () => {
const defaultScreenOptionsDict = DefaultScreenOptionsDictionary

const onboardingScreenOptions: StackNavigationOptions = {
headerShown: Platform.OS == 'ios',
headerTitle: '',
headerStyle: {
height: 50,
},
}

defaultScreenOptionsDict[Screens.Home] = {
...defaultScreenOptionsDict[Screens.Home],
headerLeft: undefined,
headerRight: HelpCenterButton,
}
defaultScreenOptionsDict[Screens.Connection] = {
...defaultScreenOptionsDict[Screens.Connection],
headerLeft: undefined,
headerRight: HelpCenterButton,
}
defaultScreenOptionsDict[Screens.CredentialDetails] = {
...defaultScreenOptionsDict[Screens.CredentialDetails],
headerShown: true,
headerLeft: undefined,
headerRight: HelpCenterButton,
}

defaultScreenOptionsDict[Screens.OpenIDCredentialDetails] = {
...defaultScreenOptionsDict[Screens.OpenIDCredentialDetails],
headerShown: true,
headerLeft: undefined,
headerRight: HelpCenterButton,
}

defaultScreenOptionsDict[Screens.Credentials] = {
...defaultScreenOptionsDict[Screens.Credentials],
headerLeft: undefined,
headerRight: HelpCenterButton,
}
defaultScreenOptionsDict[Screens.Language] = {
...defaultScreenOptionsDict[Screens.Language],
headerRight: HelpCenterButton,
}
defaultScreenOptionsDict[Screens.Scan] = {
...defaultScreenOptionsDict[Screens.Scan],
headerRight: HelpCenterButton,
}

defaultScreenOptionsDict[Screens.UseBiometry] = {
...defaultScreenOptionsDict[Screens.UseBiometry],
...onboardingScreenOptions,
}

defaultScreenOptionsDict[Screens.CreatePIN] = {
...defaultScreenOptionsDict[Screens.CreatePIN],
...onboardingScreenOptions,
gestureEnabled: true,
}
defaultScreenOptionsDict[Screens.Terms] = {
...defaultScreenOptionsDict[Screens.Terms],
...onboardingScreenOptions,
}

defaultScreenOptionsDict[Screens.Contacts] = {
...defaultScreenOptionsDict[Screens.Contacts],
headerBackTestID: testIdWithKey('Back'),
}

defaultScreenOptionsDict[Screens.WhatAreContacts] = {
...defaultScreenOptionsDict[Screens.WhatAreContacts],
headerBackTestID: testIdWithKey('Back'),
}

defaultScreenOptionsDict[Screens.CredentialDetails] = {
...defaultScreenOptionsDict[Screens.CredentialDetails],
headerBackTestID: testIdWithKey('Back'),
}

return defaultScreenOptionsDict
}
4 changes: 3 additions & 1 deletion app/src/screens/activities/Activities.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useTheme } from '@hyperledger/aries-bifold-core'
import { testIdWithKey, useTheme } from '@hyperledger/aries-bifold-core'
import React, { useState } from 'react'
import { useTranslation } from 'react-i18next'
import { View, StyleSheet, TouchableOpacity, Text } from 'react-native'
Expand Down Expand Up @@ -62,6 +62,7 @@ const Activities: React.FC = () => {
<TouchableOpacity
accessibilityState={{ selected: activeTab === NotificationTab }}
accessibilityRole="tab"
testID={testIdWithKey('Activities.NotificationsTab')}
style={[styles.tab, activeTab === NotificationTab && styles.activeTab]}
onPress={() => setActiveTab(NotificationTab)}
>
Expand All @@ -75,6 +76,7 @@ const Activities: React.FC = () => {
<TouchableOpacity
accessibilityState={{ selected: activeTab === HistoryTab }}
accessibilityRole="tab"
testID={testIdWithKey('Activities.HistoryTab')}
style={[styles.tab, activeTab === HistoryTab && styles.activeTab]}
onPress={() => setActiveTab(HistoryTab)}
>
Expand Down

0 comments on commit a6791ad

Please sign in to comment.