# Verifies the online/offline toggle works and reflects in the UI.
# This is independent of the customer side — pure mitra UI test.
#
# Stage 2 replaced the Switch widget with a single "Ganti Status" CTA on
# the online variant (and "Nyalain Status (Online)" on the offline variant).
# The status card copy ("Kamu lagi ONLINE" / "Kamu lagi OFFLINE") is the
# stable marker for the current state.
#
# A more thorough version of this test is now in
# ts-mitra-1-03-toggle_online_to_offline.yaml — that one walks the full
# auth flow and screenshots both states. This file keeps the lightweight
# variant for fast smoke iteration on a pre-signed-in device.
#
# Run:
#   maestro test mitra_app/.maestro/flows/02_online_offline_toggle.yaml
appId: ${APP_ID_ANDROID}
---
- launchApp:
    clearState: false

# Establish baseline — exactly one of the two status-card labels is up.
- assertVisible:
    text: "(?s).*Kamu lagi (ONLINE|OFFLINE).*"

# Tap whichever CTA is currently rendered. Online → "Ganti Status".
# Offline → "Nyalain Status (Online)". The regex matches both.
- tapOn: "(?s).*(Ganti Status|Nyalain Status \\(Online\\)).*"

# After the POST /api/mitra/status/{online,offline} response lands, the
# opposite status label should be visible within ~2s.
- extendedWaitUntil:
    visible:
      text: "(?s).*Kamu lagi (ONLINE|OFFLINE).*"
    timeout: 5000
