appId: com.edde746.plezy
---
- retry:
    maxRetries: 1
    commands:
      - launchApp:
          clearState: true
          permissions:
            all: allow
      - extendedWaitUntil:
          visible: "(?s)^(?:Connect to Jellyfin|Wait).*"
          timeout: 30000
      # A miss on `tapOn ... optional: true` still runs Maestro's full element
      # search before giving up, which measured 3s here and 7.8s for "Sign in"
      # on every onboarding. These taps normally find nothing, so gate them on
      # a single visibility check instead.
      - runFlow:
          when:
            visible: "Wait"
          commands:
            - tapOn: "Wait"
      - extendedWaitUntil:
          visible: "Connect to Jellyfin"
          timeout: 30000
- tapOn: "Connect to Jellyfin"
- extendedWaitUntil:
    visible: "Add Jellyfin server"
    timeout: 10000
- tapOn: "(?s)Server URLs.*"
- inputText: ${JELLYFIN_URL}
- tapOn: "Find server"
- extendedWaitUntil:
    visible: "Maestro Jellyfin"
    timeout: 15000
- tapOn: "Username"
- inputText: "maestro"
- tapOn: "Password"
- inputText: "maestro"
- pressKey: ENTER
- retry:
    maxRetries: 1
    commands:
      - runFlow:
          when:
            visible: "Sign in"
          commands:
            - tapOn: "Sign in"
      - extendedWaitUntil:
          visible: "Discover"
          timeout: 30000
