#!/bin/bash
# ╔═══════════════════════════════════════════════════════════════════╗
# ║  [TEST NAME] — [DESCRIPTION]                                     ║
# ╠═══════════════════════════════════════════════════════════════════╣
# ║  CUSTOMIZE: Fill in the steps below for your test flow.           ║
# ║                                                                   ║
# ║  Usage: bash .pi/skills/qa-automation/qa-test-flows/flows/[suite]/[name].sh
# ╚═══════════════════════════════════════════════════════════════════╝

set -euo pipefail

# ── Source Libraries ─────────────────────────────────────────────────
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
source "$SCRIPT_DIR/../../lib/test-helpers.sh"
source "$SCRIPT_DIR/../../lib/cdp-helpers.sh"

# ── Test Setup ───────────────────────────────────────────────────────
# CUSTOMIZE: Change this test name
TEST_NAME="my-test-flow"
setup_test "$TEST_NAME"

# ── Step 1: [Description] ───────────────────────────────────────────
step "Verify app is running"
assert_app_foreground || launch_app
take_screenshot "01-initial"

# ── Step 2: [Navigation] ────────────────────────────────────────────
# CUSTOMIZE: Navigate to your target screen
step "Navigate to target screen"
cdp_navigate "YourScreenName"  # or: tap_tab 1, nav_explore, etc.
sleep 2
take_screenshot "02-target-screen"
assert_screenshot "02-target-screen"

# ── Step 3: [Interaction] ───────────────────────────────────────────
# CUSTOMIZE: Perform your test actions
step "Perform test action"
# tap 200 400                      # Tap a button
# swipe 200 600 200 200            # Swipe up
# type_text @e3 "hello"            # Type into a field
sleep 1
take_screenshot "03-after-action"

# ── Step 4: [Verification] ──────────────────────────────────────────
# CUSTOMIZE: Verify the expected outcome
step "Verify result"
route=$(cdp_get_route 2>/dev/null || echo "unknown")
log_info "Current route: $route"

# assert_text_visible "Expected Text"
# assert_screenshot "04-verified"

# ── Step 5: [Cleanup] ───────────────────────────────────────────────
step "Cleanup and final state"
take_screenshot "05-final"
assert_app_foreground

# ── Teardown ─────────────────────────────────────────────────────────
teardown_test

echo ""
echo "Test completed!"
echo "   Screenshots: $SCREENSHOT_DIR/$TEST_NAME/"
echo ""
