{
  "id": "OLI-005",
  "name": "Query OrderLineItems for an Order",
  "description": "Querying OrderItems filtered by OrderId should return all line items for that Order.",
  "object": "OrderItem",
  "method": "GET",
  "endpoint": "/services/data/v63.0/query/?q=SELECT+Id,Order__c,PricebookEntryId,Quantity,UnitPrice,TotalPrice+FROM+order_product__c+WHERE+Order__c%3D%27oli005-ord-000001%27",
  "setup": [
    {
      "type": "sql",
      "name": "Create isolated Account for OLI-005",
      "sql": "INSERT INTO Account (Id, Name, BillingCountryCode, IsDeleted, CreatedDate, LastModifiedDate, SystemModstamp) VALUES (%s, %s, %s, %s, %s, %s, %s)",
      "params": [
        "oli005-acc-01",
        "OLI-005 Account",
        "{billing_country_code}",
        0,
        "{db_timestamp}",
        "{db_timestamp}",
        "{db_timestamp}"
      ]
    },
    {
      "type": "sql",
      "name": "Create Order for OLI-005",
      "sql": "INSERT INTO `Order` (Id, AccountId, Status, EffectiveDate, IsDeleted, SystemModstamp) VALUES (%s, %s, %s, %s, %s, %s)",
      "params": [
        "oli005-ord-000001",
        "oli005-acc-01",
        "Draft",
        "2026-04-01",
        0,
        "{db_timestamp}"
      ]
    },
    {
      "type": "sql",
      "name": "Create OrderItem for OLI-005",
      "sql": "INSERT INTO order_product__c (Id, Order__c, Quantity__c, IsDeleted, SystemModstamp) VALUES (%s, %s, %s, %s, %s)",
      "params": [
        "oli005-oli-000001",
        "oli005-ord-000001",
        5,
        0,
        "{db_timestamp}"
      ]
    }
  ],
  "expects": {
    "status_code": 200
  },
  "query_after": {
    "object": "order_product__c",
    "id_field": "Order__c",
    "record_id": "oli005-ord-000001",
    "assertions": [
      {
        "field": "Id",
        "operator": "is_not_null",
        "value": true
      }
    ]
  },
  "teardown": [
    {
      "type": "sql",
      "sql": "DELETE FROM order_product__c WHERE Id = %s",
      "params": [
        "oli005-oli-000001"
      ]
    },
    {
      "type": "sql",
      "sql": "DELETE FROM `Order` WHERE Id = %s",
      "params": [
        "oli005-ord-000001"
      ]
    },
    {
      "type": "sql",
      "sql": "DELETE FROM Account WHERE Id = %s",
      "params": [
        "oli005-acc-01"
      ]
    }
  ],
  "priority": "P1",
  "scene": "order_line",
  "skip": true,
  "skip_reason": "Current product behavior does not surface manually inserted order_product__c rows via the query path used by this case; keep skipped until the query contract is fixed",
  "response_assertions": [
    {
      "field": "totalSize",
      "operator": "gt",
      "value": 0
    },
    {
      "field": "records",
      "operator": "is_not_null",
      "value": true
    }
  ]
}
