diff --git a/.circleci/config.yml b/.circleci/config.yml index a9a0da0b..573f9213 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -8,6 +8,7 @@ aliases: orbs: node: circleci/node@5.1.1 browser-tools: circleci/browser-tools@1.4.6 + android: circleci/android@2.3.0 executors: default: @@ -210,6 +211,36 @@ jobs: name: Run Detox on iOS command: yarn e2e:ios - save-cache-detox-app + test-android: + parameters: + react-native-version: + type: string + executor: + name: android/android-machine + resource-class: large + tag: 2023.11.1 + working_directory: ~/react-native-url-polyfill/platforms/react-native/<< parameters.react-native-version >> + steps: + - attach-workspace + - install-node + - install-yarn-dependencies + - run: + name: List available SDKs + command: sdkmanager --list + - android/create-avd: + avd-name: TestingAVD + install: true + system-image: system-images;android-34;default;x86_64 + - android/start-emulator: + avd-name: TestingAVD + no-window: true + post-emulator-launch-assemble-command: '' + restore-gradle-cache-prefix: v1a + - run: + name: Run Detox + command: yarn e2e:android + - android/save-gradle-cache: + cache-prefix: v1a test-hermes-android: parameters: react-native-version: @@ -292,16 +323,10 @@ workflows: requires: - lint - test-js - - test-hermes-ios: - matrix: - parameters: - react-native-version: ['0.68'] - requires: - - test-ios-<< matrix.react-native-version >> - - test-hermes-android: + - test-android: matrix: parameters: - react-native-version: ['0.68'] + react-native-version: ['0.68', '0.72'] requires: - lint - test-js @@ -312,3 +337,15 @@ workflows: # requires: # - lint # - test-js + - test-hermes-ios: + matrix: + parameters: + react-native-version: ['0.68'] + requires: + - test-ios-<< matrix.react-native-version >> + - test-hermes-android: + matrix: + parameters: + react-native-version: ['0.68'] + requires: + - test-android-<< matrix.react-native-version >> diff --git a/platforms/detox/.detoxrc.js b/platforms/detox/.detoxrc.js index 33cbc86a..35448e07 100644 --- a/platforms/detox/.detoxrc.js +++ b/platforms/detox/.detoxrc.js @@ -52,7 +52,7 @@ module.exports = { emulator: { type: 'android.emulator', device: { - avdName: 'Pixel_3a_API_34_extension_level_7_arm64-v8a', + avdName: 'TestingAVD', }, }, }, diff --git a/platforms/react-native/0.68/android/app/build.gradle b/platforms/react-native/0.68/android/app/build.gradle index 407d670a..042035f1 100644 --- a/platforms/react-native/0.68/android/app/build.gradle +++ b/platforms/react-native/0.68/android/app/build.gradle @@ -170,6 +170,9 @@ android { } } } + + testBuildType System.getProperty('testBuildType', 'debug') + testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner' } if (isNewArchitectureEnabled()) { @@ -260,6 +263,9 @@ android { } dependencies { + androidTestImplementation('com.wix:detox:+') + implementation 'androidx.appcompat:appcompat:1.1.0' + implementation fileTree(dir: "libs", include: ["*.jar"]) //noinspection GradleDynamicVersion diff --git a/platforms/react-native/0.68/android/app/src/androidTest/java/com/detox/DetoxTest.java b/platforms/react-native/0.68/android/app/src/androidTest/java/com/detox/DetoxTest.java new file mode 100644 index 00000000..2e386c8f --- /dev/null +++ b/platforms/react-native/0.68/android/app/src/androidTest/java/com/detox/DetoxTest.java @@ -0,0 +1,29 @@ +package com.detox; + +import com.wix.detox.Detox; +import com.wix.detox.config.DetoxConfig; + +import org.junit.Rule; +import org.junit.Test; +import org.junit.runner.RunWith; + +import androidx.test.ext.junit.runners.AndroidJUnit4; +import androidx.test.filters.LargeTest; +import androidx.test.rule.ActivityTestRule; + +@RunWith(AndroidJUnit4.class) +@LargeTest +public class DetoxTest { + @Rule + public ActivityTestRule mActivityRule = new ActivityTestRule<>(MainActivity.class, false, false); + + @Test + public void runDetoxTests() { + DetoxConfig detoxConfig = new DetoxConfig(); + detoxConfig.idlePolicyConfig.masterTimeoutSec = 90; + detoxConfig.idlePolicyConfig.idleResourceTimeoutSec = 60; + detoxConfig.rnContextLoadTimeoutSec = (BuildConfig.DEBUG ? 180 : 60); + + Detox.runTests(mActivityRule, detoxConfig); + } +} \ No newline at end of file diff --git a/platforms/react-native/0.68/android/app/src/debug/AndroidManifest.xml b/platforms/react-native/0.68/android/app/src/debug/AndroidManifest.xml index 4b185bc1..0df58336 100644 --- a/platforms/react-native/0.68/android/app/src/debug/AndroidManifest.xml +++ b/platforms/react-native/0.68/android/app/src/debug/AndroidManifest.xml @@ -9,5 +9,10 @@ tools:targetApi="28" tools:ignore="GoogleAppIndexingWarning"> + diff --git a/platforms/react-native/0.68/android/app/src/main/AndroidManifest.xml b/platforms/react-native/0.68/android/app/src/main/AndroidManifest.xml index d04ed016..af8ccd6d 100644 --- a/platforms/react-native/0.68/android/app/src/main/AndroidManifest.xml +++ b/platforms/react-native/0.68/android/app/src/main/AndroidManifest.xml @@ -9,7 +9,8 @@ android:icon="@mipmap/ic_launcher" android:roundIcon="@mipmap/ic_launcher_round" android:allowBackup="false" - android:theme="@style/AppTheme"> + android:theme="@style/AppTheme" + android:networkSecurityConfig="@xml/network_security_config"> + diff --git a/platforms/react-native/0.68/android/app/src/main/res/values/strings.xml b/platforms/react-native/0.68/android/app/src/main/res/values/strings.xml index 8e9317b5..afa52ba2 100644 --- a/platforms/react-native/0.68/android/app/src/main/res/values/strings.xml +++ b/platforms/react-native/0.68/android/app/src/main/res/values/strings.xml @@ -1,3 +1,4 @@ Detox + com.detox.blobs diff --git a/platforms/react-native/0.68/android/app/src/main/res/xml/network_security_config.xml b/platforms/react-native/0.68/android/app/src/main/res/xml/network_security_config.xml new file mode 100644 index 00000000..c7755e76 --- /dev/null +++ b/platforms/react-native/0.68/android/app/src/main/res/xml/network_security_config.xml @@ -0,0 +1,7 @@ + + + + 10.0.2.2 + localhost + + \ No newline at end of file diff --git a/platforms/react-native/0.68/android/build.gradle b/platforms/react-native/0.68/android/build.gradle index 5dfc68a6..966289d1 100644 --- a/platforms/react-native/0.68/android/build.gradle +++ b/platforms/react-native/0.68/android/build.gradle @@ -4,6 +4,7 @@ import org.apache.tools.ant.taskdefs.condition.Os buildscript { ext { + kotlinVersion = '1.6.21' buildToolsVersion = "31.0.0" minSdkVersion = 21 compileSdkVersion = 31 @@ -25,6 +26,7 @@ buildscript { classpath("com.android.tools.build:gradle:7.0.4") classpath("com.facebook.react:react-native-gradle-plugin") classpath("de.undercouch:gradle-download-task:4.1.2") + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion" // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } @@ -47,6 +49,9 @@ allprojects { excludeGroup "com.facebook.react" } } + maven { + url "$rootDir/../node_modules/detox/Detox-android" + } google() maven { url 'https://www.jitpack.io' } } diff --git a/platforms/react-native/0.68/package.json b/platforms/react-native/0.68/package.json index 73f3fd38..7d328bb3 100644 --- a/platforms/react-native/0.68/package.json +++ b/platforms/react-native/0.68/package.json @@ -11,6 +11,9 @@ "build:ios": "detox build --configuration ios.sim.release", "test:ios": "detox test --configuration ios.sim.release --cleanup", "e2e:ios": "yarn build:ios && yarn test:ios", + "build:android": "detox build --configuration android.emu.release", + "test:android": "detox test --configuration android.emu.release", + "e2e:android": "yarn build:android && yarn test:android", "postinstall": "patch-package" }, "dependencies": {