diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml new file mode 100644 index 000000000..624e3be87 --- /dev/null +++ b/.github/workflows/e2e.yml @@ -0,0 +1,82 @@ +name: Maestro E2E + +on: + push: + branches: + - main + pull_request: + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true # auto cancel prev. run + +env: + MAESTRO_VERSION: 1.31.0 + ANDROID_ARCH: x86_64 + +jobs: + android-e2e: + name: E2e Tests ๐Ÿงช + runs-on: macos-12 # or buildjet-4vcpu-ubuntu-2204, ubuntu-22.04-4core, macos-12-xl + steps: + - name: Checkout ๐Ÿ›Ž๏ธ + uses: actions/checkout@v3 + + - name: Installing Maestro ๐Ÿ“ฅ + run: curl -Ls "https://get.maestro.mobile.dev" | bash # will use `MAESTRO_VERSION` from env + + - name: Validate Gradle Wrapper ๐Ÿ“ + uses: gradle/wrapper-validation-action@v1 + + - name: Copy CI gradle.properties ๐Ÿ“‹ + run: mkdir -p ~/.gradle ; cp .github/ci-gradle.properties ~/.gradle/gradle.properties + + - name: Set up JDK 17 โš™๏ธ + uses: actions/setup-java@v3 + with: + distribution: 'zulu' + java-version: 17 + + - name: Setup Gradle โš™๏ธ + uses: gradle/gradle-build-action@v2 + + - name: Setup environment โš™๏ธ + env: + ENV_VAR_FILE_NAME: debug.properties + run: | + echo 'API_BASE_URL="https://api.staging.crisiscleanup.io"' >> ${{ env.ENV_VAR_FILE_NAME }} + echo 'BASE_URL="http://localhost:8080"' >> ${{ env.ENV_VAR_FILE_NAME }} + echo 'MAPS_API_KEY="${{ secrets.MAPS_API_KEY }}"' >> ${{ env.ENV_VAR_FILE_NAME }} + echo 'DEBUG_EMAIL_ADDRESS="${{ secrets.TEST_APP_EMAIL_PROD }}"' >> ${{ env.ENV_VAR_FILE_NAME }} + echo 'DEBUG_ACCOUNT_PASSWORD="${{ secrets.TEST_APP_PASSWORD_PROD }}"' >> ${{ env.ENV_VAR_FILE_NAME }} + + - name: Build apk for emulator + run: | + ./gradlew assembleDebug --no-daemon -PreactNativeArchitectures=${{ env.ANDROID_ARCH }} + + echo "Print path to *.apk file" + find . -type f -name "*.apk" + + - name: Install Maestro and run e2e tests + uses: reactivecircus/android-emulator-runner@v2 + env: + APK_PATH: ./app/build/outputs/apk/demo/debug/app-demo-debug.apk + MAESTRO_DRIVER_STARTUP_TIMEOUT: 60000 + MAESTRO_APP_ID: com.crisiscleanup.demo.debug + MAESTRO_APP_EMAIL: ${{ secrets.TEST_APP_EMAIL_PROD }} + MAESTRO_APP_PASSWORD: ${{ secrets.TEST_APP_PASSWORD_PROD }} + with: + api-level: 33 + target: google_apis + arch: ${{ env.ANDROID_ARCH }} + script: | + adb install "${{ env.APK_PATH }}" + $HOME/.maestro/bin/maestro test .maestro/auth-tests --format junit + $HOME/.maestro/bin/maestro test .maestro/work-tests --format junit + + - name: Store tests result + uses: actions/upload-artifact@v3 + with: + name: e2e_android_report + path: | + report.xml diff --git a/.maestro/work-tests/incident-search-and-select.yaml b/.maestro/work-tests/incident-search-and-select.yaml index a36850c66..61f7dff32 100644 --- a/.maestro/work-tests/incident-search-and-select.yaml +++ b/.maestro/work-tests/incident-search-and-select.yaml @@ -7,10 +7,21 @@ tags: - pull-request env: SEARCH_QUERY: '11' + INCIDENT_REGEX: ".*(flood|tornado).*" onFlowStart: - runFlow: ../auth-tests/login.yaml --- # wait for incidents to load +- waitForAnimationToEnd: + timeout: 5000 +# Pick a random incident from incident selector +- tapOn: + id: "workIncidentSelectorFab" +- scrollUntilVisible: + element: ${INCIDENT_REGEX} +- tapOn: + text: ${INCIDENT_REGEX} + index: 0 - waitForAnimationToEnd: timeout: 5000 # start searching after loading spinner is invisible