Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down
24 changes: 9 additions & 15 deletions apps/brownfield-example-shared-tests/e2e/appleAppDetoxUtils.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ const {
} = require('@callstack/brownfield-example-shared-tests/e2e/e2eTestIds');
const { DETOX_TIMING } = require('./detoxTiming.cjs');
const {
assertDetoxTextMatches,
detoxLaunchArgs,
waitForVisible,
waitForNativeOverlayVisible,
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down
Loading