Skip to content

Commit

Permalink
Merge pull request #138 from millicast/bug_fix/fix_automation_test_id
Browse files Browse the repository at this point in the history
Bug fix/fix automation test
  • Loading branch information
tarunkgarg authored Feb 26, 2024
2 parents 2782470 + 9587caa commit 0af7079
Show file tree
Hide file tree
Showing 13 changed files with 112 additions and 34 deletions.
1 change: 1 addition & 0 deletions src/components/BottomBar/BottomBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export const BottomBar = ({ displayStatsInformation, focus }) => {
return (
<View style={styles.wrapper}>
<TouchableOpacity
testID="infoIconButton"
hasTVPreferredFocus={focus}
onPress={() => {
displayStatsInformation();
Expand Down
10 changes: 5 additions & 5 deletions src/components/StreamDetail/StreamDetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,21 @@ export const StreamDetail = ({ stream, onPlay }: { stream: StreamInfo; onPlay: (
onPress={() => onPlay(stream)}
setParentFocus={setIsFocused}
underlayColor="none"
testID="StreamDetail"
testID={`streamDetail.${stream.streamName}`}
>
<View style={[styles.wrapper, isFocused ? styles.wrapperInFocus : {}]}>
<View style={styles.textWrapper}>
<Text type="bodyDefault" style={styles.streamNameText}>
<Text testID={stream.streamName} type="bodyDefault" style={styles.streamNameText}>
{stream.streamName}
</Text>
<View style={styles.accountIdTextWrapper}>
<Text id="accountIDLabel" type="bodyDefault" style={styles.accountIdText} />
<Text type="bodyDefault" color="secondary.200">
<Text testID="accountIDLabel" id="accountIDLabel" type="bodyDefault" style={styles.accountIdText} />
<Text testID={stream.accountId} type="bodyDefault" color="secondary.200">
{stream.accountId}
</Text>
</View>
</View>
<Icon backgroundColor="transparent" name="playOutline" size={iconSize} color={iconColor} />
<Icon testID="playOutline" backgroundColor="transparent" name="playOutline" size={iconSize} color={iconColor} />
</View>
</FocusedComponent>
);
Expand Down
1 change: 1 addition & 0 deletions src/components/StreamList/StreamList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export const StreamList = ({
}) => {
return (
<FlatList
testID="streamList"
style={styles.wrapper}
data={streams}
renderItem={({ item }) => <StreamDetail stream={item} onPlay={onPlayStream} />}
Expand Down
10 changes: 8 additions & 2 deletions src/components/StreamStats/StreamStats.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,21 +65,27 @@ export const StreamStats = ({ onPress }) => {
return (
<View style={Platform.isTV ? styles.outerContainerTV : styles.outerContainer}>
<View style={styles.closeIcon}>
<TouchableOpacity hasTVPreferredFocus onPress={onPress}>
<TouchableOpacity testID="closeIconButton" hasTVPreferredFocus onPress={onPress}>
<Icon testID="closeIcon" name="close" size="s" />
</TouchableOpacity>
</View>

<View style={styles.innerContainer}>
<Text
testID="streamInfoTitle"
id="streamInfoTitle"
type="h2"
align={Platform.isTV ? 'left' : 'center'}
style={{ paddingTop: 16, paddingLeft: 16 }}
/>
<View style={styles.streamInfoContainer}>
<StreamStatsRecord param="Name" paramType="h3" value="Value" valueType="h3" />
<FlatList data={statsRecordsList} keyExtractor={(item) => item.param} renderItem={renderItem} />
<FlatList
testID="streamStatsInfoView"
data={statsRecordsList}
keyExtractor={(item) => item.param}
renderItem={renderItem}
/>
</View>
</View>
</View>
Expand Down
8 changes: 6 additions & 2 deletions src/components/StreamStatsRecord/StreamStatsRecord.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,14 @@ export const StreamStatsRecord = ({ param, value, paramType, valueType }) => {
return (
<View style={styles.wrapper}>
<View style={styles.contentStyle}>
<Text type={paramType}>{param}</Text>
<Text testID={param} type={paramType}>
{param}
</Text>
</View>
<View style={styles.contentStyle}>
<Text type={valueType}>{value}</Text>
<Text testID={`${param} Value`} type={valueType}>
{value}
</Text>
</View>
</View>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import styles from './StreamStatusIndicator.style';

export const StreamStatusIndicator = ({ title, position }) => {
return (
<View style={[styles.container, position]}>
<Text>{title}</Text>
<View testID="streamStatusIndicator" style={[styles.container, position]}>
<Text testID={title}>{title}</Text>
</View>
);
};
2 changes: 1 addition & 1 deletion src/screens/Navigator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import UserInput from './userInput';
const Stack = createNativeStackNavigator();

const LogoTitle = () => {
return <Icon name="dolbyLogo" color="white" />;
return <Icon testID="dolbyLogo" name="dolbyLogo" color="white" />;
};

export const Navigator = () => {
Expand Down
4 changes: 4 additions & 0 deletions src/screens/multiview/MultiView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,7 @@ export const MultiView = ({ navigation }) => {
}}
>
<FlatList
testID="multiViewStreamList"
key={columnsNumber}
data={remoteTrackSourcesRef.current}
style={{
Expand All @@ -418,6 +419,7 @@ export const MultiView = ({ navigation }) => {
renderItem={({ item, index }) => (

Check warning on line 419 in src/screens/multiview/MultiView.tsx

View workflow job for this annotation

GitHub Actions / Run-Checks

'index' is defined but never used
<View style={margin}>
<Pressable
testID={`${!item.sourceId ? 'Main' : String(item.sourceId)}SourceButton`}
style={{ marginBottom: 15 }}
onPress={() => {
dispatch({
Expand All @@ -428,6 +430,7 @@ export const MultiView = ({ navigation }) => {
}}
>
<RTCView
testID={!item.sourceId ? 'Main' : String(item.sourceId)}
key={item?.mediaStream.toURL() || `${item?.videoMediaId}` || ''}
streamURL={item?.mediaStream.toURL()}
style={{
Expand All @@ -437,6 +440,7 @@ export const MultiView = ({ navigation }) => {
}}
/>
<Text
testID={!item.sourceId ? 'Main' : String(item.sourceId)}
style={{
padding: 1,
position: 'absolute',
Expand Down
32 changes: 27 additions & 5 deletions src/screens/recentStreams/RecentStreams.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,29 +77,51 @@ export const RecentStreams = ({ navigation }) => {
<Layout testID="RecentStreamsScreen">
<SafeAreaView style={styles.wrapper}>
<ScrollView>
<Text id="appTitle" type="h1" align="center" />
<Text testID="appTitle" id="appTitle" type="h1" align="center" />
<Text
testID="recentStreamsInfoText"
id="recentStreamsInfoText"
color="secondary.200"
type="bodyDefault"
align="center"
style={styles.recentStreamsInfoText}
/>
<View style={styles.streamListHeaderWrapper}>
<Text id="recentlyViewedText" type="bodyDefault" style={styles.recentlyViewedText} />
<Text
testID="recentlyViewedText"
id="recentlyViewedText"
type="bodyDefault"
style={styles.recentlyViewedText}
/>
<FocusedComponent
name="viewAll"
onPress={handleViewAllClick}
underlayColor="none"
testID="viewAllButton"
setParentFocus={setIsFocused}
>
<Text id="viewAllButtonText" type={viewAllButtonTextType} color={viewAllButtonColor} />
<Text
testID="viewAllButtonText"
id="viewAllButtonText"
type={viewAllButtonTextType}
color={viewAllButtonColor}
/>
</FocusedComponent>
</View>
<StreamList streams={streamsList.slice(0, 3)} onPlayStream={handlePlayStreamClick} />
<Text id="alternateOptionText" type="paragraph" align="center" style={styles.alternateOptionText} />
<Button title={playNewStreamTitle} type="primary" onPress={handlePlayNewStreamClick} />
<Text
testID="alternateOptionText"
id="alternateOptionText"
type="paragraph"
align="center"
style={styles.alternateOptionText}
/>
<Button
testID="playNewStreamTitle"
title={playNewStreamTitle}
type="primary"
onPress={handlePlayNewStreamClick}
/>
</ScrollView>
</SafeAreaView>
<WelcomeFooter />
Expand Down
35 changes: 28 additions & 7 deletions src/screens/savedStreams/SavedStreams.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export const SavedStreams = ({ navigation }) => {
headerTitle: savedStreamsHeaderText,
headerRight: () =>
streamsList.length > 0 && (
<FocusedComponent onPress={clearSavedStreamsAlert} setParentFocus={setIsFocused}>
<FocusedComponent testID="trashIconButton" onPress={clearSavedStreamsAlert} setParentFocus={setIsFocused}>
<Icon testID="trashIcon" name="trash" size={defaultIconSize} color={iconColor} />
</FocusedComponent>
),
Expand All @@ -90,10 +90,10 @@ export const SavedStreams = ({ navigation }) => {
{Platform.isTV && (
<View style={styles.headerViewWrapperTV}>
<View style={{ flex: 1, alignItems: 'center' }}>
<Text id="savedStreamsHeaderText" type="H2" />
<Text testID="savedStreamsHeaderText" id="savedStreamsHeaderText" type="H2" />
</View>
{streamsList.length > 0 && (
<FocusedComponent onPress={clearSavedStreamsAlert} setParentFocus={setIsFocused}>
<FocusedComponent testID="trashIconButton" onPress={clearSavedStreamsAlert} setParentFocus={setIsFocused}>
<Icon testID="trashIcon" name="trash" size={defaultIconSize} color={iconColor} />
</FocusedComponent>
)}
Expand All @@ -102,18 +102,39 @@ export const SavedStreams = ({ navigation }) => {
{streamsList.length > 0 ? (
<ScrollView>
<View style={styles.streamListSectionHeaderWrapper}>
<Text id="lastPlayedStreamText" type="bodyDefault" style={styles.streamListSectionHeaderText} />
<Text
testID="lastPlayedStreamText"
id="lastPlayedStreamText"
type="bodyDefault"
style={styles.streamListSectionHeaderText}
/>
</View>
<StreamList streams={streamsList.slice(0, 1)} onPlayStream={handlePlayStream} />
<View style={styles.streamListSectionHeaderWrapper}>
<Text id="allStreamsText" type="bodyDefault" style={styles.streamListSectionHeaderText} />
<Text
testID="allStreamsText"
id="allStreamsText"
type="bodyDefault"
style={styles.streamListSectionHeaderText}
/>
</View>
<StreamList streams={streamsList} onPlayStream={handlePlayStream} />
</ScrollView>
) : (
<View style={styles.noStreamsMessageWrapper}>
<Text id="noSavedStreamsTitleText" type="h2" align="center" numberOfLines={2} />
<Text id="noSavedStreamssubtitleText" type="bodyDefault" color="secondary.200" />
<Text
testID="noSavedStreamsTitleText"
id="noSavedStreamsTitleText"
type="h2"
align="center"
numberOfLines={2}
/>
<Text
testID="noSavedStreamssubtitleText"
id="noSavedStreamssubtitleText"
type="bodyDefault"
color="secondary.200"
/>
</View>
)}
</SafeAreaView>
Expand Down
1 change: 1 addition & 0 deletions src/screens/singleStreamView/SingleStreamView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ export const SingleStreamView = ({ navigation }) => {
const renderVideoItem = ({item}) => (
<View style={[styles.videoContainer, { width: width, height: height }]}>
<RTCView
testID={!item.sourceId ? 'Main' : String(item.sourceId)}
key={item.video}
streamURL={item.mediaStream.toURL()}
style={styles.video}
Expand Down
26 changes: 19 additions & 7 deletions src/screens/userInput/UserInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export const UserInput = ({ navigation }) => {
const validateInput = (value: string) => {
const valid = value.length >= MINIMUM_INPUT_LENGTH;
setValidation(
value.length && value.length >= MINIMUM_INPUT_LENGTH
value.length && value.length < MINIMUM_INPUT_LENGTH
? {
valid,
message: valid ? undefined : intl.formatMessage({ id: 'enterValidInputMessage' }),
Expand Down Expand Up @@ -116,9 +116,10 @@ export const UserInput = ({ navigation }) => {
<Layout testID="UserInputScreen">
<SafeAreaView style={styles.wrapper}>
<ScrollView>
<Text id="appTitle" type="h2" align="center" style={{ paddingTop: 16 }} />
<Text id="startStream" type="h3" align="center" style={{ paddingTop: 24 }} />
<Text testID="appTitle" id="appTitle" type="h2" align="center" style={{ paddingTop: 16 }} />
<Text testID="startStream" id="startStream" type="h3" align="center" style={{ paddingTop: 24 }} />
<Text
testID="startStreamLabel"
id="startStreamLabel"
type="paragraph"
align="center"
Expand Down Expand Up @@ -159,8 +160,15 @@ export const UserInput = ({ navigation }) => {
disabled={playDisabled(validation, streamName, accountId)}
testID="PlayButton"
/>
<Text id="demoTitle" type="h2" align="center" style={{ paddingTop: 48 }} />
<Text id="demoLabel" type="paragraph" align="center" style={{ paddingTop: 8 }} color="grey.500" />
<Text testID="demoTitle" id="demoTitle" type="h2" align="center" style={{ paddingTop: 48 }} />
<Text
testID="demoLabel"
id="demoLabel"
type="paragraph"
align="center"
style={{ paddingTop: 8 }}
color="grey.500"
/>
<View style={{ paddingTop: 16 }} />
<FocusedComponent
onPress={handleDemoPlayClick}
Expand All @@ -170,8 +178,12 @@ export const UserInput = ({ navigation }) => {
testID="DemoButtonFocusElement"
>
<>
<Text id="playDemoStream" type="paragraph" />
<Icon name="playOutline" color={isDemoButtonFocused ? 'white' : defaultDemoButtonIconColor} />
<Text testID="playDemoStream" id="playDemoStream" type="paragraph" />
<Icon
testID="playOutline"
name="playOutline"
color={isDemoButtonFocused ? 'white' : defaultDemoButtonIconColor}
/>
</>
</FocusedComponent>
</ScrollView>
Expand Down
12 changes: 9 additions & 3 deletions src/uikit/components/Input/Input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ const Input = ({

return (
<View testID={testID} style={styles.container}>
<View style={[styles.labelContainer, { backgroundColor: labelBackground }]}>
<Text type="captionRegular" color={getColor(labelColor, 'grey.500')}>
<View testID={label} style={[styles.labelContainer, { backgroundColor: labelBackground }]}>
<Text testID={label} type="captionRegular" color={getColor(labelColor, 'grey.500')}>
{label}
</Text>
</View>
Expand All @@ -81,6 +81,7 @@ const Input = ({
]}
>
<TextInput
testID={testID}
ref={textInput}
value={value}
onChangeText={onChangeText}
Expand All @@ -99,6 +100,7 @@ const Input = ({
{value.length > 0 && !Platform.isTV && (
<View style={styles.buttonContainer}>
<IconButton
testID="closeIconButton"
variant="circle"
icon="close"
backgroundColor="transparent"
Expand All @@ -114,7 +116,11 @@ const Input = ({

{validation?.message && (
<View style={styles.errorContainer}>
<Text type="captionRegular" color={validation?.valid === false ? 'infoError' : 'grey.600'}>
<Text
testID="invalidInputText"
type="captionRegular"
color={validation?.valid === false ? 'infoError' : 'grey.600'}
>
{validation.message}
</Text>
</View>
Expand Down

0 comments on commit 0af7079

Please sign in to comment.