From 708a61ed9d5c1de208fedb87ed61f8a3376be35f Mon Sep 17 00:00:00 2001 From: Henning Hall Date: Mon, 18 Dec 2023 12:07:05 +0100 Subject: [PATCH] chore: convert tests from detox to maestro (maximumDate) (#739) --- .github/workflows/test-android-e2e.yml | 7 +- .github/workflows/test-ios-e2e.yml | 2 +- .maestro/maximum-date.yml | 112 ++++++++++++++++++ .maestro/utils/change-maximum-date.yml | 7 ++ .maestro/utils/change-mode.yml | 7 ++ examples/detox/e2e/tests/maximumDate.spec.js | 116 ------------------- 6 files changed, 133 insertions(+), 118 deletions(-) create mode 100644 .maestro/maximum-date.yml create mode 100644 .maestro/utils/change-maximum-date.yml create mode 100644 .maestro/utils/change-mode.yml delete mode 100644 examples/detox/e2e/tests/maximumDate.spec.js diff --git a/.github/workflows/test-android-e2e.yml b/.github/workflows/test-android-e2e.yml index d905c77..0cd9594 100644 --- a/.github/workflows/test-android-e2e.yml +++ b/.github/workflows/test-android-e2e.yml @@ -3,6 +3,11 @@ name: Test Android e2e on: workflow_call: workflow_dispatch: + inputs: + test-tags: + description: 'Maestro tags to run (comma separated)' + required: false + default: 'android' env: APP_PATH: examples/Rn071/android/app/build/outputs/apk/release/app-release.apk @@ -28,7 +33,7 @@ jobs: with: api-key: ${{ secrets.MAESTRO_CLOUD_API_KEY }} app-file: ${{ env.APP_PATH }} - include-tags: android + include-tags: ${{ inputs.test-tags }} # Step can be removed when this is fixed: # https://github.com/mobile-dev-inc/action-maestro-cloud/issues/28 diff --git a/.github/workflows/test-ios-e2e.yml b/.github/workflows/test-ios-e2e.yml index f6b01ed..bc9a784 100644 --- a/.github/workflows/test-ios-e2e.yml +++ b/.github/workflows/test-ios-e2e.yml @@ -1,4 +1,4 @@ -name: E2E tests (ios) +name: Test iOS e2e on: workflow_call: diff --git a/.maestro/maximum-date.yml b/.maestro/maximum-date.yml new file mode 100644 index 0000000..4f5d99a --- /dev/null +++ b/.maestro/maximum-date.yml @@ -0,0 +1,112 @@ +appId: com.rn071 +tags: + - android + - maximumDate +--- +- runFlow: utils/launch.yml + +########## describe: cannot pass max date + +- runFlow: + file: utils/change-maximum-date.yml + env: + VALUE: '2000-01-01T00:00:00' + +### test: datetime mode + +- runFlow: + file: utils/change-mode.yml + env: + VALUE: datetime + +- runFlow: utils/swipe-wheel-1.yml +- assertVisible: '2000-01-01 00:00:00' + +- runFlow: utils/swipe-wheel-2.yml +- assertVisible: '2000-01-01 00:00:00' + +- runFlow: utils/swipe-wheel-3.yml +- assertVisible: '2000-01-01 00:00:00' + +### test: date mode + +- runFlow: + file: utils/change-mode.yml + env: + VALUE: date + +- runFlow: utils/swipe-wheel-1.yml +- assertVisible: '2000-01-01 00:00:00' + +- runFlow: utils/swipe-wheel-2.yml +- assertVisible: '2000-01-01 00:00:00' + +- runFlow: utils/swipe-wheel-3.yml +- assertVisible: '2000-01-01 00:00:00' + +### test: time mode + +- runFlow: + file: utils/change-mode.yml + env: + VALUE: time + +- runFlow: utils/swipe-wheel-1.yml +- assertVisible: '2000-01-01 00:00:00' + +- runFlow: utils/swipe-wheel-2.yml +- assertVisible: '2000-01-01 00:00:00' + +- runFlow: utils/swipe-wheel-3.yml +- assertVisible: '2000-01-01 00:00:00' + +########## describe: overshooting max date + +### test: overshooting day wheel should reset to maximum date +- runFlow: + file: utils/change-maximum-date.yml + env: + VALUE: '2000-01-02 00:00:00' +- runFlow: utils/swipe-wheel-1.yml +- assertVisible: '2000-01-02 00:00:00' + +### test: overshooting month wheel should set other wheels to max date +- runFlow: + file: utils/change-mode.yml + env: + VALUE: date +- runFlow: utils/swipe-wheel-1.yml +- assertVisible: '2000-01-02 00:00:00' + +- runFlow: utils/swipe-wheel-2.yml +- assertVisible: '2000-01-02 00:00:00' + +### test: overshooting year wheel should set other wheels to max date +- runFlow: + file: utils/change-maximum-date.yml + env: + VALUE: '2001-01-02 00:00:00' +- runFlow: utils/swipe-wheel-1.yml +- runFlow: utils/swipe-wheel-3.yml +- assertVisible: '2001-01-02 00:00:00' + +### test: overshooting in time mode should set other wheels to max date +- runFlow: utils/reset.yml + +- runFlow: + file: utils/change-maximum-date.yml + env: + VALUE: '2000-01-01 00:00:00' +- runFlow: + file: utils/change-mode.yml + env: + VALUE: time + +- runFlow: utils/swipe-wheel-1.yml +- assertVisible: '2000-01-01 00:00:00' + +- runFlow: utils/swipe-wheel-2.yml +- assertVisible: '2000-01-01 00:00:00' + +- runFlow: utils/swipe-wheel-3.yml +- assertVisible: '2000-01-01 00:00:00' diff --git a/.maestro/utils/change-maximum-date.yml b/.maestro/utils/change-maximum-date.yml new file mode 100644 index 0000000..922d531 --- /dev/null +++ b/.maestro/utils/change-maximum-date.yml @@ -0,0 +1,7 @@ +appId: com.rn071 +--- +- runFlow: + file: change-prop.yml + env: + PROP: maximumDate + VALUE: ${VALUE} diff --git a/.maestro/utils/change-mode.yml b/.maestro/utils/change-mode.yml new file mode 100644 index 0000000..c5dd29a --- /dev/null +++ b/.maestro/utils/change-mode.yml @@ -0,0 +1,7 @@ +appId: com.rn071 +--- +- runFlow: + file: change-prop.yml + env: + PROP: mode + VALUE: ${VALUE} diff --git a/examples/detox/e2e/tests/maximumDate.spec.js b/examples/detox/e2e/tests/maximumDate.spec.js deleted file mode 100644 index c9c188a..0000000 --- a/examples/detox/e2e/tests/maximumDate.spec.js +++ /dev/null @@ -1,116 +0,0 @@ -const { scrollWheel, expectDate, setMaximumDate, setMode } = require('../utils') - -const initialDate = new Date(2000, 0, 1, 0, 0) -const secondOfJanuary = new Date(2000, 0, 2, 0, 0) -const secondOfJanuary2001 = new Date(2001, 0, 2, 0, 0) - -describe('Maximum date', () => { - before(async () => { - await device.reloadReactNative() - await element(by.text('Advanced')).tap() - }) - - describe('cannot pass max date - datetime mode', () => { - before(async () => { - await setMode('datetime') - await setMaximumDate(initialDate) - }) - - it('day wheel', async () => { - await scrollWheel(0, 2) - await expectDate('2000-01-01 00:00:00') - }) - - it('hour wheel', async () => { - await scrollWheel(1, 1) - await expectDate('2000-01-01 00:00:00') - }) - - it('minute wheel', async () => { - await scrollWheel(2, 1) - await expectDate('2000-01-01 00:00:00') - }) - }) - - describe('cannot pass max date - date mode', () => { - before(async () => { - await setMode('date') - await setMaximumDate(initialDate) - }) - - it('month wheel', async () => { - await scrollWheel(0, 1) - await expectDate('2000-01-01 00:00:00') - }) - - it('date wheel', async () => { - await scrollWheel(1, 1) - await expectDate('2000-01-01 00:00:00') - }) - - it('year wheel', async () => { - await scrollWheel(2, 1) - await expectDate('2000-01-01 00:00:00') - }) - }) - - describe('overshooting max date', () => { - before(async () => { - await setMaximumDate(secondOfJanuary) - }) - - it('day wheel should not be possible to overshoot since it is not wrapping (no invalid dates exists)', async () => { - await setMode('datetime') - await scrollWheel(0, 1) - await expectDate('2000-01-02 00:00:00') - await scrollWheel(0, 1) - await expectDate('2000-01-02 00:00:00') - }) - - describe('date mode', () => { - before(async () => { - await setMode('date') - await setMaximumDate(secondOfJanuary) - }) - - it('overshooting month wheel should set all other wheels to maximum possible date', async () => { - await scrollWheel(0, 1) - await expectDate('2000-01-02 00:00:00') - }) - - it('overshooting date wheel should reverse to highest possible date', async () => { - await scrollWheel(1, 5) - await expectDate('2000-01-02 00:00:00') - }) - - it('overshooting year wheel should set all other wheels to maximum possible date', async () => { - await setMaximumDate(secondOfJanuary2001) - await scrollWheel(0, 1) // set month to feb - await scrollWheel(2, 1) - await expectDate('2001-01-02 00:00:00') - }) - }) - - describe('time mode', () => { - before(async () => { - await setMode('time') - await setMaximumDate(initialDate) - }) - - it('overshooting hour wheel should reverse to highest possible time', async () => { - await scrollWheel(0, 5) - await expectDate('2000-01-01 00:00:00') - }) - - it('overshooting minute wheel should reverse to highest possible time', async () => { - await scrollWheel(1, 5) - await expectDate('2000-01-01 00:00:00') - }) - - it('overshooting am/pm wheel should reverse to highest possible time', async () => { - await scrollWheel(2, 1) - await expectDate('2000-01-01 00:00:00') - }) - }) - }) -})