{
  "id": "FLOW-008",
  "name": "BeforeSave Opportunity assignment via Tooling API flow fires on Create (issue #2193 engine lock)",
  "description": "Regression lock for issue #2193: a RecordBeforeSave AutoLaunchedFlow on Opportunity must execute its assignment when the entry condition passes. Installs a synthetic, tenant-agnostic flow via Tooling API that unconditionally assigns Description='FLOW-008-FIRED' on Opportunity Create. Verifies the flow engine correctly resolves the assignToReference ($Record.Description) during BeforeSave and that the persisted record reflects the assigned value. Tenant-agnostic: standard SObject (Opportunity), standard fields (Description, CloseDate, StageName, Name, AccountId, OwnerId). No __c business names, no PingCAP/TiDB identifiers. Companion to #2193's tenant-overlay fix that corrects Opportunity_Service_Start_Date_Close_Date to reference Launch_Date__c instead of the non-existent Service_Start_Date__c.",
  "setup": [
    {
      "type": "http",
      "name": "Create synthetic BeforeSave flow on Opportunity via Tooling API",
      "method": "POST",
      "endpoint": "/services/data/v63.0/tooling/sobjects/Flow",
      "payload": {
        "MasterLabel": "FLOW-008 Opp BeforeSave Description Set",
        "ProcessType": "AutoLaunchedFlow",
        "Status": "Draft",
        "Metadata": {
          "apiVersion": "63.0",
          "label": "FLOW-008 Opp BeforeSave Description Set",
          "description": "Test-only BeforeSave flow that sets Description on Opportunity Create. Regression lock for #2193 BeforeSave assignment engine path.",
          "status": "Draft",
          "processType": "AutoLaunchedFlow",
          "start": {
            "locationX": 50,
            "locationY": 0,
            "object": "Opportunity",
            "triggerType": "RecordBeforeSave",
            "recordTriggerType": "Create",
            "connector": {
              "targetReference": "Set_Description"
            }
          },
          "assignments": [
            {
              "name": "Set_Description",
              "label": "Set Description",
              "locationX": 176,
              "locationY": 287,
              "assignmentItems": [
                {
                  "assignToReference": "$Record.Description",
                  "operator": "Assign",
                  "value": {
                    "stringValue": "FLOW-008-FIRED"
                  }
                }
              ]
            }
          ]
        }
      },
      "expects": {
        "status_code": 201
      },
      "extract": {
        "flow008_version_id": "id"
      }
    },
    {
      "type": "http",
      "name": "Activate the new Flow version",
      "method": "POST",
      "endpoint": "/services/data/v63.0/tooling/sobjects/Flow/{flow008_version_id}/activate",
      "expects": {
        "status_code": 204
      }
    }
  ],
  "object": "Opportunity",
  "method": "POST",
  "endpoint": "/services/data/v63.0/sobjects/Opportunity",
  "payload": {
    "Name": "FLOW-008-BeforeSave-Opp",
    "AccountId": "{seed_Account_0}",
    "CloseDate": "2026-12-31",
    "StageName": "Prospecting",
    "Description": "initial"
  },
  "expects": {
    "status_code": 201
  },
  "query_after": {
    "object": "Opportunity",
    "retry": 5,
    "delay_ms": 500,
    "assertions": [
      {
        "field": "Name",
        "operator": "eq",
        "value": "FLOW-008-BeforeSave-Opp"
      },
      {
        "field": "Description",
        "operator": "eq",
        "value": "FLOW-008-FIRED"
      }
    ]
  },
  "teardown": [
    {
      "method": "DELETE",
      "endpoint": "/services/data/v63.0/sobjects/Opportunity/{id}"
    },
    {
      "method": "DELETE",
      "endpoint": "/services/data/v63.0/tooling/sobjects/Flow/{flow008_version_id}"
    }
  ],
  "priority": "P1",
  "bug_ref": "#2193",
  "scene": "flow"
}
