Skip to content

Commit 2a7b305

Browse files
authored
[visual testing] open-example: Wait for RNTester to render before linking
RNTester ignores a deep link until its JS has rendered, but `open-example.yml` only waits for animations to end - which on a fresh iOS simulator happens ~1.4s after relaunch, before RNTester takes links at ~2.7s. Since #59994 sent the link once on iOS, 17 of 25 iOS capture jobs had a flow fail its first attempt this way (29 failures across almost every flow), and in one job the retries ran out. This waits for the "Components" label in RNTester's tab bar, which is on every screen including a restored example, before linking. The five button and switch flows that only waited for `example-container` - which a restored previous example also has, so a missed link could screenshot the wrong screen - now wait for an element only their example has. Changelog: [Internal] Test plan: Ran every visual flow once (no Maestro retries) on a freshly erased iPhone 17 Pro simulator (iOS 27) with RNTester Release from CI. Locally the drop is deterministic: | Before the link | Result | |---|---| | `main` (wait for animations) | All 12 flows failed | | This PR (wait for "Components") | All 12 flows passed, 3/3 runs, ~8 min each. The wait took 2.7s median, 3.1s max | On CI, an earlier revision with the same wait (plus a relaunch retry, which never fired) passed all 12 flows on the first attempt on both iOS and Android (run 43580332516). `maestro check-syntax` passes for every flow. Differential Revision: D132259421 Pull Request resolved: #60004
1 parent 7483043 commit 2a7b305

4 files changed

Lines changed: 13 additions & 18 deletions

File tree

‎packages/rn-tester/visual-tests/README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ The baseline for a PR is the one for the commit it's based on, or the nearest ea
3636
id: 'text-width-mode-example'
3737
```
3838
39-
`open-example.yml` deep-links to `rntester://example/<module>/<example>`. Wait for something that's only visible once the example has rendered, and crop to the example's `testID` so that the status bar and surrounding UI aren't part of the screenshot.
39+
`open-example.yml` deep-links to `rntester://example/<module>/<example>`. Wait for something that's only visible once the example has rendered, and that only this example has (not the generic `example-container`, which a restored previous example also has), and crop to the example's `testID` so that the status bar and surrounding UI aren't part of the screenshot.
4040

4141
3. Open a PR. The new test has no baseline yet, so the report lists it as new, and like any other difference it needs a maintainer's approval (see below). Once the PR lands, `main` is captured with it and later PRs are compared against that.
4242

‎packages/rn-tester/visual-tests/flows/button.yml‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ appId: ${APP_ID}
66
EXAMPLE_URL: rntester://example/ButtonExample/default-styling
77
- extendedWaitUntil:
88
visible:
9-
id: 'example-container'
9+
id: 'button_default_styling'
1010
timeout: 15000
1111
- waitForAnimationToEnd:
1212
timeout: 5000
@@ -20,7 +20,7 @@ appId: ${APP_ID}
2020
EXAMPLE_URL: rntester://example/ButtonExample/disabled
2121
- extendedWaitUntil:
2222
visible:
23-
id: 'example-container'
23+
id: 'disabled_button'
2424
timeout: 15000
2525
- waitForAnimationToEnd:
2626
timeout: 5000
@@ -34,7 +34,7 @@ appId: ${APP_ID}
3434
EXAMPLE_URL: rntester://example/ButtonExample/color-red
3535
- extendedWaitUntil:
3636
visible:
37-
id: 'example-container'
37+
id: 'cancel_button'
3838
timeout: 15000
3939
- waitForAnimationToEnd:
4040
timeout: 5000
@@ -48,7 +48,7 @@ appId: ${APP_ID}
4848
EXAMPLE_URL: rntester://example/ButtonExample/two-buttons-flexbox
4949
- extendedWaitUntil:
5050
visible:
51-
id: 'example-container'
51+
id: 'two_cancel_button'
5252
timeout: 15000
5353
- waitForAnimationToEnd:
5454
timeout: 5000

‎packages/rn-tester/visual-tests/flows/switch.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ appId: ${APP_ID}
4040
EXAMPLE_URL: rntester://example/SwitchExample/disabled
4141
- extendedWaitUntil:
4242
visible:
43-
id: 'example-container'
43+
id: 'disabled-initial-off'
4444
timeout: 15000
4545
- assertVisible:
4646
id: 'disabled-initial-off'

‎packages/rn-tester/visual-tests/helpers/open-example.yml‎

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,15 @@ appId: ${APP_ID} # iOS: com.meta.RNTester.localDevelopment | Android: com.facebo
22
---
33
- launchApp:
44
stopApp: true
5-
- waitForAnimationToEnd:
5+
# RNTester ignores links until its JS has rendered, which waiting for
6+
# animations to end doesn't guarantee. Its tab bar shows "Components" on every
7+
# screen, including a restored example. Optional, so that a missed link fails
8+
# at the flow's own check for its example instead.
9+
- extendedWaitUntil:
10+
visible: 'Components'
611
timeout: 30000
12+
optional: true
713
- openLink: ${EXAMPLE_URL}
8-
# On a slow Android emulator, the first link can arrive before the JS Linking
9-
# listener is registered and be dropped, so Android sends it again once settled.
10-
# On iOS, each link raises an "Open in RNTester?" dialog, so it's sent once and
11-
# accepted. A second, unaccepted dialog leaves RNTester on the previous screen.
12-
- runFlow:
13-
when:
14-
platform: Android
15-
commands:
16-
- waitForAnimationToEnd:
17-
timeout: 15000
18-
- openLink: ${EXAMPLE_URL}
1914
- runFlow:
2015
when:
2116
platform: iOS

0 commit comments

Comments
 (0)