# community/create-post.yaml
# Tests: Login → Home-Feed → ComposeCard → type text → publish → ComposeCard resets.
# Pre-requisite: App installed. Test-user exists on staging.
# Env-Vars: E2E_TEST_USER, E2E_TEST_PASSWORD
# Expected outcome: After tapping "Teilen", ComposeCard resets to idle state
#                   (placeholder text visible again). Post is created in staging DB.
#
# NOTE: This flow creates a real post on staging. No automatic cleanup.
#       Delete via Service-Role or Supabase dashboard after test runs.
#
# ComposeCard placeholder = t('community.compose_placeholder') = "Was bewegt dich gerade?" (de.json)
# Share button = t('community.share') = "Teilen" (de.json)

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

# --- Home-Feed ---
- assertVisible:
    text: "ReBreak"

# ComposeCard sits at top of Home feed (/(app)/index.tsx).
# Scroll up first to make sure we're at the top.
- scrollUntilVisible:
    element:
      text: "Was bewegt dich gerade?"
    direction: UP
    timeout: 4000

- assertVisible:
    text: "Was bewegt dich gerade?"

# Tap placeholder to focus the TextInput (sets focused=true, showActions=true)
- tapOn:
    text: "Was bewegt dich gerade?"
- waitForAnimationToEnd:
    timeout: 1000

# Type post content — unique enough to find in DB for cleanup
- inputText: "[E2E] Maestro-Testpost — bitte ignorieren."

# After text input: action row appears with "Teilen" button
- assertVisible:
    text: "Teilen"

# Submit. API call: POST /api/community/post → returns 200 → queryClient invalidates
- tapOn:
    text: "Teilen"
- waitForAnimationToEnd:
    timeout: 8000

# After success: cancel() is called → content reset → ComposeCard shows placeholder again
- assertVisible:
    text: "Was bewegt dich gerade?"
