From 16018e699840f2baa6eeb3fda129a3c2b1024b1f Mon Sep 17 00:00:00 2001 From: Johannes Klein Date: Thu, 28 Mar 2024 23:41:40 +0100 Subject: [PATCH] 1312 e2e experiments (#1320) * Bump detox * Update detox * Disable one test for now * Bump detox * Increase test timeouts * Collect more logs * Increase run timeout * Comment * Increase timeout * Replace password autofill workaround * Move workaround after launchApp * Upgrade github actions workflows * Forgot one action * Update test.yml * Testing concurrency * Use concurrency for e2e as well * Remove previous concurrency code * Testing different Slack action * Change slack msg * Try different msg * Revert "Try different msg" This reverts commit ddaad331d1b8263fc6fe7b9564a4c3e92187a92a. * Revert "Change slack msg" This reverts commit 852204b074fc690148416799b463072750331467. * Revert "Testing different Slack action" This reverts commit fb072e65e34faf52839bbd281993a0321584d461. * Testing some more notify * Testing notification * Revert "Testing notification" This reverts commit 974dfcb32facbe00266e490501d111879dcf2a2f. * Revert "Testing some more notify" This reverts commit 39b3d668e22468b5a09b7a7db146c1dcb412f6a8. --- .detoxrc.js | 4 ++++ .github/workflows/e2e_android.yml | 24 +++++++++--------------- .github/workflows/e2e_ios.yml | 29 ++++++++++++----------------- .github/workflows/test.yml | 20 ++++++++------------ e2e/helpers.js | 15 +++++++++++++++ e2e/jest.config.js | 2 +- e2e/signedIn.e2e.js | 7 ------- e2e/signedOut.e2e.js | 21 +++++++++++---------- package-lock.json | 16 ++++++++-------- package.json | 2 +- 10 files changed, 69 insertions(+), 71 deletions(-) diff --git a/.detoxrc.js b/.detoxrc.js index bca8cb64c..1bce35347 100644 --- a/.detoxrc.js +++ b/.detoxrc.js @@ -13,6 +13,10 @@ module.exports = { config: "e2e/jest.config.js", _: ["e2e"], }, + jest: { + setupTimeout: 900000, + teardownTimeout: 900000, + }, }, apps: { "ios.debug": { diff --git a/.github/workflows/e2e_android.yml b/.github/workflows/e2e_android.yml index 3984faad5..20c762a7c 100644 --- a/.github/workflows/e2e_android.yml +++ b/.github/workflows/e2e_android.yml @@ -2,19 +2,13 @@ name: e2e-Android on: workflow_dispatch: +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + jobs: - # This might be refactored to use concurrency from GitHub Actions directly? - deduplicate: - runs-on: macos-latest - steps: - - uses: fkirc/skip-duplicate-actions@master - with: - github_token: ${{ github.token }} - cancel_others: true - checksecret: name: check for oauth client - needs: deduplicate runs-on: macos-latest outputs: is_SECRETS_PRESENT_set: ${{ steps.checksecret_job.outputs.is_SECRETS_PRESENT_set }} @@ -36,12 +30,12 @@ jobs: steps: - name: Check out Git repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 1 - name: Install Node.js, NPM and Yarn - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: node-version: 18 @@ -56,7 +50,7 @@ jobs: $ANDROID_HOME/emulator/emulator -list-avds - name: Cache node modules - uses: actions/cache@v3 + uses: actions/cache@v4 id: cache with: path: node_modules @@ -104,7 +98,7 @@ jobs: # Macos-latest runner has 3 Java versions pre-installed, if not specified as here, the build step errors with requiring at least Java 11 or higher # So, this step is needed for the apk build step, but somehow this is breaking emulator setup, so it is placed here - name: Set up JDK 11 - uses: actions/setup-java@v3 + uses: actions/setup-java@v4 with: java-version: '11' distribution: 'zulu' @@ -138,7 +132,7 @@ jobs: # The artifacts for the failing tests are available for download on github.com on the page of the individual actions run - name: Store Detox artifacts on test failure - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 if: failure() with: name: detox-artifacts diff --git a/.github/workflows/e2e_ios.yml b/.github/workflows/e2e_ios.yml index b44f7b935..642fcdaab 100644 --- a/.github/workflows/e2e_ios.yml +++ b/.github/workflows/e2e_ios.yml @@ -9,18 +9,13 @@ on: # branches: # - 'main' +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + jobs: - setup: - runs-on: macos-14 - steps: - - uses: fkirc/skip-duplicate-actions@master - with: - github_token: ${{ github.token }} - cancel_others: true - checksecret: name: check for oauth client - needs: setup runs-on: macos-14 outputs: is_SECRETS_PRESENT_set: ${{ steps.checksecret_job.outputs.is_SECRETS_PRESENT_set }} @@ -37,17 +32,17 @@ jobs: needs: checksecret if: needs.checksecret.outputs.is_SECRETS_PRESENT_set == 'true' runs-on: macos-14 - # Kill the task if not finished after 60 minutes - timeout-minutes: 60 + # Kill the task if not finished after 120 minutes + timeout-minutes: 120 steps: - name: Check out Git repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 1 - name: Install Node.js, NPM and Yarn - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: node-version: 18 @@ -57,7 +52,7 @@ jobs: bundler-cache: true - name: Cache node modules - uses: actions/cache@v3 + uses: actions/cache@v4 id: cache with: path: node_modules @@ -72,7 +67,7 @@ jobs: run: npm install - name: Cache Pods - uses: actions/cache@v3 + uses: actions/cache@v4 id: podcache with: path: ios/Pods @@ -122,11 +117,11 @@ jobs: curl -I --fail "https://stagingapi.inaturalist.org/v2/taxa" - name: Run e2e test - run: npm run e2e:test:ios -- --cleanup --take-screenshots failing --record-videos failing -l debug + run: npm run e2e:test:ios -- --cleanup --take-screenshots failing --record-videos failing --record-logs all -l trace # The artifacts for the failing tests are available for download on github.com on the page of the individual actions run - name: Store Detox artifacts on test failure - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 if: failure() with: name: detox-artifacts diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d4b4f7072..1ee8dc817 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -6,29 +6,25 @@ on: pull_request: push: +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + jobs: - pre_build: - runs-on: ubuntu-latest - steps: - - uses: fkirc/skip-duplicate-actions@master - with: - github_token: ${{ github.token }} - cancel_others: true test: name: Run Tests - needs: pre_build runs-on: ubuntu-latest steps: - name: Check out Git repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Install Node.js, NPM and Yarn - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: - node-version: 16 + node-version: 18 - name: Cache node modules - uses: actions/cache@v3 + uses: actions/cache@v4 id: cache with: path: node_modules diff --git a/e2e/helpers.js b/e2e/helpers.js index 062614129..1570e4645 100644 --- a/e2e/helpers.js +++ b/e2e/helpers.js @@ -1,3 +1,5 @@ +import { execSync } from "child_process"; + export async function iNatE2eBeforeAll( device ) { if ( device.getPlatform() === "android" ) { await device.launchApp( { @@ -17,5 +19,18 @@ export async function iNatE2eBeforeEach( device ) { newInstance: true, permissions: { location: "always" } } ); + // disable password autofill + execSync( + // eslint-disable-next-line max-len + `plutil -replace restrictedBool.allowPasswordAutoFill.value -bool NO ~/Library/Developer/CoreSimulator/Devices/${device.id}/data/Containers/Shared/SystemGroup/systemgroup.com.apple.configurationprofiles/Library/ConfigurationProfiles/UserSettings.plist` + ); + execSync( + // eslint-disable-next-line max-len + `plutil -replace restrictedBool.allowPasswordAutoFill.value -bool NO ~/Library/Developer/CoreSimulator/Devices/${device.id}/data/Library/UserConfigurationProfiles/EffectiveUserSettings.plist` + ); + execSync( + // eslint-disable-next-line max-len + `plutil -replace restrictedBool.allowPasswordAutoFill.value -bool NO ~/Library/Developer/CoreSimulator/Devices/${device.id}/data/Library/UserConfigurationProfiles/PublicInfo/PublicEffectiveUserSettings.plist` + ); } } diff --git a/e2e/jest.config.js b/e2e/jest.config.js index cc280b10e..7847e330e 100644 --- a/e2e/jest.config.js +++ b/e2e/jest.config.js @@ -1,6 +1,6 @@ module.exports = { maxWorkers: 1, - testTimeout: 300000, + testTimeout: 900000, rootDir: "..", testMatch: ["/e2e/**/*.e2e.js"], verbose: true, diff --git a/e2e/signedIn.e2e.js b/e2e/signedIn.e2e.js index 2b7610cfd..a544c3805 100644 --- a/e2e/signedIn.e2e.js +++ b/e2e/signedIn.e2e.js @@ -116,13 +116,6 @@ describe( "Signed in user", () => { await waitFor( username ).toBeVisible().withTimeout( 10000 ); await expect( username ).toBeVisible(); - // Weird but functional workaround for the fact that the "Save Password" - // prompt in iOS blocks things on the bottom of the screen. - // https://github.com/wix/Detox/issues/3761#issuecomment-1521110131 - await device.sendToHome(); - await device.launchApp( { - newInstance: false - } ); /* / 2. Create two observations */ diff --git a/e2e/signedOut.e2e.js b/e2e/signedOut.e2e.js index 8971b20e5..0fc523b8d 100644 --- a/e2e/signedOut.e2e.js +++ b/e2e/signedOut.e2e.js @@ -18,14 +18,15 @@ describe( "Signed out user", () => { await expect( loginText ).toBeVisible( ); } ); - it( "should add an observation without evidence", async () => { - const addObsButton = element( by.id( "add-obs-button" ) ); - await waitFor( addObsButton ).toBeVisible( ).withTimeout( 10000 ); - await addObsButton.tap( ); - await expect( element( by.id( "identify-text" ) ) ).toBeVisible(); - const obsWithoutEvidenceButton = element( by.id( "observe-without-evidence-button" ) ); - await expect( obsWithoutEvidenceButton ).toBeVisible( ); - await obsWithoutEvidenceButton.tap( ); - await waitFor( element( by.id( "new-observation-text" ) ) ).toBeVisible( ).withTimeout( 10000 ); - } ); + // it( "should add an observation without evidence", async () => { + // const addObsButton = element( by.id( "add-obs-button" ) ); + // await waitFor( addObsButton ).toBeVisible( ).withTimeout( 10000 ); + // await addObsButton.tap( ); + // await expect( element( by.id( "identify-text" ) ) ).toBeVisible(); + // const obsWithoutEvidenceButton = element( by.id( "observe-without-evidence-button" ) ); + // await expect( obsWithoutEvidenceButton ).toBeVisible( ); + // await obsWithoutEvidenceButton.tap( ); + // await waitFor( element( by.id( "new-observation-text" ) ) ) + // .toBeVisible( ).withTimeout( 10000 ); + // } ); } ); diff --git a/package-lock.json b/package-lock.json index 7a2136d3c..b5f20d75d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -122,7 +122,7 @@ "babel-plugin-transform-inline-environment-variables": "^0.4.4", "babel-plugin-transform-remove-console": "^6.9.4", "chalk": "^5.3.0", - "detox": "20.17.1", + "detox": "^20.19.4", "dotenv": "^16.3.1", "download": "^8.0.0", "eslint": "^8.49.0", @@ -9564,9 +9564,9 @@ } }, "node_modules/detox": { - "version": "20.17.1", - "resolved": "https://registry.npmjs.org/detox/-/detox-20.17.1.tgz", - "integrity": "sha512-10pey6CR9D5GSloRkH60ObBGZ8VS11H7iuBNY7qq6jO2swiqqckHhPLRXfH9+WGR7l3vDnfU+G/gQs7JxQkJwA==", + "version": "20.19.4", + "resolved": "https://registry.npmjs.org/detox/-/detox-20.19.4.tgz", + "integrity": "sha512-frlWR+6oSrVhyr2xXqnSUbOwxBl1Yl7cdayIErVcHYIxfWIMYOH9o4csuIso3HRCUpJUwZkQrg0IsZUzWe08IA==", "dev": true, "hasInstallScript": true, "dependencies": { @@ -9610,7 +9610,7 @@ "detox": "local-cli/cli.js" }, "engines": { - "node": ">=16" + "node": ">=14" }, "peerDependencies": { "jest": "29.x.x || 28.x.x || ^27.2.5" @@ -33220,9 +33220,9 @@ "dev": true }, "detox": { - "version": "20.17.1", - "resolved": "https://registry.npmjs.org/detox/-/detox-20.17.1.tgz", - "integrity": "sha512-10pey6CR9D5GSloRkH60ObBGZ8VS11H7iuBNY7qq6jO2swiqqckHhPLRXfH9+WGR7l3vDnfU+G/gQs7JxQkJwA==", + "version": "20.19.4", + "resolved": "https://registry.npmjs.org/detox/-/detox-20.19.4.tgz", + "integrity": "sha512-frlWR+6oSrVhyr2xXqnSUbOwxBl1Yl7cdayIErVcHYIxfWIMYOH9o4csuIso3HRCUpJUwZkQrg0IsZUzWe08IA==", "dev": true, "requires": { "ajv": "^8.6.3", diff --git a/package.json b/package.json index 239676e3d..89f2e9893 100644 --- a/package.json +++ b/package.json @@ -147,7 +147,7 @@ "babel-plugin-transform-inline-environment-variables": "^0.4.4", "babel-plugin-transform-remove-console": "^6.9.4", "chalk": "^5.3.0", - "detox": "20.17.1", + "detox": "^20.19.4", "dotenv": "^16.3.1", "download": "^8.0.0", "eslint": "^8.49.0",