Skip to content

Commit

Permalink
fix(INJI-337)testID for home screen and settings screen (mosip#805)
Browse files Browse the repository at this point in the history
* fix(INJI-337)testID for home screen and settings screen

* fix(INJI-337)testID for home screen and settings screen

* feat(INJI-337): refactor testID for home screen and settings screen

* feat(INJI-337): refactor testID for home screen and settings screen

* feat(INJI-337): refactor testID for home screen and settings screen

Signed-off-by: Tilak Puli <[email protected]>
  • Loading branch information
srikanth716 authored and tilak-puli committed Oct 11, 2023
1 parent bdf2782 commit 509d6fd
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 9 deletions.
2 changes: 2 additions & 0 deletions components/HelpScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export const HelpScreen: React.FC<HelpScreenProps & MainRouteProps> = (
{props.triggerComponent}
</Pressable>
<Modal
testID="helpScreen"
isVisible={showHelpPage}
headerTitle={t('header')}
headerElevation={2}
Expand Down Expand Up @@ -75,5 +76,6 @@ export const HelpScreen: React.FC<HelpScreenProps & MainRouteProps> = (
};

interface HelpScreenProps {
testID?: string;
triggerComponent: React.ReactElement;
}
1 change: 1 addition & 0 deletions components/LanguageSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export const LanguageSelector: React.FC<LanguageSelectorProps> = (props) => {
return (
<View>
<Picker
testID="language"
items={languages}
selectedValue={i18n.language}
onValueChange={changeLanguage}
Expand Down
7 changes: 6 additions & 1 deletion components/ui/Modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@ import { Column, Row, Text } from '.';
import { useSendVcScreen } from '../../screens/Scan/SendVcScreenController';
import { DeviceInfoList } from '../DeviceInfoList';
import { ElevationLevel, Theme } from './styleUtils';
import testIDProps from '../../shared/commonUtil';

export const Modal: React.FC<ModalProps> = (props) => {
const controller = useSendVcScreen();

return (
<RNModal
{...testIDProps(props.testID)}
animationType="slide"
style={Theme.ModalStyles.modal}
visible={props.isVisible}
Expand All @@ -35,6 +37,7 @@ export const Modal: React.FC<ModalProps> = (props) => {
) : null}
{props.arrowLeft ? (
<Icon
{...testIDProps('arrowLeft')}
name="arrow-left"
type="material-community"
onPress={props.onDismiss}
Expand All @@ -47,7 +50,7 @@ export const Modal: React.FC<ModalProps> = (props) => {
align={props.headerLeft ? 'flex-start' : 'center'}
margin={'16 0 0 0'}>
<Column>
<Text style={Theme.TextStyles.header}>
<Text testID={props.testID} style={Theme.TextStyles.header}>
{props.headerTitle || props.headerLeft}
</Text>
{!props.requester ? (
Expand All @@ -73,6 +76,7 @@ export const Modal: React.FC<ModalProps> = (props) => {
</Row>
{props.headerRight || props.arrowLeft || (
<Icon
{...testIDProps('close')}
name="close"
onPress={props.onDismiss}
color={Theme.Colors.Details}
Expand All @@ -88,6 +92,7 @@ export const Modal: React.FC<ModalProps> = (props) => {
};

export interface ModalProps {
testID?: string;
isVisible: boolean;
requester?: boolean;
onDismiss?: () => void;
Expand Down
1 change: 1 addition & 0 deletions screens/Home/MyVcsTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ export const MyVcsTab: React.FC<HomeScreenTabProps> = (props) => {
<Column fill style={Theme.Styles.homeScreenContainer}>
<Image source={Theme.DigitalIdentityLogo} />
<Text
testID="bringYourDigitalID"
align="center"
weight="bold"
margin="33 0 6 0"
Expand Down
4 changes: 4 additions & 0 deletions screens/MainLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { HelpScreen } from '../components/HelpScreen';

import { GlobalContext } from '../shared/GlobalContext';
import { ScanEvents } from '../machines/bleShare/scan/scanMachine';
import testIDProps from '../shared/commonUtil';
const { Navigator, Screen } = createBottomTabNavigator();

export const MainLayout: React.FC<RootRouteProps & RequestRouteProps> = (
Expand All @@ -30,6 +31,7 @@ export const MainLayout: React.FC<RootRouteProps & RequestRouteProps> = (
<HelpScreen
triggerComponent={
<Image
{...testIDProps('help')}
source={require('../assets/help-icon.png')}
style={{ width: 36, height: 36 }}
/>
Expand All @@ -41,6 +43,7 @@ export const MainLayout: React.FC<RootRouteProps & RequestRouteProps> = (
<SettingScreen
triggerComponent={
<Icon
{...testIDProps('settings')}
name="settings"
type="simple-line-icon"
size={21}
Expand Down Expand Up @@ -95,6 +98,7 @@ export const MainLayout: React.FC<RootRouteProps & RequestRouteProps> = (
title: t(route.name),
tabBarIcon: ({ focused }) => (
<Icon
{...testIDProps(route.name)}
name={route.icon}
color={focused ? Theme.Colors.Icon : Theme.Colors.GrayIcon}
style={focused ? Theme.Styles.bottomTabIconStyle : null}
Expand Down
2 changes: 1 addition & 1 deletion screens/Settings/AboutInji.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export const AboutInji: React.FC<AboutInjiProps> = ({ appId }) => {
onPress={() => {
setShowAboutInji(!showAboutInji);
}}>
<ListItem topDivider bottomDivider>
<ListItem testID="aboutInji" topDivider bottomDivider>
<Icon
type={'feather'}
name={'file'}
Expand Down
15 changes: 12 additions & 3 deletions screens/Settings/ReceivedCards.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ export const ReceivedCards: React.FC = () => {
return (
<React.Fragment>
<Pressable onPress={controller.TOGGLE_RECEIVED_CARDS}>
<Column style={Theme.Styles.receiveCardsContainer}>
<Column
testID="receivedCards"
style={Theme.Styles.receiveCardsContainer}>
<Image
source={Theme.ReceivedCardsIcon}
style={{ marginLeft: 10, marginRight: 9 }}
Expand Down Expand Up @@ -61,10 +63,17 @@ export const ReceivedCards: React.FC = () => {
size={40}
name="sentiment-dissatisfied"
/>
<Text align="center" weight="semibold" margin="0 0 4 0">
<Text
testID="noReceivedVcsTitle"
align="center"
weight="semibold"
margin="0 0 4 0">
{t('noReceivedVcsTitle')}
</Text>
<Text align="center" color={Theme.Colors.textLabel}>
<Text
testID="noReceivedVcsText"
align="center"
color={Theme.Colors.textLabel}>
{t('noReceivedVcsText')}
</Text>
</Centered>
Expand Down
20 changes: 16 additions & 4 deletions screens/Settings/SettingScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,15 @@ import { AboutInji } from './AboutInji';
import { EditableListItem } from '../../components/EditableListItem';
import { RequestRouteProps, RootRouteProps } from '../../routes';
import { ReceivedCards } from './ReceivedCards';
import testIDProps from '../../shared/commonUtil';

const LanguageSetting: React.FC = () => {
const { t } = useTranslation('SettingScreen');

return (
<LanguageSelector
triggerComponent={
<ListItem>
<ListItem testID="language">
<Icon
name="globe"
size={22}
Expand Down Expand Up @@ -59,6 +60,7 @@ export const SettingScreen: React.FC<
{props.triggerComponent}
</Pressable>
<Modal
testID="settingsScreen"
isVisible={controller.isVisible}
arrowLeft={<Icon name={''} />}
headerTitle={t('header')}
Expand All @@ -69,6 +71,7 @@ export const SettingScreen: React.FC<
style={{ display: Platform.OS !== 'ios' ? 'flex' : 'none' }}
backgroundColor={Theme.Colors.lightGreyBackgroundColor}>
<Text
testID="injiAsVerifierApp"
weight="semibold"
margin="10"
color={Theme.Colors.aboutVersion}>
Expand All @@ -78,7 +81,9 @@ export const SettingScreen: React.FC<
align="space-evenly"
backgroundColor={Theme.Colors.whiteBackgroundColor}>
<Pressable onPress={controller.RECEIVE_CARD}>
<Column style={Theme.Styles.receiveCardsContainer}>
<Column
testID="receiveCard"
style={Theme.Styles.receiveCardsContainer}>
<Image
source={Theme.ReceiveCardIcon}
style={{ alignSelf: 'center' }}
Expand All @@ -88,6 +93,7 @@ export const SettingScreen: React.FC<
</Text>
</Column>
</Pressable>

<ReceivedCards />
</Row>

Expand All @@ -107,7 +113,10 @@ export const SettingScreen: React.FC<

<LanguageSetting />

<ListItem topDivider disabled={!controller.canUseBiometrics}>
<ListItem
{...testIDProps('bioUnlock')}
topDivider
disabled={!controller.canUseBiometrics}>
<Icon
type={'MaterialCommunityIcons'}
name={'fingerprint'}
Expand Down Expand Up @@ -154,6 +163,7 @@ export const SettingScreen: React.FC<
)}

<ListItem
{...testIDProps('injiTourGuide')}
topDivider
bottomDivider
onPress={() => controller.INJI_TOUR_GUIDE()}>
Expand All @@ -173,7 +183,7 @@ export const SettingScreen: React.FC<
</ListItem.Content>
</ListItem>

<ListItem onPress={controller.LOGOUT}>
<ListItem {...testIDProps('logout')} onPress={controller.LOGOUT}>
<Icon
name="logout"
type="fontawesome"
Expand All @@ -189,6 +199,7 @@ export const SettingScreen: React.FC<
</ListItem.Title>
</ListItem.Content>
</ListItem>

{controller.backendInfo.application.name !== '' ? (
<View>
<Text
Expand Down Expand Up @@ -216,5 +227,6 @@ export const SettingScreen: React.FC<
};

interface SettingProps {
testID?: string;
triggerComponent: React.ReactElement;
}

0 comments on commit 509d6fd

Please sign in to comment.