{
  "id": "out-opp",
  "title": "Outbound NexusCRM Opportunity pushes deal fields incl Amount/ARR (#2864)",
  "kind": "hubspot_sync",
  "linkedIssues": [
    2864
  ],
  "provenance": {
    "businessScenario": "OUT-OPP — create a native NexusCRM Opportunity filling §2.4 fields (Amount set) and verify the HubSpot deal properties match the oracle (dealname identity, closedate LEFT(TEXT,10), Type->pipeline + Type|StageName->dealstage valueMaps, allow_close__c transform). Amount IS now outbound: #2864 (CLOSED) added Opportunity.Amount->deal.amount and ARR_Amount_USD__c->net_new_arr_amount, so the case asserts amount carries the value (250000). Amount missing = #2864 regression = FAIL.",
    "reportedBy": "HubSpot sync spec OUT-OPP (hubspot-nexuscrm-sync-CASE-EXEC-SELFCONTAINED)",
    "capturedAt": "2026-06-18",
    "note": "[calibrated] Oracle: dealname identity, closedate, pipeline/dealstage non-empty, plus Amount->amount=250000 and ARR_Amount_USD__c->net_new_arr_amount=100000 (#2864 added these outbound). The Account fixture is explicitly synced and waited before the Opportunity, with a short settle before Opportunity create, so the deal->company association target link exists before the deal push reserves its attempt."
  },
  "steps": [
    {
      "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": "OutoppAcct {{__runId}}",
        "Industry": "FSI-FinTech",
        "NumberOfEmployees": 250,
        "RecordTypeId": "{{steps.account-record-type.response.body.records[0].Id}}",
        "Region__c": "NA",
        "Vertical__c": "Payment",
        "Website": "https://outopp-acct-{{__runId}}.example.com",
        "ApprovalStatus__c": "Approved",
        "HubSpot_Sync_Enabled__c": true
      },
      "expectStatusRange": [
        200,
        299
      ],
      "assertions": [
        {
          "path": "response.body.id",
          "exists": true
        }
      ]
    },
    {
      "id": "wait-account-hubspot-id",
      "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": 3000
      },
      "onTimeout": "fail",
      "assertions": [
        {
          "path": "response.body.records[0].HubSpot_Id__c",
          "exists": true
        }
      ]
    },
    {
      "id": "create-record",
      "system": "nexuscrm",
      "authRole": "admin",
      "method": "POST",
      "path": "/services/data/v63.0/sobjects/Opportunity",
      "delayMs": 15000,
      "body": {
        "Name": "OutOppDeal {{__runId}}",
        "AccountId": "{{steps.create-account.response.body.id}}",
        "CloseDate": "2026-09-30",
        "Type": "New Subscription",
        "StageName": "Prospecting",
        "Launch_Date__c": "2026-12-31",
        "Amount": 250000,
        "ARR_Amount_USD__c": 100000,
        "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 Opportunity 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/deals/{{steps.wait-hubspot-id.response.body.records[0].HubSpot_Id__c}}?properties=dealname,closedate,pipeline,dealstage,amount,net_new_arr_amount",
      "expectStatus": 200,
      "poll": {
        "budgetMs": 90000,
        "intervalMs": 3000
      },
      "onTimeout": "fail",
      "assertions": [
        {
          "path": "response.body.properties.dealname",
          "equals": "OutOppDeal {{__runId}}"
        },
        {
          "path": "response.body.properties.closedate",
          "matches": "^2026-09-30"
        },
        {
          "path": "response.body.properties.pipeline",
          "exists": true
        },
        {
          "path": "response.body.properties.dealstage",
          "exists": true
        },
        {
          "path": "response.body.properties.amount",
          "numericEquals": 250000
        },
        {
          "path": "response.body.properties.net_new_arr_amount",
          "numericEquals": 100000
        }
      ]
    }
  ]
}
