Browse Source

chore: move some detox tests to mastro (#642)

master
Henning Hall 2 years ago
committed by GitHub
parent
commit
563b930982
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
21 changed files with 221 additions and 167 deletions
  1. +2
    -0
      .maestro/display-text.yml
  2. +120
    -0
      .maestro/timezone-offset-in-minutes.yml
  3. +1
    -0
      .maestro/utils/change-prop.yml
  4. +4
    -0
      .maestro/utils/disable-network-time-zone.yml
  5. +7
    -0
      .maestro/utils/goto-settings-from-app-info.yml
  6. +0
    -2
      .maestro/utils/launch.yml
  7. +4
    -0
      .maestro/utils/reset.yml
  8. +4
    -0
      .maestro/utils/select-region.yml
  9. +7
    -0
      .maestro/utils/select-utc-offset.yml
  10. +8
    -0
      .maestro/utils/set-timezone-us.yml
  11. +32
    -0
      .maestro/utils/set-timezone.yml
  12. +5
    -0
      .maestro/utils/swipe-wheel-3.yml
  13. +0
    -0
      .maestro/utils/swipe-wheel-4.yml
  14. +8
    -0
      .maestro/utils/tap-if-visible.yml
  15. +3
    -0
      .maestro/utils/tap.yml
  16. +1
    -0
      .npmignore
  17. +0
    -82
      examples/Rn069/e2e/tests/timezoneOffset.spec.js
  18. +2
    -2
      examples/Rn069/src/App.js
  19. +9
    -0
      examples/Rn069/src/CustomPropValue.js
  20. +0
    -81
      examples/detox/e2e/tests/timezoneOffset.spec.js
  21. +4
    -0
      package.json

+ 2
- 0
.maestro/display-text.yml View File

@ -1,6 +1,8 @@
appId: com.rn069
---
- runFlow: utils/launch.yml
- tapOn: androidVariant
- tapOn: nativeAndroid
- runFlow:
file: utils/change-prop.yml
env:

+ 120
- 0
.maestro/timezone-offset-in-minutes.yml View File

@ -0,0 +1,120 @@
appId: com.rn069
---
- runFlow:
file: utils/set-timezone.yml
env:
TIMEZONE: Sweden
GMT: GMT+01:00
- runFlow: utils/launch.yml
# test: timezone offset with undefined
- runFlow: utils/swipe-wheel-3.yml
- assertVisible: '2000-01-01 00:01:00'
- assertVisible: 'Sat Jan 11201 AM '
- runFlow: utils/reset.yml
# test: timezone offset with 0
- runFlow:
file: utils/change-prop.yml
env:
PROP: timeZoneOffsetInMinutes
VALUE: 0
- runFlow: utils/swipe-wheel-3.yml
- assertVisible: '2000-01-01 00:01:00'
- assertVisible: 'Fri Dec 311101 PM '
- runFlow: utils/reset.yml
# test: timezone offset with 180
- runFlow:
file: utils/change-prop.yml
env:
PROP: timeZoneOffsetInMinutes
VALUE: 180
- runFlow: utils/swipe-wheel-3.yml
- assertVisible: '2000-01-01 00:01:00'
- assertVisible: 'Sat Jan 1201 AM '
- runFlow: utils/reset.yml
# test: timezone offset with -180
- runFlow:
file: utils/change-prop.yml
env:
PROP: timeZoneOffsetInMinutes
VALUE: -180
- runFlow: utils/swipe-wheel-3.yml
- assertVisible: '2000-01-01 00:01:00'
- assertVisible: 'Fri Dec 31801 PM '
########## describe: DAYLIGHT SAVING
- runFlow:
file: utils/set-timezone.yml
env:
TIMEZONE: Sweden
GMT: GMT+02:00
- runFlow: utils/launch.yml
# test: timezone offset undefined
- runFlow:
file: utils/change-prop.yml
env:
PROP: maximumDate
VALUE: '2000-07-01T00:00:00'
- runFlow:
file: utils/change-prop.yml
env:
PROP: date
VALUE: '2000-06-01T00:00:00+02:00'
- runFlow: utils/swipe-wheel-3.yml
- assertVisible: '2000-06-01 00:01:00'
- assertVisible: 'Thu Jun 11201 AM '
- runFlow: utils/reset.yml
# # test: timezone offset 0
- runFlow:
file: utils/change-prop.yml
env:
PROP: maximumDate
VALUE: '2000-07-01T00:00:00'
- runFlow:
file: utils/change-prop.yml
env:
PROP: date
VALUE: '2000-06-01T00:00:00+02:00'
- runFlow:
file: utils/change-prop.yml
env:
PROP: timeZoneOffsetInMinutes
VALUE: 0
- runFlow: utils/swipe-wheel-3.yml
- assertVisible: '2000-06-01 00:01:00'
- assertVisible: 'Wed May 311001 PM '
- runFlow: utils/reset.yml
# test: timezone offset 180
- runFlow:
file: utils/change-prop.yml
env:
PROP: maximumDate
VALUE: '2000-07-01T00:00:00'
- runFlow:
file: utils/change-prop.yml
env:
PROP: date
VALUE: '2000-06-01T00:00:00+02:00'
- runFlow:
file: utils/change-prop.yml
env:
PROP: timeZoneOffsetInMinutes
VALUE: 180
- runFlow: utils/swipe-wheel-3.yml
- assertVisible: '2000-06-01 00:01:00'
- assertVisible: 'Thu Jun 1101 AM '
- runFlow: utils/reset.yml

+ 1
- 0
.maestro/utils/change-prop.yml View File

@ -1,5 +1,6 @@
appId: com.rn069
---
- tapOn: clear
- tapOn:
id: propName
- inputText: ${PROP}

+ 4
- 0
.maestro/utils/disable-network-time-zone.yml View File

@ -0,0 +1,4 @@
appId: com.android.settings
---
- tapOn: 'Use network-provided time zone'
- tapOn: 'Time zone'

+ 7
- 0
.maestro/utils/goto-settings-from-app-info.yml View File

@ -0,0 +1,7 @@
appId: com.android.settings
---
- scrollUntilVisible:
element:
text: 'Settings'
- tapOn: 'Settings'
- tapOn: 'Open'

+ 0
- 2
.maestro/utils/launch.yml View File

@ -3,5 +3,3 @@ appId: com.rn069
- launchApp:
stopApp: true
- tapOn: Advanced
- tapOn: androidVariant
- tapOn: nativeAndroid

+ 4
- 0
.maestro/utils/reset.yml View File

@ -0,0 +1,4 @@
appId: com.rn069
---
- tapOn: 'Go back'
- tapOn: Advanced

+ 4
- 0
.maestro/utils/select-region.yml View File

@ -0,0 +1,4 @@
appId: com.android.settings
---
- tapOn: Region
- inputText: ${TIMEZONE}

+ 7
- 0
.maestro/utils/select-utc-offset.yml View File

@ -0,0 +1,7 @@
appId: com.android.settings
---
- tapOn: 'Select UTC offset'
- scrollUntilVisible:
element:
text: ${GMT}
- tapOn: ${GMT}

+ 8
- 0
.maestro/utils/set-timezone-us.yml View File

@ -0,0 +1,8 @@
appId: com.android.settings
---
- runFlow:
file: set-timezone.yml
env:
TIMEZONE: 'United states'
GMT: ${GMT}
- tapOn: ${STATE}

+ 32
- 0
.maestro/utils/set-timezone.yml View File

@ -0,0 +1,32 @@
appId: com.android.settings
---
- launchApp
- runFlow:
when:
visible: 'App info'
file: goto-settings-from-app-info.yml
- tapOn: 'Search settings'
- inputText: 'Date'
- tapOn: 'Date & time'
- tapOn: 'Date & time'
- tapOn: 'Time zone'
- runFlow:
when:
notVisible: 'Select time zone'
file: disable-network-time-zone.yml
# on some devices (maestro cloud) "Select UTC offset" is displayed instead of Region
- runFlow:
when:
visible: 'Select UTC offset'
file: select-utc-offset.yml
env:
GMT: ${GMT}
# on most(?) devices timezone is selected by picking region
- runFlow:
when:
visible: Region
file: select-region.yml
env:
TIMEZONE: ${TIMEZONE}

+ 5
- 0
.maestro/utils/swipe-wheel-3.yml View File

@ -0,0 +1,5 @@
appId: com.rn069
---
- swipe:
start: 63%, 40%
end: 63%, 35%

.maestro/utils/swipe-wheel-am-pm.yml → .maestro/utils/swipe-wheel-4.yml View File


+ 8
- 0
.maestro/utils/tap-if-visible.yml View File

@ -0,0 +1,8 @@
appId: com.android.settings
---
- runFlow:
when:
visible: ${TEXT}
file: tap.yml
env:
TEXT: ${TEXT}

+ 3
- 0
.maestro/utils/tap.yml View File

@ -0,0 +1,3 @@
appId: com.android.settings
---
- tapOn: ${TEXT}

+ 1
- 0
.npmignore View File

@ -6,3 +6,4 @@ examples
githubREADME.md
.gitignore
scripts
.maestro

+ 0
- 82
examples/Rn069/e2e/tests/timezoneOffset.spec.js View File

@ -1,82 +0,0 @@
const {
setTimeZoneOffsetInMinutes,
expectDate,
scrollWheel,
expectDateString,
setMaximumDate,
setDate,
init,
} = require('../utils');
const scrollMinuteWheel = () => scrollWheel(2, 1);
// I haven't found a way to change the timezone on the emulator to be able to run these tests.
// Until possible, run these tests locally when needed with Europe/Stockholm timezone.
describe.skip('Timezone offset', () => {
beforeAll(async () => {
await init();
await element(by.text('Advanced')).tap();
});
it('undefined (default)', async () => {
await setTimeZoneOffsetInMinutes(undefined);
await scrollMinuteWheel();
await expectDate('2000-01-01 00:01:00');
await expectDateString('Sat Jan 11201 AM ');
});
it('0', async () => {
await setTimeZoneOffsetInMinutes(0);
await scrollMinuteWheel();
await expectDate('2000-01-01 00:01:00');
await expectDateString('Fri Dec 311101 PM ');
});
it('180', async () => {
await setTimeZoneOffsetInMinutes(180);
await scrollMinuteWheel();
await expectDate('2000-01-01 00:01:00');
await expectDateString('Sat Jan 1201 AM ');
});
it('-180', async () => {
await setTimeZoneOffsetInMinutes(-180);
await scrollMinuteWheel();
await expectDate('2000-01-01 00:01:00');
await expectDateString('Fri Dec 31801 PM ');
});
describe('daylight saving', () => {
const firstOfJuly = new Date(2000, 6, 1, 0, 0);
const firstOfJune = new Date(2000, 5, 1, 0, 0);
beforeAll(async () => {
await setMaximumDate(firstOfJuly);
await setDate(firstOfJune);
});
it('undefined', async () => {
await setDate(firstOfJune);
await setTimeZoneOffsetInMinutes(undefined);
await scrollMinuteWheel();
await expectDate('2000-06-01 00:01:00');
await expectDateString('Thu Jun 11201 AM ');
});
it('0', async () => {
await setDate(firstOfJune);
await setTimeZoneOffsetInMinutes(0);
await scrollMinuteWheel();
await expectDate('2000-06-01 00:01:00');
await expectDateString('Wed May 311001 PM ');
});
it('180', async () => {
await setDate(firstOfJune);
await setTimeZoneOffsetInMinutes(180);
await scrollMinuteWheel();
await expectDate('2000-06-01 00:01:00');
await expectDateString('Thu Jun 1101 AM ');
});
});
});

+ 2
- 2
examples/Rn069/src/App.js View File

@ -18,7 +18,7 @@ export default class App extends Component {
<ScrollView
style={[
styles.container,
{backgroundColor: this.state.backgroundColor},
{backgroundColor: this.state.backgroundColor || 'white'},
]}
contentContainerStyle={styles.content}
>
@ -64,7 +64,7 @@ export default class App extends Component {
onPress={() => this.setState({picker: undefined})}
style={{margin: 10, position: 'absolute', top: 30, left: 0}}
>
<Text style={styles.text}>Back</Text>
<Text style={styles.text}>Go back</Text>
</TouchableOpacity>
);
}

+ 9
- 0
examples/Rn069/src/CustomPropValue.js View File

@ -35,6 +35,15 @@ export default function CustomPropValue(props) {
testID={"changeProp"}
onPress={() => props.changeProp({ propName, propValue: getPropValue() })}
><Text style={{ color: "blue" }}>Change</Text></TouchableOpacity>
<View style={{width: 20}}/>
<TouchableOpacity
onPress={() => {
setPropName('');
setPropValue('');
}}
>
<Text style={{color: 'blue'}}>Clear</Text>
</TouchableOpacity>
</View>
)
}

+ 0
- 81
examples/detox/e2e/tests/timezoneOffset.spec.js View File

@ -1,81 +0,0 @@
const {
setTimeZoneOffsetInMinutes,
expectDate,
scrollWheel,
expectDateString,
setMaximumDate,
setDate,
} = require('../utils')
const scrollMinuteWheel = () => scrollWheel(2, 1)
// I haven't found a way to change the timezone on the emulator to be able to run these tests.
// Until possible, run these tests locally when needed with Europe/Stockholm timezone.
describe.skip('Timezone offset', () => {
before(async () => {
await device.reloadReactNative()
await element(by.text('Advanced')).tap()
})
it('undefined (default)', async () => {
await setTimeZoneOffsetInMinutes(undefined)
await scrollMinuteWheel()
await expectDate('2000-01-01 00:01:00')
await expectDateString('Sat Jan 11201 AM ')
})
it('0', async () => {
await setTimeZoneOffsetInMinutes(0)
await scrollMinuteWheel()
await expectDate('2000-01-01 00:01:00')
await expectDateString('Fri Dec 311101 PM ')
})
it('180', async () => {
await setTimeZoneOffsetInMinutes(180)
await scrollMinuteWheel()
await expectDate('2000-01-01 00:01:00')
await expectDateString('Sat Jan 1201 AM ')
})
it('-180', async () => {
await setTimeZoneOffsetInMinutes(-180)
await scrollMinuteWheel()
await expectDate('2000-01-01 00:01:00')
await expectDateString('Fri Dec 31801 PM ')
})
describe('daylight saving', () => {
const firstOfJuly = new Date(2000, 6, 1, 0, 0)
const firstOfJune = new Date(2000, 5, 1, 0, 0)
before(async () => {
await setMaximumDate(firstOfJuly)
await setDate(firstOfJune)
})
it('undefined', async () => {
await setDate(firstOfJune)
await setTimeZoneOffsetInMinutes(undefined)
await scrollMinuteWheel()
await expectDate('2000-06-01 00:01:00')
await expectDateString('Thu Jun 11201 AM ')
})
it('0', async () => {
await setDate(firstOfJune)
await setTimeZoneOffsetInMinutes(0)
await scrollMinuteWheel()
await expectDate('2000-06-01 00:01:00')
await expectDateString('Wed May 311001 PM ')
})
it('180', async () => {
await setDate(firstOfJune)
await setTimeZoneOffsetInMinutes(180)
await scrollMinuteWheel()
await expectDate('2000-06-01 00:01:00')
await expectDateString('Thu Jun 1101 AM ')
})
})
})

+ 4
- 0
package.json View File

@ -9,6 +9,10 @@
"prepublishOnly": "mv README.md githubREADME.md && mv npmREADME.md README.md",
"postpublish": "mv README.md npmREADME.md && mv githubREADME.md README.md",
"test": "jest src",
"install:release": "adb install examples/Rn069/android/app/build/outputs/apk/release/app-release.apk",
"install:debug": "adb install examples/Rn069/android/app/build/outputs/apk/debug/app-debug.apk",
"build:release": "(cd examples/Rn069/android && ./gradlew assembleRelease) && yarn install:release",
"build:debug": "(cd examples/Rn069/android && ./gradlew assembleDebug) && yarn install:debug",
"emulator": "bash ./scripts/start-android-emulator.sh"
},
"repository": {

Loading…
Cancel
Save