Skip to content

Commit

Permalink
chore: move display text tests from detox to maestro (#801)
Browse files Browse the repository at this point in the history
  • Loading branch information
henninghall authored Apr 19, 2024
1 parent 77bded5 commit e28b24a
Show file tree
Hide file tree
Showing 13 changed files with 235 additions and 354 deletions.
95 changes: 66 additions & 29 deletions .maestro/display-text.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,61 +11,98 @@ tags:
STATE: ''

- runFlow: utils/launch.yml

# test: minuteInterval rounding should round with floor
- runFlow:
file: utils/change-prop.yml
env:
PROP: minuteInterval
VALUE: 5
- tapOn: change date
- runFlow:
file: utils/change-prop.yml
file: utils/change-prop-value.yml
env:
PROP: date
VALUE: '2000-01-01T00:34:00+01:00'
- runFlow: utils/swipe-wheel-1.yml
- assertVisible: '2000-01-02 00:30:00'

- runFlow: utils/reset.yml

# test: can have initial date in past
- tapOn: clear maximumDate
- tapOn: clear minimumDate
- tapOn: change date
- runFlow:
file: utils/change-prop.yml
env:
PROP: maximumDate
VALUE: undefined
- runFlow:
file: utils/change-prop.yml
env:
PROP: minimumDate
VALUE: undefined
- runFlow:
file: utils/change-prop.yml
file: utils/change-prop-value.yml
env:
PROP: date
VALUE: '1999-01-01'
- runFlow: utils/swipe-wheel-1.yml
- assertVisible: '1999-01-02 01:00:00'

- runFlow: utils/reset.yml

# test: display text
- runFlow:
file: utils/change-prop.yml
file: utils/change-locale-and-scroll.yml
env:
PROP: locale
VALUE: vi-VN
- runFlow: utils/swipe-wheel-1.yml
- assertVisible:
id: dateStringOutput
text: 'CN 2 thg 11200 SA '
LOCALE: en-US
EXPECT: 'Sun Jan 21200 AM '

- runFlow: utils/reset.yml

# test: display text - datetime
- runFlow:
file: utils/change-locale-and-scroll.yml
env:
LOCALE: vi-VN
EXPECT: 'CN 2 thg 11200 SA '

- runFlow:
file: utils/change-locale-and-scroll.yml
env:
LOCALE: pt-BR
EXPECT: 'dom. 2 de jan.1200 AM '

# Should be possible to use picker with invalid locale
- runFlow: utils/launch.yml
- runFlow:
file: utils/change-prop.yml
file: utils/change-locale-and-scroll.yml
env:
PROP: locale
VALUE: xx
- runFlow: utils/swipe-wheel-1.yml
- assertVisible: '2000-01-02 00:00:00'
LOCALE: xx
EXPECT: '2000-01-02 00:00:00'

# If more tests are needed on datetime locale:
# 'sv-SE', 'sön 2 jan.' + '1200 fm '
# 'ru-RU', 'вс 2 янв.' + '1200 AM '
# 'ko', '1월 2일 일 오전 1200'
# 'ja', '1月2日 日' + '1200 午前 '
# 'zh-CH', '1月2日周日 上午 1200'
# 'eu', 'urt. 2 ig.' + ' AM 1200'

# test: display text - date

- tapOn: date mode
- tapOn: clear minimumDate
- tapOn: clear maximumDate

- runFlow:
file: utils/change-locale-and-scroll.yml
env:
LOCALE: en-US
EXPECT: 'February12000'

- runFlow:
file: utils/change-locale-and-scroll.yml
env:
LOCALE: pt-BR
EXPECT: '2janeiro2000'

- runFlow:
file: utils/change-locale-and-scroll.yml
env:
LOCALE: zh-CH
EXPECT: '2001年一月1日'
#
# If more tests are needed for date locale:
# 'sv-SE', '2' + 'januari' + '2000'
# 'ko', '2001년' + '1월' + '1일'
# 'ja', '2001年' + '1月' + '1日'
# 'zh-CH', '2001年' + '一月' + '1日'
# 'eu', '2001' + 'urtarrila' + '1'
14 changes: 14 additions & 0 deletions .maestro/utils/change-locale-and-scroll.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
appId: com.android.settings
---
- tapOn: Clear
- tapOn: reset date
- tapOn: change locale
- tapOn:
id: propValue
- inputText: ${LOCALE}
- hideKeyboard
- tapOn: Change
- runFlow: swipe-wheel-1.yml
- assertVisible:
id: dateStringOutput|dateOutput
text: ${EXPECT}
9 changes: 9 additions & 0 deletions .maestro/utils/change-prop-value.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
appId: com.rn071
---
- tapOn: clear prop value
- tapOn:
id: propValue
- inputText: ${VALUE}
- hideKeyboard
- tapOn:
id: changeProp
3 changes: 1 addition & 2 deletions .maestro/utils/change-prop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ appId: com.rn071
- tapOn:
id: propValue
- inputText: ${VALUE}
- tapOn:
id: changeProp
- hideKeyboard
- tapOn:
id: changeProp
4 changes: 2 additions & 2 deletions .maestro/utils/swipe-wheel-1-down.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
appId: com.rn071
---
- swipe:
start: 25%, 40%
end: 25%, 32%
start: 35%, 40%
end: 35%, 32%
4 changes: 2 additions & 2 deletions .maestro/utils/swipe-wheel-1-up.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
appId: com.rn071
---
- swipe:
start: 38%, 32%
end: 38%, 40%
start: 35%, 32%
end: 35%, 40%
106 changes: 0 additions & 106 deletions examples/Rn069/e2e/tests/displayText.spec.js

This file was deleted.

9 changes: 3 additions & 6 deletions examples/Rn071/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ export default class App extends Component {
styles.container,
{backgroundColor: this.state.backgroundColor || 'white'},
]}
contentContainerStyle={styles.content}
>
contentContainerStyle={styles.content}>
<SafeAreaView>
<Text style={styles.header}>{!this.state.picker && 'Examples'}</Text>
{!this.state.picker && this.renderButtons()}
Expand Down Expand Up @@ -53,17 +52,15 @@ export default class App extends Component {
<TouchableOpacity
key={key}
onPress={() => this.setState({picker: key})}
style={{margin: 10}}
>
style={{margin: 10}}>
<Text style={styles.text}>{examples[key].buttonTitle}</Text>
</TouchableOpacity>
);

renderBackButton = key => (
<TouchableOpacity
onPress={() => this.setState({picker: undefined})}
style={{margin: 10, position: 'absolute', top: 30, left: 0}}
>
style={{margin: 10, position: 'absolute', top: 30, left: 0}}>
<Text style={styles.text}>Go back</Text>
</TouchableOpacity>
);
Expand Down
Loading

0 comments on commit e28b24a

Please sign in to comment.