Skip to content

Commit 41c5e84

Browse files
test(e2e): open the AppleApp RN screen with a coordinate tap
Detox's element tap injects a synthesized touch at the accessibility activation point, which SwiftUI's NavigationLink ignores: the tap was reported as successful, but the RN screen was never pushed. Tap the center of the Open React Native button through XCUITest (device.tap) instead, which delivers a real touch.
1 parent 365d202 commit 41c5e84

1 file changed

Lines changed: 16 additions & 1 deletion

File tree

‎apps/brownfield-example-shared-tests/e2e/appleAppDetoxUtils.cjs‎

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,12 +100,27 @@ async function waitForAppleAppReady() {
100100
await waitForVisible(OPEN_REACT_NATIVE_BUTTON, DETOX_TIMING.VISIBILITY_TIMEOUT_MS);
101101
}
102102

103+
/**
104+
* Tap the center of a SwiftUI control with a real (XCUITest) touch.
105+
*
106+
* Detox's element `tap()` injects a synthesized touch at the accessibility activation point.
107+
* SwiftUI's NavigationLink ignores it: Detox reports success, but nothing is pushed.
108+
* `device.tap` goes through XCUITest, which only accepts whole points in app coordinates.
109+
*/
110+
async function tapSwiftUIControl(matcher) {
111+
const { frame } = await element(matcher).getAttributes();
112+
await device.tap({
113+
x: Math.round(frame.x + frame.width / 2),
114+
y: Math.round(frame.y + frame.height / 2),
115+
});
116+
}
117+
103118
/** Push RNAppScreen from the native shell and wait until `isReady` resolves. */
104119
async function openReactNative(isReady) {
105120
await device.disableSynchronization();
106121
try {
107122
await waitForVisible(OPEN_REACT_NATIVE_BUTTON, DETOX_TIMING.VISIBILITY_TIMEOUT_MS);
108-
await element(OPEN_REACT_NATIVE_BUTTON).tap();
123+
await tapSwiftUIControl(OPEN_REACT_NATIVE_BUTTON);
109124
await isReady();
110125
} finally {
111126
await device.enableSynchronization();

0 commit comments

Comments
 (0)