# Tests — add-detail-screen

---

## Test 1: Skill activation

**Scenario:** User says "add a detail screen for Visit"

**Expected:**

-   Skill triggers on "detail screen" trigger phrase
-   Agent asks for all 7 input-prompt answers before touching any files
-   Agent does NOT start creating files until inputs are confirmed
-   Agent explicitly asks whether the screen is read-only or editable (Input 2)

**Pass criterion:** Input prompt is shown in full; no files created prematurely.

---

## Test 2: Full read-only flow — Visit info screen

**Scenario:** "Add a read-only info screen for Visit accessible from the Visit overview list"

**Inputs:**

1. Entity: BoVisit (already exists)
2. Read-only
3. Module: Visit
4. Title: "Visit Information"
5. Fields: Customer (from BoRetailStore.name), Visit Status (VisitBo.status.text),
   Time From/Thru (Merger), Main Address/Zip/State (from RetailStoreAddress)
6. (skipped — read-only)
7. Navigation: from Visit overview list (itemSelected → pKey)

**Expected files created:**

-   `src/Visit/PR/Visit_Info/Visit_InfoUI.userinterface.xml`
-   `src/Visit/PR/Visit_Info/Visit_InfoProcess.processflow.xml`

**Expected DS shape:**

-   BO DS already exists (`DsBoVisit_sf.datasource.xml`) — Step 2 may be skipped or confirmed

**Expected UI shape:**

-   `pagePattern="SingleSectionDialogPage"` with `onBackDiscard="true"`
-   All `<InputArea>` elements have `disabled="true"`
-   All `<Binding>` elements have `bindingMode="ONE_WAY"`
-   No save `<MenuItem>` in `<PageHeader>`

**Expected process shape:**

-   Parameters: `VisitPKey (DomPKey)`
-   EntryActions: LOAD BoVisit, LOAD BoRetailStore (related), LOGIC getRetailStoreAddress
-   Body: single VIEW action — `showVisitInfo`
-   No `<ExitHandlers>` block

**Expected caller wiring (Step 7):**

-   Visit overview list process has `<Event name="itemSelected" action="OpenVisitInfo" />`
-   `<Action actionType="PROCESS" name="OpenVisitInfo" process="Visit::InfoProcess">` with `VisitPKey=Event.pKey`

**Pass criterion:** `sf mdl build` passes; simulator shows Visit info from the list tap; all fields are non-editable; pressing Back returns to the list.

---

## Test 3: Full editable flow — Visit details screen

**Scenario:** "Add an editable detail screen for Visit so users can update status remarks and priority"

**Inputs:**

1. Entity: BoVisit (already exists)
2. Editable
3. Module: Visit
4. Title: "Visit Details"
5. Fields: AccountId (disabled), Actual Start/End (Merger, TWO_WAY), Description (MultiLine, TWO_WAY),
   Status (SelectionBox, ONE_WAY), StatusRemarks (MultiLine, TWO_WAY), VisitPriority (SelectionBox, TWO_WAY)
6. Validate-then-save (ExitHandler validates BoVisit before exit)
7. Navigation: BoVisit passed in from caller process

**Expected files created:**

-   `src/Visit/PR/visit_Details/visit_DetailsUI.userinterface.xml`
-   `src/Visit/PR/visit_Details/visit_DetailsProcess.processflow.xml`

**Expected DS shape:**

-   `editableEntity="Visit"` — confirmed present in `DsBoVisit_sf.datasource.xml`

**Expected UI shape:**

-   `pagePattern="SingleSectionDialogPage"` (no `onBackDiscard`)
-   TWO_WAY bindings on StatusRemarks, VisitPriority, Actual Start/End, Description
-   ONE_WAY on Status (SelectionBox DataSource binding)
-   `disabled="true"` on AccountId, Actual times (display only for reference)

**Expected process shape:**

-   Parameters: `BoVisit (type=BoVisit)` — passed in, not loaded here
-   EntryActions: LOAD BoRetailStore (pKey=BoVisit.StoreId), LOAD BoAccount (pKey=BoVisit.AccountId)
-   Body: VIEW `Visit::DetailsUI`
-   `<ExitHandlers><ExitHandler type="Validate" name="ProcessContext::BoVisit"><OnValidationError transitionTo="showVisitDetails" /></ExitHandler></ExitHandlers>`

**Pass criterion:** `sf mdl build` passes; edit StatusRemarks; navigate back; change persists on re-open.

---

## Test 4: Tabbed editable detail — Tour Details

**Scenario:** "Add an editable Tour details screen with tabs: Tour Details, Vehicle Details, Inspection"

**Inputs:**

1. Entity: BoTourData (already exists)
2. Editable
3. Module: Tour
4. Title: bound dynamically to `ProcessContext::TourDataBo.tourDescription`
5. Fields grouped into tabs: "TourDetails", "ReviewVehicleDetails", "VehicleInspection"
6. Validate-then-save (ExitHandler on BoTourData)
7. Navigation: pKey passed in from Tour overview list

**Expected UI shape:**

-   `pagePattern="SingleSectionPage"`
-   `sectionPattern="TabbedViewAreaSection"` with `currentTab="ProcessContext::CurrentTabName"`
-   `<TabSelector>` with `<Tab tabName="TourDetails">`, `<Tab tabName="ReviewVehicleDetails">`, `<Tab tabName="VehicleInspection">`
-   Each `Tab tabName="X"` has a matching `<Area areaPattern="MultiArea" areaName="X">`
-   `<ItemSelectedEvent event="tabSelected" />` in TabSelector

**Expected process shape:**

-   EntryActions include LOGIC call to initialize `CurrentTabName` via `Utils.identity`
-   Body includes `SetCurrentTab` LOGIC action wired from `tabSelected` event
-   ExitHandler validates `ProcessContext::TourDataBo`

**Pass criterion:** Build passes; all three tabs are tappable; each tab's content loads correctly; navigation between tabs does not hang.

---

## Test 5: Save-validation flow

**Scenario:** Agent invoked with validate-then-save; required field left blank

**Inputs:**

-   Entity: CustomerIssue (new BO)
-   Editable, validate-then-save
-   Required fields: issueTitle, status

**Expected BL:**

-   `create-business-logic` invoked for `BoCustomerIssue.validate`
-   Method body checks `issueTitle` and `status` for non-empty; returns array with error objects if invalid

**Expected process:**

-   ExitHandler of type `Validate` on `ProcessContext::CustomerIssueBo`
-   `<OnValidationError transitionTo="showCustomerIssueDetails" />`

**Runtime behavior:**

-   User clears `issueTitle`, attempts to navigate back
-   Validation fires — error shown inline
-   User stays on detail screen (ExitHandler fires `transitionTo`)
-   User fills in title — navigation succeeds

**Pass criterion:** Build passes; blank required field blocks navigation and shows an error message in the simulator.

---

## Test 6: Parent-caller wiring — detail not reachable (Fm4)

**Scenario:** Agent produces all detail screen files but does not update the calling list screen process (Step 7 skipped)

**Expected:**

-   Skill's mandatory checklist item "Parent caller wired" remains unchecked
-   Agent flags this as a blocker before claiming success
-   Agent does NOT invoke `build-and-simulate` until Step 7 is confirmed complete

**Pass criterion:** Agent explicitly calls out missing caller wiring and blocks completion until Step 7 is done.

---

## Test 7: editableEntity missing — save bug diagnosed (Fm1)

**Scenario:** DS for new CustomerIssue detail was created with `editableEntity=""`

**Expected:**

-   Skill's mandatory checklist prompts agent to verify `editableEntity` in the DS file
-   If empty: agent flags this as a blocker and reinvokes `create-datasource` with the correct entity name
-   The verify step happens before `build-and-simulate` is invoked

**Pass criterion:** Agent catches the missing `editableEntity` and corrects the DS before the build step. No silent save failure reaches the simulator.

---

## Test 8: MFG absence audit

**Scenario:** Inspect all files produced by a complete add-detail-screen run

**Command:**

```bash
grep -rni "mfg\|MfgVisit\|MfgQuality\|MfgAgreements" .claude/skills/add-detail-screen/ \
  --include="*.md" | grep -v "MFG check\|Forbidden\|no-MFG" || echo "NO MFG"
```

**Expected output:** `NO MFG`

**Pass criterion:** Zero MFG mentions in any skill file.
