{
  "id": "fix-2752",
  "title": "Native records auto-sync by default (HubSpot_Sync_Enabled__c default true, 3/3)",
  "kind": "hubspot_sync",
  "linkedIssues": [
    2752
  ],
  "provenance": {
    "businessScenario": "FIX-2752 — re-prove #2752: native records have HubSpot_Sync_Enabled__c default true and auto-outbound on create (3/3 across Lead/Account/Opportunity). Step 1 reads Lead describe to confirm the default-value contract; steps then create one native record per object WITHOUT setting the sync field and poll HubSpot_Id__c writeback. PASS (verbatim NEW runbook H FIX-2752): default true, 3/3 auto-sync. Any object not written back = FAIL (record n/3); describe default not true = FAIL.",
    "reportedBy": "HubSpot sync spec FIX-2752 (hubspot-nexuscrm-sync-CASE-EXEC-SELFCONTAINED)",
    "capturedAt": "2026-06-18",
    "calibrated": "[calibrated] Account create now carries required NX fields (Industry/NumberOfEmployees/RecordTypeId/Region__c/Vertical__c/Website). Records are now created and verified in dependency order for the native business objects: Account writeback, then Opportunity create after a short Account-link settle, then the independent Lead writeback proof. Native deal outbound resolves AccountId through the Account's finalized connector link before reserving a deal push attempt, so creating the Opportunity before Account sync can fail closed with no Opportunity attempt."
  },
  "steps": [
    {
      "id": "describe-lead",
      "system": "nexuscrm",
      "authRole": "admin",
      "method": "GET",
      "path": "/services/data/v63.0/sobjects/Lead/describe",
      "expectStatus": 200,
      "assertions": [
        {
          "path": "response.body.fields",
          "arrayContainsObject": {
            "name": "HubSpot_Sync_Enabled__c",
            "defaultValue": true
          }
        }
      ]
    },
    {
      "id": "account-record-type",
      "system": "nexuscrm",
      "authRole": "admin",
      "method": "GET",
      "path": "/services/data/v63.0/query?q=SELECT Id FROM _System_RecordType WHERE SobjectType = 'Account' AND Name = 'Customer' AND IsActive = true LIMIT 1",
      "expectStatus": 200,
      "assertions": [
        {
          "path": "response.body.totalSize",
          "atLeast": 1
        },
        {
          "path": "response.body.records[0].Id",
          "exists": true
        }
      ]
    },
    {
      "id": "create-account",
      "system": "nexuscrm",
      "authRole": "admin",
      "method": "POST",
      "path": "/services/data/v63.0/sobjects/Account",
      "body": {
        "Name": "Fx2752A-{{__runId}}",
        "Industry": "FSI-FinTech",
        "NumberOfEmployees": 120,
        "RecordTypeId": "{{steps.account-record-type.response.body.records[0].Id}}",
        "Region__c": "NA",
        "Vertical__c": "Payment",
        "Website": "https://fx2752-{{__runId}}.example.com",
        "ApprovalStatus__c": "Approved"
      },
      "expectStatusRange": [
        200,
        299
      ],
      "assertions": [
        {
          "path": "response.body.id",
          "exists": true
        }
      ]
    },
    {
      "id": "wait-account-writeback",
      "system": "nexuscrm",
      "authRole": "admin",
      "method": "GET",
      "path": "/services/data/v63.0/query?q=SELECT HubSpot_Id__c FROM Account WHERE Id='{{steps.create-account.response.body.id}}' LIMIT 1",
      "expectStatus": 200,
      "poll": {
        "budgetMs": 90000,
        "intervalMs": 6000
      },
      "onTimeout": "fail",
      "assertions": [
        {
          "path": "response.body.records[0].HubSpot_Id__c",
          "exists": true
        }
      ]
    },
    {
      "id": "create-opp",
      "system": "nexuscrm",
      "authRole": "admin",
      "method": "POST",
      "path": "/services/data/v63.0/sobjects/Opportunity",
      "delayMs": 15000,
      "body": {
        "Name": "Fx2752O-{{__runId}}",
        "StageName": "Prospecting",
        "ARR_Amount_USD__c": 100000,
        "Launch_Date__c": "2026-12-31",
        "CloseDate": "2026-12-31",
        "AccountId": "{{steps.create-account.response.body.id}}"
      },
      "expectStatusRange": [
        200,
        299
      ],
      "assertions": [
        {
          "path": "response.body.id",
          "exists": true
        }
      ]
    },
    {
      "id": "wait-opp-writeback",
      "system": "nexuscrm",
      "authRole": "admin",
      "method": "GET",
      "path": "/services/data/v63.0/query?q=SELECT HubSpot_Id__c FROM Opportunity WHERE Id='{{steps.create-opp.response.body.id}}' LIMIT 1",
      "expectStatus": 200,
      "poll": {
        "budgetMs": 90000,
        "intervalMs": 6000
      },
      "onTimeout": "fail",
      "assertions": [
        {
          "path": "response.body.records[0].HubSpot_Id__c",
          "exists": true
        }
      ]
    },
    {
      "id": "create-lead",
      "system": "nexuscrm",
      "authRole": "admin",
      "method": "POST",
      "path": "/services/data/v63.0/sobjects/Lead",
      "body": {
        "LastName": "Fx2752-{{__runId}}",
        "Company": "C",
        "Email": "fx2752-{{__runId}}@example.com"
      },
      "expectStatusRange": [
        200,
        299
      ],
      "assertions": [
        {
          "path": "response.body.id",
          "exists": true
        }
      ]
    },
    {
      "id": "wait-lead-writeback",
      "system": "nexuscrm",
      "authRole": "admin",
      "method": "GET",
      "path": "/services/data/v63.0/query?q=SELECT HubSpot_Id__c FROM Lead WHERE Id='{{steps.create-lead.response.body.id}}' LIMIT 1",
      "expectStatus": 200,
      "poll": {
        "budgetMs": 90000,
        "intervalMs": 6000
      },
      "onTimeout": "fail",
      "assertions": [
        {
          "path": "response.body.records[0].HubSpot_Id__c",
          "exists": true
        }
      ]
    }
  ]
}
