# Checkout Flow
# ---
# Pattern: E-commerce — browse, add to cart, checkout, verify confirmation
# What it tests: End-to-end purchase flow from product browsing to order confirmation.
# Customize:
#   - Update product names, form fields, and confirmation text for your store
#
# Tip: For payment forms in iframes (like Stripe), you may need explicit selectors
#      targeting the iframe content. ProwlQA's Playwright engine handles iframes natively.
#      For Stripe-specific checkout, see e-commerce/stripe-checkout.yml.

name: checkout-flow
description: Browse products, add to cart, complete checkout

tags:
  - e-commerce
  - checkout
  - cart
  - purchase

vars:
  EMAIL: "{{TEST_EMAIL}}"

steps:
  - navigate: "/products"

  # Browse and add a product to cart
  - click: "Add to Cart"

  - assert:
      visible: "Added to cart"

  # Go to cart and proceed to checkout
  - click: "Cart"
  - assert:
      visible: "Your Cart"

  - click: "Checkout"

  # Fill shipping/billing information
  - fill:
      "Email": "{{EMAIL}}"

  - fill:
      "Full Name": "Test Buyer"

  - fill:
      "Address": "123 Test Street"

  - fill:
      "City": "Miami"

  - select:
      "State": "FL"

  - fill:
      "ZIP Code": "33101"

  # Submit the order
  - click: "Place Order"

  - waitForNetworkIdle:
      timeout: 15000

  # Verify order confirmation
  - assert:
      visible: "Order Confirmed"

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