appId: dev.expo.updatese2e
onFlowStart:
  - runFlow:
      file: beforeEach.yml
---
# update with bad asset hash yields expected log entry, and does not run
- evalScript:
    script:  ${output.api.serveManifest('test-update-with-invalid-asset-hash', MAESTRO_PLATFORM)}
    label: Setup updates server to serve an update with invalid asset hash
    env:
      MAESTRO_PLATFORM: ${MAESTRO_PLATFORM}
- launchApp
- copyTextFrom:
    label: Copy text from update string
    id: updateString
- evalScript:
    script: ${output.api.delay(3000)}
    label: Delay for 3 seconds
- assertTrue:
    condition: ${maestro.copiedText == "test"}
    label: Assert update string is from embedded bundle
- assertTrue:
    condition:  ${output.api.staticFileCount() == 4}
    label: Assert that exactly 4 static files were requested
- stopApp
- launchApp
- copyTextFrom:
    label: Copy text from update string
    id: updateString
- assertTrue:
    condition: ${maestro.copiedText == "test"}
    label: Assert update string is from embedded bundle (update not applied)
- tapOn:
    label: Tap on read log entries
    id: readLogEntries
- evalScript:
    script: ${output.api.delay(500)}
    label: Delay for 0.5 seconds
- evalScript:
    script: ${output.logs = output.api.logEntries()}
    label: Read log entries uploaded to server
- assertTrue:
    condition: ${output.logs.length > 0}
    label: Assert that logs were uploaded
- assertTrue:
    condition: ${JSON.stringify(output.logs).includes("AssetsFailedToLoad")}
    label: Assert that the update failed to apply due to an invalid asset hash
- stopApp
