Skip to content

Commit

Permalink
fix conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
matinzd committed Jan 20, 2025
2 parents 73a4741 + de0dbe9 commit 759efac
Show file tree
Hide file tree
Showing 195 changed files with 3,940 additions and 4,786 deletions.
3 changes: 2 additions & 1 deletion .buildkite/jobs/pipeline.android_rn_73.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
- label: ":android::detox: RN .73 + Android: Tests app"
- label: ":android::detox: (Old Arch) - RN .73 + Android: Tests app"
command:
- "nvm install"
- "./scripts/ci.android.sh"
env:
REACT_NATIVE_VERSION: 0.73.2
DETOX_DISABLE_POD_INSTALL: true
DETOX_DISABLE_POSTINSTALL: true
ENABLE_NEW_ARCH: false
artifact_paths:
- "/Users/builder/uibuilder/work/coverage/**/*.lcov"
- "/Users/builder/uibuilder/work/**/allure-report-*.html"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
- label: ":android::detox: RN .75 + Android: Tests app"
- label: ":android::detox: (Old Arch) - RN .76 + Android: Tests app"
command:
- "nvm install"
- "./scripts/ci.android.sh"
env:
REACT_NATIVE_VERSION: 0.75.4
DETOX_DISABLE_POD_INSTALL: true
DETOX_DISABLE_POSTINSTALL: true
ENABLE_NEW_ARCH: false
artifact_paths:
- "/Users/builder/uibuilder/work/coverage/**/*.lcov"
- "/Users/builder/uibuilder/work/**/allure-report-*.html"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
- label: ":ios::react: RN .76 + iOS: Demo app"
- label: ":new::ios::react: RN .76 + iOS: Demo app"
command:
- "nvm install"
- "./scripts/demo-projects.ios.sh"
env:
REACT_NATIVE_VERSION: 0.76.3
RCT_NEW_ARCH_ENABLED: 1
artifact_paths:
- "/Users/builder/uibuilder/work/coverage/**/*.lcov"
- "/Users/builder/uibuilder/work/artifacts*.tar.gz"
1 change: 1 addition & 0 deletions .buildkite/jobs/pipeline.ios_rn_76.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
- "./scripts/ci.ios.sh"
env:
REACT_NATIVE_VERSION: 0.76.3
RCT_NEW_ARCH_ENABLED: 0
artifact_paths:
- "/Users/builder/uibuilder/work/coverage/**/*.lcov"
- "/Users/builder/uibuilder/work/**/allure-report-*.html"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
- label: ":ios::detox: RN .75 + iOS: Tests app"
- label: ":new::ios::detox: RN .76 + New Arch + iOS: Tests app"
command:
- "nvm install"
- "./scripts/ci.ios.sh"
env:
REACT_NATIVE_VERSION: 0.75.4
REACT_NATIVE_VERSION: 0.76.3
RCT_NEW_ARCH_ENABLED: 1
artifact_paths:
- "/Users/builder/uibuilder/work/coverage/**/*.lcov"
- "/Users/builder/uibuilder/work/**/allure-report-*.html"
Expand Down
13 changes: 0 additions & 13 deletions .buildkite/pipeline.release.fast.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,9 @@
JAVA_HOME: /opt/openjdk/openlogic-openjdk-17.0.9+9-mac-x64/jdk-17.0.9.jdk/Contents/Home
artifact_paths: "/Users/builder/uibuilder/work/detox/Detox-android/**/*"

- label: ":android: Package android Legacy"
key: 'android_package_legacy'
command:
- "nvm install"
- "npm install"
- "npm run package:android"
env:
REACT_NATIVE_VERSION: 0.71.10
DETOX_DISABLE_POSTINSTALL: true
DETOX_DISABLE_POD_INSTALL: true
artifact_paths: "/Users/builder/uibuilder/work/detox/Detox-android/**/*"

- label: ":shipit: Publish"
depends_on:
- 'android_package'
- 'android_package_legacy'
- 'ios_package'
command:
- "nvm install 20"
Expand Down
6 changes: 3 additions & 3 deletions .buildkite/pipeline_common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

echo "steps:"

cat .buildkite/jobs/pipeline.ios_rn_76_new_arch.yml
cat .buildkite/jobs/pipeline.ios_rn_76.yml
cat .buildkite/jobs/pipeline.ios_rn_75.yml
cat .buildkite/jobs/pipeline.ios_rn_73.yml
cat .buildkite/jobs/pipeline.ios_demo_app_rn_76.yml
cat .buildkite/jobs/pipeline.ios_demo_app_rn_76_new_arch.yml
cat .buildkite/jobs/pipeline.android_rn_76.yml
cat .buildkite/jobs/pipeline.android_rn_75.yml
cat .buildkite/jobs/pipeline.android_rn_76_old_arch.yml
cat .buildkite/jobs/pipeline.android_rn_73.yml
cat .buildkite/jobs/pipeline.android_demo_app_rn_76.yml
cat .buildkite/pipeline.post_processing.yml
8 changes: 4 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ fabric.properties
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore

## Build generated
ios/build/
ios/DerivedData/
*/*/ios/build/
*/*/ios/DerivedData/

## Various settings
*.pbxuser
Expand All @@ -93,12 +93,12 @@ ios/DerivedData/
!default.mode2v3
*.perspectivev3
!default.perspectivev3
ios/xcuserdata/
*/*/ios/xcuserdata/

## Other
*.moved-aside
*.xcuserstate
ios/.xcode.env.local
*/*/ios/.xcode.env.local

## Obj-C/Swift specific
*.hmap
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ The most difficult part of automated testing on mobile is the tip of the testing

Detox was built from the ground up to support React Native projects.

While Detox should work out of the box with almost any React Native version of the latest minor releases, official support is provided for React Native versions `0.72.x`, `0.73.x`, `0.74.x`, `0.75.x`, `0.76.x` without React Native's ["New Architecture"](https://reactnative.dev/docs/the-new-architecture/landing-page).
While Detox should work out of the box with almost any React Native version of the latest minor releases, official support is provided for React Native versions `0.73.x`, `0.74.x`, `0.75.x` and `0.76.x` without React Native's ["New Architecture"](https://reactnative.dev/docs/the-new-architecture/landing-page).

Newer versions, as well as React Native's "New Architecture", may work with Detox, but have not been tested out yet by the Detox team.

Expand Down
Binary file removed artifacts__detoxtest_2024-10-15_10-04-31.tar.gz
Binary file not shown.
7 changes: 6 additions & 1 deletion detox/android/detox/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,12 @@ dependencies {
api('androidx.test.uiautomator:uiautomator:2.2.0') {
because 'Needed by Detox but also makes UIAutomator seamlessly provided to Detox users with hybrid apps/E2E-tests.'
}
api('androidx.test:core-ktx:1.6.1') {
because 'Needed by Detox but also makes AndroidX test core seamlessly provided to Detox users with hybrid apps/E2E-tests.'
}
implementation("org.jetbrains.kotlin:kotlin-reflect:$_kotlinVersion") {
because('Needed by Detox for kotlin reflection')
}
}

// Third-party/extension deps.
Expand Down Expand Up @@ -199,7 +205,6 @@ if (rootProject.hasProperty('isOfficialDetoxLib') ||
dependencies {
testImplementation 'org.spekframework.spek2:spek-dsl-jvm:2.0.15'
testImplementation 'org.spekframework.spek2:spek-runner-junit5:2.0.15'
testImplementation "org.jetbrains.kotlin:kotlin-reflect:$_kotlinVersion"
}
}

Expand Down
12 changes: 12 additions & 0 deletions detox/android/detox/proguard-rules-app.pro
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
-keepattributes InnerClasses, Exceptions

-keep class com.facebook.react.fabric.FabricUIManager { *; }
-keep class com.facebook.react.fabric.mounting.MountItemDispatcher { *; }
-keep class com.facebook.react.modules.** { *; }
-keep class com.facebook.react.uimanager.** { *; }
-keep class com.facebook.react.animated.** { *; }
-keep class com.facebook.react.ReactApplication { *; }
-keep class com.facebook.react.ReactNativeHost { *; }
-keep class com.facebook.react.ReactHost { *; }
-keep class com.facebook.react.runtime.ReactHostImpl { *; }
-keep class com.facebook.react.runtime.BridgelessReactContext { *; }
-keep class com.facebook.react.runtime.ReactInstance { *; }
-keep class com.facebook.react.modules.core.JavaTimerManager { *; }

-keep class com.facebook.react.ReactInstanceManager { *; }
-keep class com.facebook.react.ReactInstanceManager** { *; }
-keep class com.facebook.react.ReactInstanceEventListener { *; }
Expand All @@ -18,6 +26,10 @@
-keep class com.reactnativecommunity.asyncstorage.** { *; }

-keep class kotlin.reflect.** { *; }
-keep class kotlin.KotlinVersion { *; }
-keep class kotlin.sequences.** { *; }
-keep class kotlin.Triple { *; }
-keep class kotlin.properties.** { *; }
-keep class kotlin.coroutines.CoroutineDispatcher { *; }
-keep class kotlin.coroutines.CoroutineScope { *; }
-keep class kotlin.coroutines.CoroutineContext { *; }
Expand Down
7 changes: 4 additions & 3 deletions detox/android/detox/src/full/java/com/wix/detox/DetoxMain.kt
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,11 @@ object DetoxMain {
* not by instrumentation itself, but based on the `AppWillTerminateWithError` message; In it's own, it is a good
* thing, but for a reason we're not sure of yet, it is ignored by the test runner at this point in the flow.
*/
@Synchronized
private fun launchActivityOnCue(rnHostHolder: Context, activityLaunchHelper: ActivityLaunchHelper) {
awaitHandshake()
launchActivity(rnHostHolder, activityLaunchHelper)
synchronized(this) {
awaitHandshake()
launchActivity(rnHostHolder, activityLaunchHelper)
}
}

private fun awaitHandshake() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import com.facebook.react.ReactApplication;
import com.wix.detox.common.UIThread;
import com.wix.detox.reactnative.ReactNativeExtension;
import com.wix.detox.reactnative.idlingresources.NetworkIdlingResource;
import com.wix.detox.reactnative.idlingresources.network.NetworkIdlingResource;

import org.hamcrest.Matcher;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.wix.detox.reactnative

import android.annotation.SuppressLint
import com.facebook.react.ReactApplication
import com.facebook.react.ReactInstanceManager
import com.facebook.react.bridge.ReactContext
import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint


fun ReactApplication.getInstanceManagerSafe(): ReactInstanceManager {
return reactNativeHost.reactInstanceManager
?: throw RuntimeException("ReactInstanceManager is null!")
}

@SuppressLint("VisibleForTests")
fun ReactApplication.getCurrentReactContext(): ReactContext? {
return if (isFabricEnabled()) {
reactHost?.currentReactContext
} else {
getInstanceManagerSafe().currentReactContext
}
}

fun ReactApplication.getCurrentReactContextSafe(): ReactContext {
return getCurrentReactContext()
?: throw RuntimeException("ReactContext is null!")
}

/**
* A method to check if Fabric is enabled in the React Native application.
*/
fun isFabricEnabled(): Boolean {
return DefaultNewArchitectureEntryPoint.fabricEnabled
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ import android.content.Context
import android.util.Log
import androidx.test.platform.app.InstrumentationRegistry
import com.facebook.react.ReactApplication
import com.facebook.react.ReactInstanceManager
import com.facebook.react.bridge.ReactContext
import com.wix.detox.LaunchArgs
import com.wix.detox.reactnative.idlingresources.ReactNativeIdlingResources
import com.wix.detox.reactnative.reloader.ReactNativeReloaderFactory

private const val LOG_TAG = "DetoxRNExt"

Expand All @@ -33,9 +34,9 @@ object ReactNativeExtension {
}

(applicationContext as ReactApplication).let {
val reactContext = awaitNewReactNativeContext(it, null)
awaitNewReactNativeContext(it, null)

enableOrDisableSynchronization(reactContext)
enableOrDisableSynchronization(it)
}
}

Expand All @@ -56,15 +57,14 @@ object ReactNativeExtension {
Log.i(LOG_TAG, "Reloading React Native")

(applicationContext as ReactApplication).let {
val networkSyncEnabled = rnIdlingResources?.networkSyncEnabled ?: true
clearIdlingResources()

val previousReactContext = getCurrentReactContextSafe(it)
val previousReactContext = it.getCurrentReactContext()

reloadReactNativeInBackground(it)
val reactContext = awaitNewReactNativeContext(it, previousReactContext)
awaitNewReactNativeContext(it, previousReactContext)

enableOrDisableSynchronization(reactContext, networkSyncEnabled)
enableOrDisableSynchronization(it)
}
}

Expand All @@ -75,11 +75,7 @@ object ReactNativeExtension {

@JvmStatic
fun enableAllSynchronization(applicationContext: ReactApplication) {
val reactContext = getCurrentReactContextSafe(applicationContext)

if (reactContext != null) {
setupIdlingResources(reactContext)
}
setupIdlingResources(applicationContext)
}

@JvmStatic
Expand All @@ -88,16 +84,11 @@ object ReactNativeExtension {
@JvmStatic
fun getRNActivity(applicationContext: Context): Activity? {
if (ReactNativeInfo.isReactNativeApp()) {
return getCurrentReactContextSafe(applicationContext as ReactApplication)?.currentActivity
return (applicationContext as ReactApplication).getCurrentReactContext()?.currentActivity
}
return null
}

@JvmStatic
fun setNetworkSynchronization(enable: Boolean) {
rnIdlingResources?.setNetworkSynchronization(enable)
}

@JvmStatic
fun toggleNetworkSynchronization(enable: Boolean) {
rnIdlingResources?.let {
Expand All @@ -120,20 +111,27 @@ object ReactNativeExtension {
}

private fun reloadReactNativeInBackground(reactApplication: ReactApplication) {
val rnReloader = ReactNativeReLoader(InstrumentationRegistry.getInstrumentation(), reactApplication)
val rnReloader = ReactNativeReloaderFactory(InstrumentationRegistry.getInstrumentation(), reactApplication).create()
rnReloader.reloadInBackground()
}

private fun awaitNewReactNativeContext(reactApplication: ReactApplication, previousReactContext: ReactContext?): ReactContext {
val rnLoadingMonitor = ReactNativeLoadingMonitor(InstrumentationRegistry.getInstrumentation(), reactApplication, previousReactContext)
private fun awaitNewReactNativeContext(
reactApplication: ReactApplication,
previousReactContext: ReactContext?
): ReactContext {
val rnLoadingMonitor = ReactNativeLoadingMonitor(
InstrumentationRegistry.getInstrumentation(),
reactApplication,
previousReactContext
)
return rnLoadingMonitor.getNewContext()!!
}

private fun enableOrDisableSynchronization(reactContext: ReactContext, networkSyncEnabled: Boolean = true) {
private fun enableOrDisableSynchronization(reactApplication: ReactApplication) {
if (shouldDisableSynchronization()) {
clearAllSynchronization()
} else {
setupIdlingResources(reactContext, networkSyncEnabled)
setupIdlingResources(reactApplication)
}
}

Expand All @@ -142,10 +140,10 @@ object ReactNativeExtension {
return launchArgs.hasEnableSynchronization() && launchArgs.enableSynchronization.equals("0")
}

private fun setupIdlingResources(reactContext: ReactContext, networkSyncEnabled: Boolean = true) {
private fun setupIdlingResources(reactApplication: ReactApplication) {
val launchArgs = LaunchArgs()

rnIdlingResources = ReactNativeIdlingResources(reactContext, launchArgs, networkSyncEnabled).apply {
rnIdlingResources = ReactNativeIdlingResources(reactApplication, launchArgs).apply {
registerAll()
}
}
Expand All @@ -155,12 +153,4 @@ object ReactNativeExtension {
rnIdlingResources = null
}

private fun getInstanceManagerSafe(reactApplication: ReactApplication): ReactInstanceManager {
return reactApplication.reactNativeHost.reactInstanceManager
?: throw RuntimeException("ReactInstanceManager is null!")
}

private fun getCurrentReactContextSafe(reactApplication: ReactApplication): ReactContext? {
return getInstanceManagerSafe(reactApplication).currentReactContext
}
}
Loading

0 comments on commit 759efac

Please sign in to comment.