{
  "$schema": "https://farmslot.io/schemas/recipe-v1.schema.json",
  "title": "Perps release order entry",
  "description": "Exercises the live Perps order form through semantic visible controls without submitting an order.",
  "paramsSchema": {
    "type": "object",
    "additionalProperties": false,
    "required": [
      "market"
    ],
    "properties": {
      "market": {
        "type": "string",
        "description": "Perps market with no existing position so the New Long and Short controls are available."
      },
      "amount": {
        "type": "string",
        "default": "10"
      },
      "leverage": {
        "type": "string",
        "default": "5"
      }
    }
  },
  "workflow": {
    "entry": "open-perps",
    "nodes": {
      "open-perps": {
        "action": "ui.navigate",
        "page": "perps",
        "intent": "Reset transient Perps navigation state",
        "next": "open-market-list"
      },
      "open-market-list": {
        "action": "ui.navigate",
        "page": "perps-market-list",
        "intent": "Show the live Perps market list",
        "next": "open-market"
      },
      "open-market": {
        "action": "ui.navigate",
        "page": "perps-market",
        "market": "{{params.market}}",
        "intent": "Open the requested Perps market",
        "next": "open-long"
      },
      "open-long": {
        "action": "ui.press",
        "test_id": "perps-long-cta-button",
        "intent": "Open a new long market order",
        "next": "wait-order-entry"
      },
      "wait-order-entry": {
        "action": "ui.wait_for",
        "test_id": "perps-order-entry-page",
        "expected": "visible",
        "timeout_ms": 10000,
        "intent": "Confirm the order form finished opening",
        "next": "assert-long"
      },
      "assert-long": {
        "action": "metamask.perps.read_visible_state",
        "surface": "order-entry",
        "market": "{{params.market}}",
        "direction": "long",
        "order_type": "market",
        "require_test_ids": [
          "direction-tab-long",
          "direction-tab-short",
          "order-type-market",
          "order-type-limit",
          "amount-input-field",
          "leverage-input",
          "auto-close-toggle",
          "submit-order-button"
        ],
        "max_items": 150,
        "intent": "Prove the long market form and its semantic controls",
        "next": "set-amount"
      },
      "set-amount": {
        "action": "ui.set_input",
        "selector": "[data-testid=\"amount-input-field\"] input",
        "value": "{{params.amount}}",
        "intent": "Enter the USD order amount through the amount field",
        "next": "set-leverage"
      },
      "set-leverage": {
        "action": "ui.set_input",
        "selector": "[data-testid=\"leverage-input\"] input",
        "value": "{{params.leverage}}",
        "intent": "Enter leverage through the leverage field",
        "next": "assert-configured"
      },
      "assert-configured": {
        "action": "metamask.perps.read_visible_state",
        "surface": "order-entry",
        "market": "{{params.market}}",
        "direction": "long",
        "order_type": "market",
        "amount": "{{params.amount}}",
        "leverage": "{{params.leverage}}",
        "submit_enabled": true,
        "max_items": 150,
        "intent": "Prove amount, leverage, and submit eligibility update together",
        "next": "select-short"
      },
      "select-short": {
        "action": "ui.press",
        "test_id": "direction-tab-short",
        "intent": "Switch the same order form to Short",
        "next": "assert-short"
      },
      "assert-short": {
        "action": "metamask.perps.read_visible_state",
        "surface": "order-entry",
        "market": "{{params.market}}",
        "direction": "short",
        "order_type": "market",
        "amount": "{{params.amount}}",
        "submit_enabled": true,
        "max_items": 150,
        "intent": "Prove direction changes without losing configured values",
        "next": "select-limit"
      },
      "select-limit": {
        "action": "ui.press",
        "test_id": "order-type-limit",
        "intent": "Switch the order form to Limit",
        "next": "assert-limit"
      },
      "assert-limit": {
        "action": "metamask.perps.read_visible_state",
        "surface": "order-entry",
        "market": "{{params.market}}",
        "direction": "short",
        "order_type": "limit",
        "amount": "{{params.amount}}",
        "require_test_ids": ["limit-price-input", "limit-price-mid-button"],
        "max_items": 150,
        "intent": "Prove Limit mode exposes its price controls",
        "next": "capture"
      },
      "capture": {
        "action": "ui.screenshot",
        "path": "screenshots/perps-order-entry.png",
        "label": "Perps release order entry",
        "intent": "Preserve reviewer-visible proof of the configured order form",
        "next": "done"
      },
      "done": {
        "action": "end",
        "status": "pass"
      }
    }
  }
}
