|
1 | | -# Reusable navigation helper: launch the app, open a category, open a demo. |
| 1 | +# Reusable navigation helper: get the app to ``"Demo: <DEMO_TITLE>"`` |
| 2 | +# from whatever screen we happen to be on. |
2 | 3 | # |
3 | 4 | # Callers pass two env vars: |
4 | 5 | # |
5 | 6 | # CATEGORY: "Hooks" |
6 | 7 | # DEMO_TITLE: "use_state" |
7 | 8 | # |
8 | | -# This flow leaves the app on the corresponding demo screen with |
9 | | -# ``"Demo: <DEMO_TITLE>"`` visible, ready for the caller's assertions. |
| 9 | +# This helper is *state-aware*: it does the minimum work needed to land |
| 10 | +# on the target demo. The full suite spends most of its time replaying |
| 11 | +# the same launch + nav-home + nav-category dance between every flow, |
| 12 | +# so the suite-wide speedup from short-circuiting these steps is |
| 13 | +# significant (and it removes a lot of ``launchApp`` calls, which is |
| 14 | +# where Maestro's iOS XCUITest driver tends to flake). |
| 15 | +# |
| 16 | +# State machine, evaluated top-to-bottom; each block runs only if the |
| 17 | +# previous one's effects still leave us off-target: |
| 18 | +# |
| 19 | +# 1. On a demo screen ("Back to list" visible) |
| 20 | +# -> tap "Back to list", now on some category screen. |
| 21 | +# 2. On the wrong category screen ("Back to home" visible, but title |
| 22 | +# != ``Demos in ${CATEGORY}``) |
| 23 | +# -> tap "Back to home", now on the home screen. |
| 24 | +# 3. App is dead (neither right category nor home visible) |
| 25 | +# -> ``launchApp``, now on the home screen. |
| 26 | +# 4. On the home screen (but not yet on the right category) |
| 27 | +# -> tap ``Open ${CATEGORY}``, now on the right category screen. |
| 28 | +# 5. On the right category screen |
| 29 | +# -> tap ``Open: ${DEMO_TITLE}``, now on the target demo. |
10 | 30 | # |
11 | 31 | # Both the home and category screens use a ScrollView and the target |
12 | | -# button can be below the visible fold (especially in the Components |
13 | | -# category, which lists 20+ demos). Maestro's ``tapOn`` does not |
14 | | -# auto-scroll, so we explicitly ``scrollUntilVisible`` before each tap. |
15 | | -# It's a no-op when the element is already on screen, so the helper is |
16 | | -# safe to use for short lists too. |
| 32 | +# button can be below the visible fold (Components has 20+ demos). |
| 33 | +# Maestro's ``tapOn`` does not auto-scroll, so we ``scrollUntilVisible`` |
| 34 | +# before each tap. iOS also preserves a ScrollView's offset across |
| 35 | +# navigation, so we scroll UP to surface the title before asserting. |
17 | 36 | appId: ${APP_ID} |
18 | 37 | --- |
19 | | -- launchApp |
20 | | -- extendedWaitUntil: |
21 | | - visible: "E2E Suite home" |
22 | | - timeout: 60000 |
23 | | -- scrollUntilVisible: |
24 | | - element: |
25 | | - text: "Open ${CATEGORY}" |
26 | | - direction: DOWN |
27 | | -- tapOn: "Open ${CATEGORY}" |
28 | | -- extendedWaitUntil: |
29 | | - visible: "Demos in ${CATEGORY}" |
30 | | - timeout: 15000 |
| 38 | +# 1. If we landed on a demo screen, pop one level to its category list. |
| 39 | +- runFlow: |
| 40 | + when: |
| 41 | + visible: "Back to list" |
| 42 | + commands: |
| 43 | + - tapOn: "Back to list" |
| 44 | + - extendedWaitUntil: |
| 45 | + visible: "Back to home" |
| 46 | + timeout: 15000 |
| 47 | + |
| 48 | +# 2. If we're on the wrong category, go back to home. |
| 49 | +- runFlow: |
| 50 | + when: |
| 51 | + visible: "Back to home" |
| 52 | + notVisible: "Demos in ${CATEGORY}" |
| 53 | + commands: |
| 54 | + - scrollUntilVisible: |
| 55 | + element: |
| 56 | + text: "Back to home" |
| 57 | + direction: DOWN |
| 58 | + - tapOn: "Back to home" |
| 59 | + - scrollUntilVisible: |
| 60 | + element: |
| 61 | + text: "E2E Suite home" |
| 62 | + direction: UP |
| 63 | + timeout: 15000 |
| 64 | + - assertVisible: "E2E Suite home" |
| 65 | + |
| 66 | +# 3. If neither the right category nor the home screen is visible, the |
| 67 | +# app is either not running yet (first flow of the suite) or the driver |
| 68 | +# lost its connection. Relaunch as a cold start. |
| 69 | +- runFlow: |
| 70 | + when: |
| 71 | + notVisible: "Demos in ${CATEGORY}" |
| 72 | + commands: |
| 73 | + - runFlow: |
| 74 | + when: |
| 75 | + notVisible: "E2E Suite home" |
| 76 | + commands: |
| 77 | + - launchApp |
| 78 | + - extendedWaitUntil: |
| 79 | + visible: "E2E Suite home" |
| 80 | + timeout: 60000 |
| 81 | + |
| 82 | +# 4. From the home screen, navigate into the right category. |
| 83 | +- runFlow: |
| 84 | + when: |
| 85 | + visible: "E2E Suite home" |
| 86 | + notVisible: "Demos in ${CATEGORY}" |
| 87 | + commands: |
| 88 | + - scrollUntilVisible: |
| 89 | + element: |
| 90 | + text: "Open ${CATEGORY}" |
| 91 | + direction: DOWN |
| 92 | + - tapOn: "Open ${CATEGORY}" |
| 93 | + - extendedWaitUntil: |
| 94 | + visible: "Demos in ${CATEGORY}" |
| 95 | + timeout: 15000 |
| 96 | + |
| 97 | +# 5. We're now guaranteed to be on the right category list. Open the |
| 98 | +# requested demo. |
31 | 99 | - scrollUntilVisible: |
32 | 100 | element: |
33 | 101 | text: "Open: ${DEMO_TITLE}" |
|
0 commit comments