Skip to content

Commit 276db3b

Browse files
committed
test: convert detox patch-package patch to yarn patch style
this one needs frequent work, and yarn2 has built in patching this starts the conversion of our patches to built-in yarn2 style
1 parent 6083156 commit 276db3b

4 files changed

Lines changed: 158 additions & 72 deletions

File tree

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
diff --git a/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/network/NetworkIdlingResource.kt b/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/network/NetworkIdlingResource.kt
2+
index be01a0dbeeaebbada21810269e4e30d114bf4476..88af8da4545e4458d340c3b0b4e37f134efc33f7 100644
3+
--- a/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/network/NetworkIdlingResource.kt
4+
+++ b/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/network/NetworkIdlingResource.kt
5+
@@ -50,23 +50,6 @@ class NetworkIdlingResource(private val dispatcher: Dispatcher) : DetoxIdlingRes
6+
7+
@Synchronized
8+
override fun checkIdle(): Boolean {
9+
- busyResources.clear()
10+
-
11+
- val calls = dispatcher.runningCalls()
12+
- for (call in calls) {
13+
- val url = call.request().url.toString()
14+
-
15+
- if (!isUrlBlacklisted(url)) {
16+
- busyResources.add(url)
17+
- }
18+
- }
19+
-
20+
- if (busyResources.isNotEmpty()) {
21+
- Log.i(LOG_TAG, "Network is busy, with " + busyResources.size + " in-flight calls")
22+
- Choreographer.getInstance().postFrameCallback(this)
23+
- return false
24+
- }
25+
-
26+
notifyIdle()
27+
return true
28+
}
29+
diff --git a/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/timers/TimersIdlingResource.kt b/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/timers/TimersIdlingResource.kt
30+
index 462908c3427599bb06bf04ca2d4662d320519ff4..a367e18b34750a4f6d163be343fa3835a8b348ed 100644
31+
--- a/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/timers/TimersIdlingResource.kt
32+
+++ b/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/timers/TimersIdlingResource.kt
33+
@@ -32,15 +32,8 @@ class TimersIdlingResource @JvmOverloads constructor(
34+
35+
@SuppressLint("VisibleForTests")
36+
override fun checkIdle(): Boolean {
37+
- val isIdle = !timingModule.hasActiveTimersInRange(BUSY_WINDOW_THRESHOLD)
38+
-
39+
- if (isIdle) {
40+
- notifyIdle()
41+
- } else {
42+
- getChoreographer().postFrameCallback(this)
43+
- }
44+
-
45+
- return isIdle
46+
+ notifyIdle()
47+
+ return true
48+
}
49+
50+
override fun doFrame(frameTimeNanos: Long) {
51+
diff --git a/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/uimodule/fabric/FabricUIManagerIdlingResources.kt b/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/uimodule/fabric/FabricUIManagerIdlingResources.kt
52+
index d6db5d5d7a4173eae88d97bf06eaeaf8b38c3b94..a85ebdf5a30607459be68463b3238b6ff1caf97a 100644
53+
--- a/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/uimodule/fabric/FabricUIManagerIdlingResources.kt
54+
+++ b/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/uimodule/fabric/FabricUIManagerIdlingResources.kt
55+
@@ -20,47 +20,8 @@ class FabricUIManagerIdlingResources(
56+
private var isSteadyState: Boolean = false
57+
58+
override fun checkIdle(): Boolean {
59+
- val mountItemsCount = getMountItemsSize()
60+
- val viewCommandMountItemsCount = getViewCommandMountItemsSize()
61+
-
62+
- if (mountItemsCount == 0 && viewCommandMountItemsCount == 0) {
63+
- firstBusyTimestamp = 0
64+
- isSteadyState = false
65+
- notifyIdle()
66+
- return true
67+
- }
68+
-
69+
- // Once we've determined this is a steady-state (a stuck mount item that never
70+
- // resolves), keep reporting idle as long as the count stays low.
71+
- if (isSteadyState && mountItemsCount <= 1 && viewCommandMountItemsCount == 0) {
72+
- notifyIdle()
73+
- return true
74+
- }
75+
-
76+
- // Count increased beyond steady-state threshold — reset and treat as genuinely busy.
77+
- if (isSteadyState) {
78+
- isSteadyState = false
79+
- firstBusyTimestamp = 0
80+
- }
81+
-
82+
- val now = SystemClock.uptimeMillis()
83+
- if (firstBusyTimestamp == 0L) {
84+
- firstBusyTimestamp = now
85+
- }
86+
-
87+
- // On API 36+, edge-to-edge enforcement can cause a single mount item to remain
88+
- // permanently in the queue on older RN versions. If the count stays at 1 for over
89+
- // 1.5s, treat it as a steady-state condition rather than a genuinely busy UI.
90+
- if (now - firstBusyTimestamp >= BUSY_TOLERANCE_MS
91+
- && mountItemsCount <= 1
92+
- && viewCommandMountItemsCount == 0) {
93+
- isSteadyState = true
94+
- notifyIdle()
95+
- return true
96+
- }
97+
-
98+
- Choreographer.getInstance().postFrameCallback(this)
99+
- return false
100+
+ notifyIdle()
101+
+ return true
102+
}
103+
104+
override fun registerIdleTransitionCallback(callback: IdlingResource.ResourceCallback?) {

tests/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
"assert": "^2.1.0",
4646
"axios": "^1.15.2",
4747
"cpy-cli": "^7.0.0",
48-
"detox": "20.51.0",
48+
"detox": "patch:detox@npm%3A20.51.0#~/.yarn/patches/detox-npm-20.51.0-3e13b6e309.patch",
4949
"firebase": "^12.12.1",
5050
"firebase-tools": "^15.16.0",
5151
"jest-circus": "^30.3.0",

tests/patches/detox+20.50.1.patch

Lines changed: 0 additions & 70 deletions
This file was deleted.

yarn.lock

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10999,6 +10999,58 @@ __metadata:
1099910999
languageName: node
1100011000
linkType: hard
1100111001

11002+
"detox@patch:detox@npm%3A20.51.0#~/.yarn/patches/detox-npm-20.51.0-3e13b6e309.patch":
11003+
version: 20.51.0
11004+
resolution: "detox@patch:detox@npm%3A20.51.0#~/.yarn/patches/detox-npm-20.51.0-3e13b6e309.patch::version=20.51.0&hash=9a9476"
11005+
dependencies:
11006+
"@wix-pilot/core": "npm:^3.4.2"
11007+
"@wix-pilot/detox": "npm:^1.0.13"
11008+
ajv: "npm:^8.6.3"
11009+
bunyan: "npm:^1.8.12"
11010+
bunyan-debug-stream: "npm:^3.1.0"
11011+
caf: "npm:^15.0.1"
11012+
chalk: "npm:^4.0.0"
11013+
execa: "npm:^5.1.1"
11014+
find-up: "npm:^5.0.0"
11015+
fs-extra: "npm:^11.0.0"
11016+
funpermaproxy: "npm:^1.1.0"
11017+
glob: "npm:^8.0.3"
11018+
ini: "npm:^1.3.4"
11019+
jest-environment-emit: "npm:^1.2.0"
11020+
json-cycle: "npm:^1.3.0"
11021+
lodash: "npm:^4.17.11"
11022+
multi-sort-stream: "npm:^1.0.3"
11023+
multipipe: "npm:^4.0.0"
11024+
node-ipc: "npm:9.2.1"
11025+
promisify-child-process: "npm:^4.1.2"
11026+
proper-lockfile: "npm:^3.0.2"
11027+
resolve-from: "npm:^5.0.0"
11028+
sanitize-filename: "npm:^1.6.1"
11029+
semver: "npm:^7.0.0"
11030+
serialize-error: "npm:^8.0.1"
11031+
shell-quote: "npm:^1.7.2"
11032+
signal-exit: "npm:^3.0.3"
11033+
stream-json: "npm:^1.7.4"
11034+
strip-ansi: "npm:^6.0.1"
11035+
telnet-client: "npm:1.2.8"
11036+
tmp: "npm:^0.2.1"
11037+
trace-event-lib: "npm:^1.3.1"
11038+
which: "npm:^1.3.1"
11039+
ws: "npm:^7.0.0"
11040+
yargs: "npm:^17.0.0"
11041+
yargs-parser: "npm:^21.0.0"
11042+
yargs-unparser: "npm:^2.0.0"
11043+
peerDependencies:
11044+
jest: 30.x.x || 29.x.x || 28.x.x || ^27.2.5
11045+
peerDependenciesMeta:
11046+
jest:
11047+
optional: true
11048+
bin:
11049+
detox: local-cli/cli.js
11050+
checksum: 10/cdf7cb647640107a3435e0d281db4c5eea421f0ebb8e9f5ea0e5e0016afcdf90a50fda63d2483e9552b878066b88b7ad1ec2f682f696a072f9865a7742a2feaa
11051+
languageName: node
11052+
linkType: hard
11053+
1100211054
"devlop@npm:^1.0.0, devlop@npm:^1.1.0":
1100311055
version: 1.1.0
1100411056
resolution: "devlop@npm:1.1.0"
@@ -22006,7 +22058,7 @@ __metadata:
2200622058
assert: "npm:^2.1.0"
2200722059
axios: "npm:^1.15.2"
2200822060
cpy-cli: "npm:^7.0.0"
22009-
detox: "npm:20.51.0"
22061+
detox: "patch:detox@npm%3A20.51.0#~/.yarn/patches/detox-npm-20.51.0-3e13b6e309.patch"
2201022062
firebase: "npm:^12.12.1"
2201122063
firebase-tools: "npm:^15.16.0"
2201222064
jest-circus: "npm:^30.3.0"

0 commit comments

Comments
 (0)