diff --git a/.circleci/config.yml b/.circleci/config.yml index eb0d3020..867d2311 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -3,7 +3,7 @@ version: 2.1 # Default VM config to be used for macOS builds macos_config: &macos_config macos: - xcode: 15.3.0 + xcode: 16.0.0 resource_class: macos.m1.large.gen1 shell: /bin/bash --login -eo pipefail @@ -20,7 +20,8 @@ executors: working_directory: ~/project orbs: - android: circleci/android@1.0 + android: circleci/android@2.4.0 + node: circleci/node@5.1.0 # Always run job run_always: &run_always @@ -36,7 +37,6 @@ run_on_release: &run_on_release branches: ignore: /.*/ - commands: attach_project: steps: @@ -55,7 +55,6 @@ jobs: command: | corepack enable yarn install --cwd example - yarn install --cwd example/e2e yarn install - save_cache: key: dependencies-{{ checksum "package.json" }} @@ -63,9 +62,6 @@ jobs: - save_cache: key: dependencies-example-{{ checksum "example/package.json" }} paths: example/node_modules - - save_cache: - key: dependencies-example-e2e-{{ checksum "example/package.json" }} - paths: example/e2e/node_modules - persist_to_workspace: root: . paths: . @@ -115,10 +111,14 @@ jobs: JAVA_OPTS: '-Xms512m -Xmx1024m' executor: name: android/android-machine + resource-class: large + tag: default working_directory: ~/project steps: - checkout: path: ~/project + - node/install: + node-version: 18.17.0 - attach_workspace: at: ~/project @@ -126,7 +126,11 @@ jobs: - <<: *setup_env_file - run: - working_directory: example/e2e + name: Install Maestro + command: curl -Ls "https://get.maestro.mobile.dev" | bash + + - run: + working_directory: example/test name: Build android command: npm run build:android @@ -141,10 +145,44 @@ jobs: post-emulator-launch-assemble-command: echo Emulator Started - run: - working_directory: example/e2e + name: Wait for emulator to finish booting + command: | + echo "⏳ Waiting for emulator to boot..." + adb wait-for-device + boot_completed="" + until [[ "$boot_completed" == "1" ]]; do + boot_completed=$(adb shell getprop sys.boot_completed 2>/dev/null | tr -d '\r') + echo "boot_completed=$boot_completed" + sleep 5 + done + echo "✅ Emulator boot complete" + + - run: + name: Log emulator + Intercom info + command: | + echo "🛰 Connected ADB devices:" + adb devices + + echo "📱 Installed packages:" + adb shell pm list packages | grep intercom || true + + echo "📜 Last 100 lines of logcat:" + adb logcat -d | tail -n 100 || true + + - run: + name: Install app on emulator + command: | + adb install -r ~/project/example/android/app/build/outputs/apk/release/app-release.apk + + - run: + working_directory: example/test name: Run UI Tests command: npm run test:android + - store_artifacts: + path: ~/.maestro/tests + destination: maestro-tests + # Build the Test App used for UI Testing and save is to the workspace. This allows it to be used by other jobs. ios-e2e-test: <<: *macos_config @@ -155,6 +193,11 @@ jobs: - <<: *setup_env_file + - run: + working_directory: example/e2e + name: Install Maestro + command: curl -Ls "https://get.maestro.mobile.dev" | bash + - restore_cache: keys: - pod-dependencies-{{ checksum "~/project/example/ios/Podfile" }} @@ -162,21 +205,37 @@ jobs: working_directory: example/ios name: Install Pods command: pod install + - save_cache: key: pod-dependencies-{{ checksum "~/project/example/ios/Podfile" }} paths: - ~/project/example/ios/Pods - run: - working_directory: example/e2e + working_directory: example/test name: Build command: npm run build:ios - run: - working_directory: example/e2e + name: Create and boot iPhone 15 simulator + command: | + echo "Creating iPhone 15 simulator with runtime $RUNTIME" + xcrun simctl create "iPhone 15" com.apple.CoreSimulator.SimDeviceType.iPhone-15 $RUNTIME + xcrun simctl boot "iPhone 15" || true + + - run: + name: Install app on simulator + command: | + xcrun simctl install booted ~/project/example/test/build/Build/Products/Release-iphonesimulator/IntercomReactNativeExampleUI.app + + - run: + working_directory: example/test name: Run UI Tests command: npm run test:ios + - store_artifacts: + path: ~/.maestro/tests + destination: maestro-tests release-to-npm: executor: default @@ -201,7 +260,6 @@ jobs: name: Publish the package command: npm publish - workflows: version: 2.1 build-and-test: @@ -224,22 +282,23 @@ workflows: <<: *run_always requires: - install-dependencies - # - android-e2e-test: - # <<: *run_always - # requires: - # - install-dependencies - # - lint - # - typescript - # - unit-tests - # - build-package - # - ios-e2e-test: - # <<: *run_always - # requires: - # - install-dependencies - # - lint - # - typescript - # - unit-tests - # - build-package + - android-e2e-test: + <<: *run_always + requires: + - install-dependencies + - lint + - typescript + - unit-tests + - build-package + - ios-e2e-test: + <<: *run_always + requires: + - install-dependencies + - lint + - typescript + - unit-tests + - build-package + - release-to-npm: <<: *run_on_release context: @@ -250,5 +309,5 @@ workflows: - typescript - unit-tests - build-package - # - ios-e2e-test - # - android-e2e-test + - ios-e2e-test + - android-e2e-test diff --git a/example/android/app/build.gradle b/example/android/app/build.gradle index 6d1cf5b2..d694c220 100644 --- a/example/android/app/build.gradle +++ b/example/android/app/build.gradle @@ -42,7 +42,7 @@ react { // bundleAssetName = "MyApplication.android.bundle" // // The entry file for bundle generation. Default is 'index.android.js' or 'index.js' - entryFile = file("index.tsx") + entryFile = file("../../index.tsx") // // A list of extra flags to pass to the 'bundle' commands. // See https://github.com/react-native-community/cli/blob/main/docs/commands.md#bundle diff --git a/example/test/maestro/android/open-help-center.yaml b/example/test/maestro/android/open-help-center.yaml index 68001e49..8c1ddd84 100644 --- a/example/test/maestro/android/open-help-center.yaml +++ b/example/test/maestro/android/open-help-center.yaml @@ -5,6 +5,9 @@ tags: --- - launchApp - tapOn: "Login as an Unidentified User" +- assertVisible: + text: "Present Help Center" + enabled: true - tapOn: "Present Help Center" - assertVisible: "Help" - assertVisible: "Untitled Collection" diff --git a/example/test/maestro/android/open-messenger.yaml b/example/test/maestro/android/open-messenger.yaml index 62ee64fb..ee5ebda9 100644 --- a/example/test/maestro/android/open-messenger.yaml +++ b/example/test/maestro/android/open-messenger.yaml @@ -1,4 +1,4 @@ -git appId: com.example.intercomreactnative +appId: com.example.intercomreactnative tags: - android - messenger diff --git a/example/test/maestro/ios/open-help-center.yaml b/example/test/maestro/ios/open-help-center.yaml index 82622cdc..7a4f045e 100644 --- a/example/test/maestro/ios/open-help-center.yaml +++ b/example/test/maestro/ios/open-help-center.yaml @@ -5,7 +5,9 @@ tags: --- - launchApp - tapOn: "Login as an Unidentified User" +- assertVisible: + text: "Present Help Center" + enabled: true - tapOn: "Present Help Center" -- assertVisible: "Help" - assertVisible: "Untitled collection" - tapOn: "Untitled collection" diff --git a/example/test/maestro/ios/open-messenger.yaml b/example/test/maestro/ios/open-messenger.yaml index 5a351f1b..941ba181 100644 --- a/example/test/maestro/ios/open-messenger.yaml +++ b/example/test/maestro/ios/open-messenger.yaml @@ -5,6 +5,8 @@ tags: --- - launchApp - tapOn: "Login as an Unidentified User" +- assertVisible: + text: "Present Intercom" + enabled: true - tapOn: "Present Intercom" - tapOn: "Messenger apps" - diff --git a/example/test/package.json b/example/test/package.json new file mode 100644 index 00000000..a4e6594e --- /dev/null +++ b/example/test/package.json @@ -0,0 +1,15 @@ +{ + "name": "intercom-react-native-example-e2e-tests", + "description": "Running", + "version": "1.0.0", + "main": "index.js", + "scripts": { + "build:android": "../android/gradlew assembleRelease -Pfoss -p ../android", + "build:ios": "xcodebuild build -workspace ../ios/IntercomReactNativeExample.xcworkspace -scheme IntercomReactNativeExampleUI -configuration Release -sdk iphonesimulator -derivedDataPath ./build", + "test:android": "maestro test ./maestro/android/*.yaml", + "test:ios": "maestro test ./maestro/ios/*.yaml" + }, + "keywords": [], + "author": "", + "license": "ISC" +}