appId: dev.expo.updatese2e
onFlowStart:
  - runFlow:
      file: beforeEach.yml
---
- launchApp
- copyTextFrom:
    label: Copy text from update string
    id: updateString
- assertTrue:
    condition: ${maestro.copiedText == 'test'}
    label: Assert update string is from embedded bundle
- copyTextFrom:
    label: Copy text from ('channel')
    id: channel
- assertTrue:
    condition: ${maestro.copiedText == 'default'}
    label: Assert channel is default

# Send update to preview channel and verify new update
- evalScript:
    script: ${output.downloadedUpdateId = output.api.serveManifest('test-update-basic', MAESTRO_PLATFORM, 'preview')}
    label: Send new update to preview channel
    env:
      MAESTRO_PLATFORM: ${MAESTRO_PLATFORM}
- tapOn:
    label: Tap on check for update button
    id: checkForUpdate
- evalScript:
    script: ${output.api.delay(500)}
    label: Delay for 0.5 seconds
- copyTextFrom:
    label: Copy text from availableUpdateID
    id: availableUpdateID
- assertTrue:
    condition: ${maestro.copiedText == 'undefined'}
    label: Assert no update is available
- tapOn:
    label: Tap on toggleUpdateRequestHeadersOverride button
    id: toggleUpdateRequestHeadersOverride
- tapOn:
    label: Tap on check for update button
    id: checkForUpdate
- evalScript:
    script: ${output.api.delay(500)}
    label: Delay for 0.5 seconds
- copyTextFrom:
    label: Copy text from availableUpdateID
    id: availableUpdateID
- assertTrue:
    condition: ${maestro.copiedText == output.downloadedUpdateId}
    label: Assert correct update ID is available
- tapOn:
    label: Tap on download update button
    id: downloadUpdate
- evalScript:
    script: ${output.api.delay(1500)}
    label: Delay for 1.5 seconds
- tapOn: "reload"
- evalScript:
    script: ${output.api.delay(3000)}
    label: Delay for 3 seconds
- copyTextFrom:
    label: Copy text from update channel
    id: channel
- assertTrue:
    condition: ${maestro.copiedText == 'preview'}
    label: Assert update channel is the preview channel
- copyTextFrom:
    label: Copy text from update string
    id: updateID
- assertTrue:
    condition: ${maestro.copiedText == output.downloadedUpdateId}
    label: Assert update string is from downloaded bundle

# Send update to default channel and verify new update from default channel
- evalScript:
    script: ${output.downloadedUpdateId = output.api.serveManifest('test-update-basic', MAESTRO_PLATFORM, 'default')}
    label: Send new update to default channel
    env:
      MAESTRO_PLATFORM: ${MAESTRO_PLATFORM}
- tapOn:
    label: Tap on check for update button
    id: checkForUpdate
- evalScript:
    script: ${output.api.delay(500)}
    label: Delay for 0.5 seconds
- copyTextFrom:
    label: Copy text from availableUpdateID
    id: availableUpdateID
- assertTrue:
    condition: ${maestro.copiedText == 'undefined'}
    label: Assert no update is available
- tapOn:
    label: Tap on toggleUpdateRequestHeadersOverride button to reset channel
    id: toggleUpdateRequestHeadersOverride
- tapOn:
    label: Tap on check for update button
    id: checkForUpdate
- evalScript:
    script: ${output.api.delay(500)}
    label: Delay for 0.5 seconds
- copyTextFrom:
    label: Copy text from availableUpdateID
    id: availableUpdateID
- assertTrue:
    condition: ${maestro.copiedText == output.downloadedUpdateId}
    label: Assert correct update ID is available
- tapOn:
    label: Tap on download update button
    id: downloadUpdate
- evalScript:
    script: ${output.api.delay(1500)}
    label: Delay for 1.5 seconds
- tapOn: "reload"
- evalScript:
    script: ${output.api.delay(3000)}
    label: Delay for 3 seconds
- copyTextFrom:
    label: Copy text from update channel
    id: channel
- assertTrue:
    condition: ${maestro.copiedText == 'default'}
    label: Assert update channel reset to default
- copyTextFrom:
    label: Copy text from update string
    id: updateID
- assertTrue:
    condition: ${maestro.copiedText == output.downloadedUpdateId}
    label: Assert update string is from downloaded bundle
