{
  "id": "QUOTE-TENANT-CLONE-LINE-ITEMS",
  "name": "apply-tenant → POST /sobjects/Quote clones OpportunityLineItem rows into quote_product__c (issue #1847 child-clone half)",
  "description": "Sibling to QUOTE-TENANT-INHERIT-CLONE — that case asserts the inheritance half (AccountId landing on the new Quote). This case asserts the child-clone half: after the Quote insert, quote_product__c rows attached to the new Quote must exist, mapped from the source OpportunityLineItem rows per pingcap/object_child_clone_rules.json Quote entry. Together the two cases prove the full cutover hook fires end-to-end against a real tenant-overlay-applied DB. If the rule set, the applyChildCloneRules hook, or the BuildChildCloneTarget core ever silently stops running, this case fails — the runtime oracle the round-4 reviewer required.",
  "object": "Quote",
  "method": "POST",
  "endpoint": "/services/data/v63.0/sobjects/Quote",
  "setup": [
    {
      "type": "sql",
      "name": "Create Account for clone case (distinct IDs from inheritance case)",
      "sql": "INSERT INTO Account (Id, Name, BillingCountryCode, IsDeleted, CreatedDate, LastModifiedDate, SystemModstamp) VALUES (%s, %s, %s, %s, %s, %s, %s)",
      "params": [
        "qtenant-clone-account-01",
        "Quote Tenant Clone Account",
        "{billing_country_code}",
        0,
        "{db_timestamp}",
        "{db_timestamp}",
        "{db_timestamp}"
      ]
    },
    {
      "type": "sql",
      "name": "Create Opportunity",
      "sql": "INSERT INTO Opportunity (Id, Name, AccountId, StageName, CloseDate, Amount, IsDeleted, CreatedDate, LastModifiedDate, SystemModstamp) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
      "params": [
        "qtenant-clone-opp-01",
        "Quote Tenant Clone Opp",
        "qtenant-clone-account-01",
        "Prospecting",
        "2026-12-31",
        15000,
        0,
        "{db_timestamp}",
        "{db_timestamp}",
        "{db_timestamp}"
      ]
    },
    {
      "type": "sql",
      "name": "Create OpportunityLineItem with distinctive Quantity so the clone is traceable",
      "sql": "INSERT INTO OpportunityLineItem (Id, OpportunityId, PricebookEntryId, Product2Id, Quantity, UnitPrice, ListPrice, IsDeleted, CreatedDate, LastModifiedDate, SystemModstamp) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
      "params": [
        "qtenant-clone-oli-01",
        "qtenant-clone-opp-01",
        "01u5g00000196D9AAI",
        "01t5g000000liLsAAI",
        7,
        199.99,
        250.00,
        0,
        "{db_timestamp}",
        "{db_timestamp}",
        "{db_timestamp}"
      ]
    }
  ],
  "payload": {
    "Name": "Quote Tenant Clone Test",
    "OpportunityId": "qtenant-clone-opp-01"
  },
  "expects": {
    "status_code": 201
  },
  "extract": {
    "quote_id": "id"
  },
  "query_after": {
    "object": "quote_product__c",
    "id_field": "Quote__c",
    "record_id": "{quote_id}",
    "select_fields": ["Id", "Product__c", "Quantity__c", "Unit_Net_Price__c", "Quote__c"],
    "response_assertions": [
      {
        "field": "totalSize",
        "operator": "equals",
        "value": 1,
        "comment": "ChildCloneRules for Quote produced exactly one quote_product__c row from the one OpportunityLineItem source"
      }
    ],
    "assertions": [
      {
        "field": "Product__c",
        "operator": "equals",
        "value": "01t5g000000liLsAAI",
        "comment": "fieldMappings.Product__c ← Product2Id copied correctly"
      },
      {
        "field": "Quantity__c",
        "operator": "equals",
        "value": 7,
        "comment": "fieldMappings.Quantity__c ← Quantity copied correctly"
      },
      {
        "field": "Quote__c",
        "operator": "equals",
        "value": "{quote_id}",
        "comment": "targetLookupField stamps the new Quote's Id onto the clone"
      }
    ]
  },
  "teardown": [
    {
      "type": "sql",
      "sql": "DELETE FROM quote_product__c WHERE Quote__c = %s",
      "params": ["{quote_id}"]
    },
    {
      "type": "sql",
      "sql": "DELETE FROM Quote WHERE Id = %s",
      "params": ["{quote_id}"]
    },
    {
      "type": "sql",
      "sql": "DELETE FROM OpportunityLineItem WHERE Id = %s",
      "params": ["qtenant-clone-oli-01"]
    },
    {
      "type": "sql",
      "sql": "DELETE FROM Opportunity WHERE Id = %s",
      "params": ["qtenant-clone-opp-01"]
    },
    {
      "type": "sql",
      "sql": "DELETE FROM Account WHERE Id = %s",
      "params": ["qtenant-clone-account-01"]
    }
  ],
  "priority": "P0",
  "bug_ref": "#1847",
  "scene": "quote_line"
}
