{
  "id": "out-lead",
  "title": "Outbound NexusCRM Lead pushes mapped fields to HubSpot contact",
  "kind": "hubspot_sync",
  "linkedIssues": [],
  "provenance": {
    "businessScenario": "OUT-LEAD — create a native NexusCRM Lead filling §2.2 outbound-mapped fields and verify each HubSpot contact property equals the oracle (identity overwrite + Country/State valueMap non-empty pass-through). Representative subset asserted per spec; remainder per §2.2.",
    "reportedBy": "HubSpot sync spec OUT-LEAD (hubspot-nexuscrm-sync-CASE-EXEC-SELFCONTAINED)",
    "capturedAt": "2026-06-18",
    "note": "[calibrated] Reduced create body + assertions to verified outbound identity oracle (Company->company, Email lowercased via includes, Title->jobtitle, FirstName/LastName, LeadSource); dropped picklist fields whose HS enum is not a clean sandbox identity."
  },
  "steps": [
    {
      "id": "create-record",
      "system": "nexuscrm",
      "authRole": "admin",
      "method": "POST",
      "path": "/services/data/v63.0/sobjects/Lead",
      "body": {
        "Company": "OutLeadCo {{__runId}}",
        "Email": "out-lead-{{__runId}}@example.com",
        "FirstName": "Olivia",
        "LastName": "Lead{{__runId}}",
        "Title": "VP Eng",
        "LeadSource": "Website Referral",
        "HubSpot_Sync_Enabled__c": true
      },
      "expectStatusRange": [200, 299],
      "assertions": [
        { "path": "response.body.id", "exists": true }
      ]
    },
    {
      "id": "wait-hubspot-id",
      "system": "nexuscrm",
      "authRole": "admin",
      "method": "GET",
      "path": "/services/data/v63.0/query?q=SELECT HubSpot_Id__c FROM Lead WHERE Id = '{{steps.create-record.response.body.id}}' LIMIT 1",
      "expectStatus": 200,
      "poll": { "budgetMs": 90000, "intervalMs": 3000 },
      "onTimeout": "fail",
      "assertions": [
        { "path": "response.body.records[0].HubSpot_Id__c", "exists": true }
      ]
    },
    {
      "id": "assert-hubspot",
      "system": "hubspot",
      "method": "GET",
      "path": "/crm/v3/objects/contacts/{{steps.wait-hubspot-id.response.body.records[0].HubSpot_Id__c}}?properties=company,email,firstname,lastname,jobtitle,leadsource",
      "expectStatus": 200,
      "poll": { "budgetMs": 90000, "intervalMs": 3000 },
      "onTimeout": "fail",
      "assertions": [
        { "path": "response.body.properties.company", "equals": "OutLeadCo {{__runId}}" },
        { "path": "response.body.properties.email", "includes": "out-lead-{{__runId}}@example.com", "caseInsensitive": true },
        { "path": "response.body.properties.firstname", "equals": "Olivia" },
        { "path": "response.body.properties.lastname", "equals": "Lead{{__runId}}" },
        { "path": "response.body.properties.jobtitle", "equals": "VP Eng" },
        { "path": "response.body.properties.leadsource", "equals": "Website Referral" }
      ]
    }
  ]
}
