# Tests for `create-process` Skill

7 acceptance tests. All run against the output produced by the skill in a simulator-ready branch.

---

## Test 1 — Skill activation

**Trigger:** User says "Create a process for the Call reschedule flow that loads BoCall and shows a dialog."

**Expected:** Skill identifies the phrase "process for" + `.processflow.xml` intent and activates
`create-process`. Agent does NOT activate `create-ui-page` or `create-business-logic` as the
primary skill.

**Pass criteria:**

-   Skill is invoked before any file is written.
-   Agent checks whether the referenced BO (`BoCall`) exists before writing the process.
-   If BO is missing, agent pauses and invokes `create-business-object` first.

**Fail if:** Agent writes a `.processflow.xml` without checking for prerequisite BO/LO/LU
declarations, or activates a different skill.

---

## Test 2 — Simple dialog process creation

**Setup:** `BoCall` and `BoWizardRescheduleCall` both exist.

**Action:** Apply `templates/simple-dialog.processflow.xml.template` with:

-   `MODULE=Call`, `FLOW_NAME=Call_Reschedule`, `BO_CLASS=BoCall`, `BO_VAR=CallBo`
-   `WIZARD_BO=BoWizardRescheduleCall`, `WIZARD_VAR=RescheduleCallBo`
-   `PKEY_PARAM=CallPKey`, `DONE_EVENT=saveReschedule`

**Expected output file:** `src/Call/PR/Call_Reschedule/Call_RescheduleProcess.processflow.xml`

**Assertions:**

-   [ ] Root element: `<Process name="Call::Call_RescheduleProcess" defaultAction="ShowDialog" schemaVersion="0.0.0.5">`
-   [ ] `<Entry>` block present with `<ProcessContext>`, `<Declarations>`, `<Parameters>`, `<EntryActions>`
-   [ ] `<Declaration name="CallBo" type="BoCall" />` present
-   [ ] `<Declaration name="RescheduleCallBo" type="BoWizardRescheduleCall" />` present
-   [ ] `<Input name="CallPKey" type="DomPKey" />` present in Parameters
-   [ ] EntryActions contain a `LOAD` action for `BoCall` and a `CREATE` action for `BoWizardRescheduleCall`
-   [ ] Body contains a `VIEW` action with `<UIDescription>Call::Call_RescheduleUI</UIDescription>`
-   [ ] VIEW `<Events>` maps `saveReschedule` to a downstream action
-   [ ] Body contains `VALIDATION`, `DECISION`, `LOGIC`, and two `END` actions
-   [ ] Every `<TransitionTo action="X">` has a matching `<Action name="X">` in the Body
-   [ ] `sf mdl build` exits 0 after the file is placed (with companion UI)

**Fail if:**

-   `defaultAction` points to an action not in the Body
-   `TransitionTo` references a non-existent action name
-   `schemaVersion` is missing or wrong

---

## Test 3 — Decision branch process creation

**Setup:** `BoVisit` and `LoVisitAssessmentTask` both exist.

**Action:** Apply `templates/decision-branch.processflow.xml.template` with:

-   `MODULE=Visit`, `FLOW_NAME=Visit_ChangeStatus`, `BO_CLASS=BoVisit`, `BO_VAR=VisitBo`
-   `DECISION_PARAM=targetStatus`
-   `BRANCH_VALUE_A=Completed`, `BRANCH_VALUE_B=Cancelled`
-   `ACTION_A_METHOD=endVisit`, `ACTION_B_METHOD=abandonVisit`

**Expected output file:** `src/Visit/PR/Visit_ChangeStatus/Visit_ChangeStatusProcess.processflow.xml`

**Assertions:**

-   [ ] Root: `<Process name="Visit::Visit_ChangeStatusProcess" ...>`
-   [ ] Empty `<EntryActions></EntryActions>` (or EntryActions with just the LOAD)
-   [ ] LOAD action transitions to a DECISION action
-   [ ] DECISION on `ProcessContext::targetStatus` with `<Case value="Completed">` and `<Case value="Cancelled">`
-   [ ] `<CaseElse>` and `<CaseEmpty>` both present on every DECISION
-   [ ] Each branch ends with a CONFIRM action that has `confirmType="YesNo"` and `<Message messageId="...">`
        (no `messageDefault` attribute)
-   [ ] Two END actions: `EndWithRefresh` (value="1") and `EndWithoutRefresh` (value="0")
-   [ ] No companion UI file needed — pure logic flow (no VIEW actions)

**Fail if:**

-   `<Message messageId="..." messageDefault="...">` — `messageDefault` is not a valid attribute
-   Any END action is missing `<ReturnValues>`
-   A CONFIRM `<Case>` value is anything other than `"Yes"`, `"No"`, or `"Ok"`

---

## Test 4 — Wizard process creation

**Setup:** `BoOrder` and `BoWizardCreateOrder` both exist.

**Action:** Apply `templates/wizard.processflow.xml.template` with:

-   `MODULE=Order`, `FLOW_NAME=Order_Create`, `BO_CLASS=BoOrder`, `BO_VAR=OrderBo`
-   `WIZARD_BO=BoWizardCreateOrder`, `WIZARD_VAR=WizardBo`
-   `STEP1_EVENT=goToStep2`, `STEP2_BACK_EVENT=goToStep1`, `STEP2_DONE_EVENT=submit`
-   `SAVE_METHOD=createOrder`

**Expected output file:** `src/Order/PR/Order_Create/Order_CreateProcess.processflow.xml`

**Assertions:**

-   [ ] Root: `<Process name="Order::Order_CreateProcess" defaultAction="ShowStep1" ...>`
-   [ ] EntryActions: LOAD `BoOrder` + CREATE `BoWizardCreateOrder`
-   [ ] Body: `ShowStep1` VIEW → `ShowStep2` VIEW → `ValidateWizard` → `ValidationDecision` → `PerformSave` → `End`
-   [ ] `ShowStep2` VIEW handles both a Back event (→ `ShowStep1`) and a Done event (→ `ValidateWizard`)
-   [ ] VALIDATION action followed by DECISION on `ProcessContext::validationResult`
-   [ ] DECISION has `Case value="validateOk"` and `Case value="validateDiscard"`
-   [ ] `End` action has `ReturnValues` with `refreshRequired=1` and `createdPKey`
-   [ ] `EndCancel` action has `ReturnValues` with `refreshRequired=0`
-   [ ] Both `Step1UI` and `Step2UI` UIDescription references are correct module-scoped names

**Fail if:**

-   Any VIEW action's `<UIDescription>` value doesn't follow `Module::FlowNameUI` pattern
-   A back-navigation event (goToStep1) transitions to a non-existent action

---

## Test 5 — TransitionTo target mismatch caught

**Setup:** Agent writes a process where `<TransitionTo action="SaveVisit" />` is used but the
action is named `"PersistVisit"` instead.

**Expected:** Agent catches the mismatch during self-review (or the mandatory checklist prompts
inspection) before writing the file.

**Pass criteria:**

-   Agent cross-checks every `<TransitionTo action="X">`, `<Case action="X">`, and `<Event action="X">`
    against the set of `<Action name="X">` in `<Body><Actions>`.
-   No dangling references in the written file.
-   `sf mdl build` exits 0.

**Fail if:** File is written with a dangling `TransitionTo` target, causing a build error like
"action reference not found" or similar.

---

## Test 6 — ProcessContext variable missing before VIEW

**Setup:** Agent writes a process where `ProcessContext::WizardBo` is declared but never populated
(no LOAD or CREATE action writes to it), yet the VIEW step's UI binds to it.

**Expected:** Agent notices the uninitialized variable during the mandatory checklist step and
either:
(a) adds a CREATE/LOAD action in EntryActions to initialize it, or
(b) reports the gap and prompts the user.

**Pass criteria:**

-   Final process file has all UI-bound variables initialized before the first VIEW action runs.
-   No runtime `Cannot read properties of null` error in the simulator when opening the screen.

**Fail if:** File is written with a VIEW action where a bound variable is declared but never
populated in EntryActions or an earlier Body action.

---

## Test 7 — MFG absence

**Action:** Run the following from the repo root:

```bash
grep -rni "mfg" .claude/skills/create-process/ \
    --include="*.md" --include="*.template" | grep -iv "forbidden\|MFG check"
```

**Pass criteria:** Output is empty (no matches). No MFG-specific content must appear in the
skill — it is a general-purpose process skill, not domain-specific.

**Fail if:** Any skill file or template references "MFG", "MfgVisit", "MfgQuality",
"MfgAgreements", or any MFG-specific module name. Use only real shipping modules:
Visit, Order, Product, Tour, Call, Promotion, CustomerIssue, Workflow.
