# create-datasource — Self-Test Checklist

Run these tests manually (or in a simulator session) to verify the skill behaves correctly.

---

## Test 1 — Skill activation

**Input phrase:** "create a DataSource for Visit"
**Expected:** Skill activates and begins the verify-sqlite-schema prerequisite step.
**Pass criterion:** The first action taken is invoking `verify-sqlite-schema` for the Visit table,
NOT immediately writing any `.datasource.xml` file.

---

## Test 2 — Declarative DS passes `sf mdl build`

**Setup:** Write a minimal declarative DS using `templates/declarative.datasource.xml.template`
targeting the Visit table (columns: `Id`, `Name`, `Status`). Place it at
`src/Visit/DS/DsBoVisitTest_sf.datasource.xml`.

**Expected:** `sf mdl build` completes with no errors referencing `DsBoVisitTest`.
**Pass criterion:** Build output contains no `ERROR` lines for the new file.

---

## Test 3 — Context-menu DS with `external="true"` and trivial Load

**Setup:** Write a context-menu DS using `templates/context-menu.datasource.xml.template` for
`DsLoOrderContextMenu`. Place it at `src/Order/DS/DsLoOrderContextMenu_sf.datasource.xml`.

**Expected:** `sf mdl build` passes. Loading the owning LO in the simulator shows an empty list
(no crash) until `.bl.js` code populates it.
**Pass criterion:** No build error; no devtools `Cannot read properties of undefined` runtime error.

---

## Test 4 — verify-sqlite-schema halt on missing column

**Setup:** Attempt to write a DS that references a fictional column `Visit.CustomerRating__c`.
Invoke `verify-sqlite-schema` for `Visit` / `CustomerRating__c`.

**Expected:** The skill reports `COLUMN_MISSING` and halts. It does NOT write the `.datasource.xml`
file. It offers to investigate the Salesforce org.
**Pass criterion:** No file is written. The skill reports the column is missing and states next steps
(add to `Mobility_relevant` field set or use a `DerivedAttribute`).

---

## Test 5 — Catch the `external` mismatch error

**Setup:** Deliberately write a DS with `external="true"` that contains only a `<QueryCondition>`
block (no `<Database><Load>`). Build and load in simulator.

**Expected:** Simulator devtools console shows:
`Cannot read properties of undefined (reading 'Load')`
**Pass criterion:** The error message matches exactly; the skill's Fm1 failure-mode description
explains the cause and fix.

---

## Test 6 — Real-module example only (Visit / Order / Product / Tour)

**Setup:** Ask the skill: "create a DS for a list of visits filtered by date range"

**Expected:** The skill produces a scripted DS based on `DsLoVisit` or `DsLoVisitsByDate` patterns,
using the Visit / Order / Product / Tour modules. No manufacturing-module references appear in
any generated or referenced file.

**Pass criterion:**

```bash
grep -rni "mfg" .claude/skills/create-datasource/ | grep -v "Forbidden\|no-MFG" || echo "NO MFG"
```

Output: `NO MFG`
