From ca59bcee1562660d0c21074e78740fb0fff9e8c5 Mon Sep 17 00:00:00 2001 From: artus9033 Date: Mon, 6 Jul 2026 13:25:50 +0200 Subject: [PATCH] fix(test): stabilize postMessage toast E2E test on iOS --- .../e2e/appleAppBrownfield.e2e.js | 2 +- .../e2e/appleAppDetoxUtils.cjs | 24 +++++++------------ .../e2e/appleAppExpoBrownfield.e2e.js | 2 +- 3 files changed, 11 insertions(+), 17 deletions(-) diff --git a/apps/brownfield-example-shared-tests/e2e/appleAppBrownfield.e2e.js b/apps/brownfield-example-shared-tests/e2e/appleAppBrownfield.e2e.js index dcae1226..f1f8a7a9 100644 --- a/apps/brownfield-example-shared-tests/e2e/appleAppBrownfield.e2e.js +++ b/apps/brownfield-example-shared-tests/e2e/appleAppBrownfield.e2e.js @@ -37,7 +37,7 @@ describe('Brownfield (AppleApp — Vanilla)', () => { }); it('shows a native toast when RN sends postMessage', async () => { - await sendPostMessageToNativeAndWaitForToast(/Hello from React Native!/); + await sendPostMessageToNativeAndWaitForToast(); }); it('navigates to native settings from the RN surface', async () => { diff --git a/apps/brownfield-example-shared-tests/e2e/appleAppDetoxUtils.cjs b/apps/brownfield-example-shared-tests/e2e/appleAppDetoxUtils.cjs index b0f8cfc1..013f29b2 100644 --- a/apps/brownfield-example-shared-tests/e2e/appleAppDetoxUtils.cjs +++ b/apps/brownfield-example-shared-tests/e2e/appleAppDetoxUtils.cjs @@ -4,7 +4,6 @@ const { } = require('@callstack/brownfield-example-shared-tests/e2e/e2eTestIds'); const { DETOX_TIMING } = require('./detoxTiming.cjs'); const { - assertDetoxTextMatches, detoxLaunchArgs, waitForVisible, waitForNativeOverlayVisible, @@ -260,25 +259,20 @@ async function openPostMessageTabExpo() { ); } -async function sendPostMessageToNativeAndWaitForToast(rnMessagePattern) { +async function sendPostMessageToNativeAndWaitForToast() { await waitForVisible( by.id(ids.sendMessageToNative), DETOX_TIMING.VISIBILITY_TIMEOUT_MS ); - await element(by.id(ids.sendMessageToNative)).tap(); - const bubble = element(by.id(ids.rnPostMessageText)).atIndex(0); - const deadline = Date.now() + DETOX_TIMING.POST_MESSAGE_BUBBLE_TIMEOUT_MS; - while (Date.now() < deadline) { - try { - await assertDetoxTextMatches(bubble, rnMessagePattern); - break; - } catch { - await new Promise((resolve) => - setTimeout(resolve, DETOX_TIMING.POLL_INTERVAL_MS) - ); - } + // Tap with sync off — embedded Expo can keep Detox busy while native UI is ready. + await device.disableSynchronization(); + try { + await element(by.id(ids.sendMessageToNative)).tap(); + } finally { + await device.enableSynchronization(); } - await assertDetoxTextMatches(bubble, rnMessagePattern); + // Assert toast before RN bubble: E2E toast is visible for ~10s and can dismiss + // while Fabric/accessibility catches up on the message list. await waitForNativeOverlayVisible( by.id(ids.appleAppPostMessageToast), DETOX_TIMING.TOAST_VISIBILITY_TIMEOUT_MS diff --git a/apps/brownfield-example-shared-tests/e2e/appleAppExpoBrownfield.e2e.js b/apps/brownfield-example-shared-tests/e2e/appleAppExpoBrownfield.e2e.js index 06e8621f..fbed8661 100644 --- a/apps/brownfield-example-shared-tests/e2e/appleAppExpoBrownfield.e2e.js +++ b/apps/brownfield-example-shared-tests/e2e/appleAppExpoBrownfield.e2e.js @@ -30,7 +30,7 @@ describe('Brownfield (AppleApp — Expo)', () => { it('shows a native toast when Expo RN sends postMessage', async () => { await openPostMessageTabExpo(); - await sendPostMessageToNativeAndWaitForToast(/Hello from Expo!/); + await sendPostMessageToNativeAndWaitForToast(); }); it('records the RN postMessage bubble in the Expo surface', async () => {