# `tests/conformance/sf-crm/`

Salesforce-CRM-shaped scenario tests for the flow runtime.

This is the only location in the repository (other than installed pack
metadata resolved from the external official app-packs repo) where Salesforce
standard SObject names — `Lead`, `Account`, `Contact`, `Opportunity`,
`Order`, `Contract`, `Campaign`, `Case`, … — appear in test code.

See `tests/conformance/README.md` for the convention this directory
follows.

## Run

```bash
cd tests/conformance/sf-crm
go test ./...
```

## Module structure

This directory is its own Go module (`nexuscrm-tests/sf-crm`) with
`replace` directives pinning `github.com/nexuscrm/backend` and
`github.com/nexuscrm/shared` to the local checkout (`../../../backend`
and `../../../shared`). The replaces are repo-relative, so any clone of
NexusCRM at the standard layout works without configuration.

The module imports **only** the L0 bridge package
`github.com/nexuscrm/backend/pkg/automationtesting` (and shared model
types). It does not — and cannot, by Go's `internal/` rule — import
`github.com/nexuscrm/backend/internal/...`. All access to the flow
runtime goes through `automationtesting.Rig` and its options.

## Adding a scenario

1. Pick a name that describes the runtime behavior under test, NOT a
   contract claim. `lead_insert_before_save_test.go` ✅ —
   `flow_conformance_test.go` ❌ (the latter implies contract-level
   coverage that one file cannot deliver; see PR #173 / #196 for the
   cautionary history that produced this rule).
2. Use generic helpers from `backend/pkg/automationtesting` for rigs,
   stubs, builders, and snapshot comparison. Pass `"Lead"` (or whichever
   object name) in as a parameter to those helpers.
3. Configure the rig via `automationtesting.With...` options. Do not
   reach for `backend/internal/...` types directly.
4. Fixture JSONs for this pack go under `testdata/`. Snapshots from
   cupaloy or similar go under `testdata/snapshots/`.
5. If a helper you need is not yet in `backend/pkg/automationtesting`,
   add it there in a separate PR before importing it here.

## What this directory is NOT

- It is **not** a "conformance harness" in the contract-test sense. It
  is a collection of scenario tests for runtime branches that happen to
  use SF-CRM-shaped fixtures.
- It is **not** the place for "baseline" or "gap matrix" documents.
  Snapshot-based scenario tests pass or fail; "29/31 baseline FAIL
  because half the dependencies are stubbed" is a test-design artifact,
  not a conformance gap. (See PR #173 / PR #196 for the cautionary
  history that produced this rule.)
- It is **not** a substitute for `tests/integration/`. End-to-end
  black-box tests against a live backend belong there.
