config:
  app: com.example.testapp

setup:
  - terminate_app
  - launch_app
  - wait: 3s

teardown:
  - terminate_app

tests:
  - name: if_screen - AI vision check
    steps:
      - tap: "Open Gallery"
      - wait: 2s
      # Use AI vision to check complex visual state (empty vs populated)
      - if_screen: "Empty gallery with no photos"
        then:
          - tap: "Import Photos"
          - wait: 5s
        else:
          - tap: "Select Photo"
      - verify_screen: "Photo selected or imported"

  - name: if_screen with nested element checks
    steps:
      - tap: "Profile"
      - wait: 2s
      # Combine vision check with element-based conditional
      - if_screen: "User profile with avatar visible"
        then:
          # Check if profile is editable
          - if_exists: "Edit Profile"
            then:
              - tap: "Edit Profile"
          else:
            - verify_screen: "View-only profile"
        else:
          - tap: "Sign In"

  - name: Combined element and screen checks
    steps:
      - tap: "Create"
      - wait: 1s
      # Level 1: Check premium status via element
      - if_exists: "Premium Badge"
        then:
          # Level 2: Verify premium UI is fully loaded
          - if_screen: "Advanced editor tools visible"
            then:
              - verify_screen: "Full premium features available"
            else:
              - tap: "Unlock Advanced Tools"
        else:
          # Level 2: Verify free tier UI
          - if_screen: "Basic editor interface"
            then:
              - verify_screen: "Free tier features"
            else:
              - verify_screen: "Unknown state"
