# Login Flow
# ---
# Pattern: Authentication — email/password login with redirect verification
# What it tests: Fill credentials, submit, verify redirect to dashboard.
# Customize:
#   - Update the selectors and URL paths to match your app's login page
#   - Store credentials in .prowl/.env and reference them with {{VAR}}
#
# Tip: Use `prowl login` to capture auth state so other hunts can skip login.

name: login-flow
description: Log in with email and password, verify redirect to dashboard

tags:
  - auth
  - login
  - credentials

# Store secrets in .prowl/.env — they'll be redacted in reports automatically.
# Example .env:
#   TEST_EMAIL=user@example.com
#   TEST_PASSWORD=secret123
vars:
  EMAIL: "{{TEST_EMAIL}}"
  PASSWORD: "{{TEST_PASSWORD}}"

steps:
  - navigate: "/login"

  # Shorthand fill — Prowl finds the input by its label or placeholder text.
  # Equivalent explicit form:
  #   fill:
  #     selector: "input[placeholder='Email']"
  #     value: "{{EMAIL}}"
  - fill:
      "Email": "{{EMAIL}}"

  - fill:
      "Password": "{{PASSWORD}}"

  # Shorthand click — Prowl finds a button by its text content.
  # Equivalent explicit form:
  #   click:
  #     selector: "button:has-text('Sign In')"
  - click: "Sign In"

  # Wait for navigation to complete after login
  - waitForUrl:
      value: "/dashboard"
      timeout: 10000

  # Mid-flow assertion — verify the dashboard loaded
  - assert:
      visible: "Dashboard"

assertions:
  - urlIncludes: "/dashboard"
  - noConsoleErrors: true
