> For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt.

# subflows/handle-e2e-ad.yaml

[Source](https://github.com/leapgame/leap-sim-piano/blob/f794b594016038c483e2d20b6af56aea0ae1b982/.maestro/subflows/handle-e2e-ad.yaml)

```yaml
appId: ${APP_ID}
---
# Meets the fake interstitial that may open now (EXPO_PUBLIC_E2E_ADS=1: `e2e-ad-interstitial`, labelled
# "E2E interstitial #<n>", n counted since launch) and closes it, checking the No Ads popup rule:
#   ${WAIT_MS}  how long an ad may take to open (it opens right after a song end or a song-row tap)
#   ${EARLY}    regex of the labels BEFORE the popup's turn: after closing one, the popup must not open
#   ${MODE}     "expect": close every ad (the popup may open after a later one)
#               "never":  close the early ones only; leave a later one up, the caller's loop stops on it
- extendedWaitUntil:
    visible:
      id: "e2e-ad-interstitial"
    timeout: ${WAIT_MS}
    optional: true
- runFlow:
    when:
      visible:
        id: "e2e-ad-interstitial"
        text: ${EARLY}
    commands:
      - tapOn:
          id: "e2e-ad-close"
      # Give the popup its full chance before saying it did not open: it would open over the result,
      # after the result's reveal. (After a song-row ad the song starts instead; the wait just runs out.)
      - extendedWaitUntil:
          visible:
            id: "session-action-songs"
          timeout: 15000
          optional: true
      - runFlow:
          file: sleep.yaml
          env:
            MS: "5000"
      - assertNotVisible:
          id: "noads-popup-close"
- runFlow:
    when:
      true: ${MODE == 'expect'}
      visible:
        id: "e2e-ad-interstitial"
    commands:
      - tapOn:
          id: "e2e-ad-close"
      - runFlow:
          file: sleep.yaml
          env:
            MS: "4000"
```
