# settings/dark-theme.yaml
# Tests: Login → Header dropdown → Settings → Theme picker → Dark mode selected.
# Pre-requisite: App installed. Test-user exists on staging.
# Env-Vars: E2E_TEST_USER, E2E_TEST_PASSWORD
# Expected outcome: After selecting "Dunkel", Settings screen reflects dark theme
#                   (background color changes — Maestro cannot assert CSS, but
#                    assertVisible on a dark-only element or the "Dunkel" value chip
#                    confirms the selection was persisted in local store).
#
# IMPORTANT: Theme is stored in MMKV (useThemeStore). clearState: true resets it
# to 'system' each run — so this flow always starts from system default.
#
# The theme menu is a @react-native-menu/menu MenuView (native iOS context menu).
# Maestro can trigger the anchor Pressable but may NOT be able to interact with
# the native UIMenu popover on iOS. If this step fails, it is a Maestro limitation
# with native context menus — add to SETUP.md known issues.
# Alternative: implement a test-only theme toggle button accessible via testID.
# See TODO_TESTIDS.md.

appId: org.rebreak.app
---
- launchApp:
    clearState: true

- waitForAnimationToEnd:
    timeout: 5000

# --- Auth ---
- assertVisible:
    text: "E-Mail"
- tapOn:
    text: "E-Mail"
- inputText: ${E2E_TEST_USER}@rebreak.internal
- tapOn:
    text: "Passwort"
- inputText: ${E2E_TEST_PASSWORD}
- tapOn:
    text: "Anmelden"
- waitForAnimationToEnd:
    timeout: 10000

- assertVisible:
    text: "ReBreak"

# Open Header dropdown → Settings
- tapOn:
    point: "93%, 6%"
- waitForAnimationToEnd:
    timeout: 2000

# t('headerMenu.settings') = "Einstellungen" (de.json)
- assertVisible:
    text: "Einstellungen"
- tapOn:
    text: "Einstellungen"
- waitForAnimationToEnd:
    timeout: 3000

# Settings screen: AppHeader title = t('settings.title') = "Einstellungen"
- assertVisible:
    text: "Einstellungen"

# Theme section: t('settings.theme') = "Erscheinungsbild" (de.json) — row label.
# The current value chip shows t('settings.theme_system') = "Systemstandard" initially.
- assertVisible:
    text: "Erscheinungsbild"

# Tap the value chip (MenuView anchor Pressable) to open iOS UIMenu.
# WARNING: Native UIMenu interaction may not work in Maestro — see header note.
# We tap on the current value "Systemstandard" which is inside the anchor Pressable.
- tapOn:
    text: "Systemstandard"
- waitForAnimationToEnd:
    timeout: 1500

# iOS native UIMenu: items are "Systemstandard", "Hell", "Dunkel"
# t('settings.theme_dark') = "Dunkel" (de.json)
- tapOn:
    text: "Dunkel"
- waitForAnimationToEnd:
    timeout: 1500

# After selection: the value chip in the row should now show "Dunkel"
- assertVisible:
    text: "Dunkel"
