@stalfh233/omc-cli 0.6.99 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,267 @@
1
+ # Live capability conformance
2
+
3
+ Exercises **every** omc CLI capability (the authority is `omc commands --json`)
4
+ against a **real** CloudPivot environment and judges each on **content-level
5
+ readback** — never on `envelope.ok` / `envelope.status`.
6
+
7
+ This exists because "the write returned ok" is not acceptance. A published form
8
+ with no bound controls, or a list view with only system columns, returns ok and
9
+ is still unusable. Every oracle here asserts the thing a user would actually
10
+ see, and every failure is reported with raw envelope evidence.
11
+
12
+ ## Run
13
+
14
+ ```bash
15
+ # read-only (no environment mutation) — safe on any reachable env
16
+ node packages/omc-cli/conformance/run-conformance.mjs --layer read
17
+
18
+ # write (creates disposable resources, verifies, then deletes them)
19
+ node packages/omc-cli/conformance/run-conformance.mjs --layer write
20
+
21
+ # one capability
22
+ node packages/omc-cli/conformance/run-conformance.mjs --layer write --only field.publish
23
+
24
+ # keep the fixture, run the frontend oracle, then clean up
25
+ node packages/omc-cli/conformance/run-conformance.mjs --layer write --keep
26
+ node packages/omc-cli/conformance/frontend-acceptance.mjs
27
+ node packages/omc-cli/conformance/run-conformance.mjs --cleanup-only --prefix <prefix from the report>
28
+ ```
29
+
30
+ - Config home: `$OMC_CONFIG_HOME` (default `/root/.omc-conformance`). It must
31
+ hold `omc.config.json` and `credentials` for the target `--env` (default `t248`).
32
+ - Reports: `--report <path>` (default `/root/.omc-conformance/conformance-report.json`).
33
+
34
+ ## Two oracles, not one
35
+
36
+ The API oracle (`run-conformance.mjs`) proves a write landed and reads back.
37
+ The product oracle (`frontend-acceptance.mjs`) proves a **human** can see and
38
+ use it: it logs in, opens the model designer, and asserts each written resource
39
+ on the surface where a person looks — Data Model grid, Business Rules / Data
40
+ Rules, Form Design controls, View Design columns, WorkerFlow Design, the
41
+ BizIntegration list, and the portal. It also fails on any page console error or
42
+ non-aborted network failure.
43
+
44
+ `frontend-acceptance.mjs` needs a local `playwright`:
45
+
46
+ ```bash
47
+ PW_ROOT=/path/to/node_modules node packages/omc-cli/conformance/frontend-acceptance.mjs
48
+ # or install it in this package: npm i -D playwright && npx playwright install chromium
49
+ # executable path is /usr/bin/chromium here; override with PW_EXECUTABLE_PATH
50
+ ```
51
+
52
+ Screenshots land in `$OMC_PW_SHOT_DIR` (default `/root/.omc-conformance/shots`)
53
+ as human-readable evidence for each surface.
54
+
55
+ ## How a capability is judged
56
+
57
+ - **Write capabilities**: execute once through the environment `writable` gate;
58
+ production probes add `confirmProduction:true`. `dryRun` remains available for
59
+ zero-wire previews.
60
+ - **Oracle**: a per-capability content assertion in `manifest.mjs`
61
+ (e.g. `field.list` must echo the model; `listview.configure` readback must
62
+ contain the business columns; `doctor` steps must all pass).
63
+ - **Fixtures**: one disposable app/model/field/form/listview/rule/workflow/
64
+ service/data set, unique prefix per run, cleaned up leaf-first at the end.
65
+ `workflow.delete` targets a second, never-published draft workflow on its own
66
+ disposable model: after a first publish the model's default list binds to the
67
+ workflow and delete refuses 303024 (S29 deleteGate), so the published template
68
+ is removed by the `model.delete` cascade instead.
69
+ - **Ordering**: constructive capabilities run first; destructive ones run last
70
+ (leaf -> root) so a mid-list `model.delete` cannot pull the rug from under the
71
+ rest. This ordering *is* a finding: the first runs failed exactly because it
72
+ was missing.
73
+ - **Compacted reads**: the read lane token-diets any result over 4 KB into
74
+ `{count|keys,sha256}` stubs and spills the full readback to a detail artifact.
75
+ A content oracle follows that artifact, so a growing environment (e.g. more
76
+ dictionaries) cannot FAIL a good read on "rows missing".
77
+ - **Read layer probe**: `--layer read` cannot build a fixture, so it points at a
78
+ shared probe model; when that model is absent the model-dependent reads SKIP
79
+ with that precondition named instead of FAILing. Use `--layer all` for a
80
+ self-contained read+write run that builds its own fixture.
81
+
82
+ ## Status classification
83
+
84
+ - `PASS` — exit 0 AND the content oracle holds.
85
+ - `FAIL` — anything else; raw envelope kept in the report.
86
+ - `SKIP` — with a named reason. Two kinds:
87
+ - **external precondition** the environment cannot satisfy here (a reachable
88
+ database for `service.dbconnpool.*` / `service.table_*`, a real service ZIP
89
+ for `service.check` / `service.import`, a live work item for `workitem.list`,
90
+ a real endpoint for `method.test`);
91
+ - **covered boundary** — a refusal that is the documented contract or an
92
+ interactive configuration surface (`setup.commit`).
93
+
94
+ ## Adding a capability
95
+
96
+ 1. Add `buildArgs` for it in `manifest.mjs` (derive the payload from
97
+ `omc describe <tool>`, do not invent it).
98
+ 2. Add a content oracle branch (never `ok`/`status`).
99
+ 3. If it needs a fixture, either add it to `FIXTURE_ORDER` or extend the
100
+ dependency wiring; if it tears resources down, add it to `DESTRUCTIVE_ORDER`
101
+ leaf-first.
102
+ 4. If it is genuinely un-runnable here, add a `SKIP` reason that names the
103
+ missing precondition.
104
+
105
+ ## Frontend behavior probe (`frontend-behavior-probe.mjs`)
106
+
107
+ `frontend-acceptance.mjs` proves a configured resource is *visible* in the admin
108
+ UI. `frontend-behavior-probe.mjs` proves the configured **runtime behavior**
109
+ actually happens in a real page: online-JS lifecycle events register and fire,
110
+ custom buttons really issue their request, calculation rules produce the value,
111
+ and visibility / readonly / required follow the condition field.
112
+
113
+ ### One-time install (no browser download)
114
+
115
+ `omc` ships the probe but not Playwright. Install `playwright-core` into the OMC
116
+ cache (a few MB) and reuse the system Chromium/Chrome:
117
+
118
+ ```bash
119
+ omc frontend setup # npm install --prefix ~/.omc/frontend-probe playwright-core
120
+ omc frontend setup --check # diagnose: playwrightRoot / chromium / cacheDir (JSON, no network)
121
+ ```
122
+
123
+ Already have Playwright? Skip setup and point `PW_ROOT` at that `node_modules`
124
+ (direct script mode also still supports `CREDS`).
125
+
126
+ It is scenario-driven so nothing has to be hard-coded per feature:
127
+
128
+ ```bash
129
+ # 1) drive a scenario against a real environment
130
+ node packages/omc-cli/conformance/frontend-behavior-probe.mjs \
131
+ --scenario packages/omc-cli/conformance/frontend-scenarios/calc-visibility.json \
132
+ --base-url http://10.168.150.248:8088 --env t248 --out ./frontend-probe-out
133
+
134
+ # 1') same thing through the CLI (env/credentials resolved from the OMC config
135
+ # root). The report directory flag is `--report-dir` — the global
136
+ # `--out <file>` means "write the stdout envelope to a file" and is
137
+ # consumed before the subcommand ever sees it.
138
+ omc frontend probe \
139
+ --scenario packages/omc-cli/conformance/frontend-scenarios/calc-visibility.json \
140
+ --env t248 --report-dir ./frontend-probe-out
141
+
142
+ # The probe prints `DATA-LINK <url>` for every record it creates or submits —
143
+ # open it directly to see the saved record. Screenshots are off by default;
144
+ # add `--screenshots` when you need visual evidence.
145
+
146
+ # 2) validate a scenario offline (no browser, no environment)
147
+ node packages/omc-cli/conformance/frontend-behavior-probe.mjs --validate <scenario.json>
148
+
149
+ # 3) prove the harness itself (inline HTML, no CloudPivot) — must print SELF-TEST PASS
150
+ node packages/omc-cli/conformance/frontend-behavior-probe.mjs --self-test
151
+ ```
152
+
153
+ Options: `--fail-fast`, `--headed`, `--trace` (writes `trace.zip`),
154
+ `--screenshots` (off by default; failures are not screenshotted either),
155
+ `--timeout <ms>`. Exit codes: `0` all pass, `1` a step or
156
+ assertion failed, `2` invalid scenario, `3` harness/login/browser error.
157
+ `omc frontend probe` resolves credentials from the OMC config root; direct
158
+ script mode still accepts `CREDS` / `OMC_PROBE_USERNAME`+`OMC_PROBE_PASSWORD`.
159
+ Playwright resolution order: `PW_ROOT` → `~/.omc/frontend-probe/node_modules`
160
+ (created by `omc frontend setup`) → npx cache. Browser: `PW_EXECUTABLE_PATH`
161
+ (or `CHROME_PATH`) → common system paths. `login: false` skips login.
162
+
163
+ ### Scenario shape
164
+
165
+ `name`, optional `description` / `ignoreConsole` (substring or
166
+ `{pattern,flags}` regexes) / `login` / `schemaCode` / `sheetCode` (used to build
167
+ `DATA-LINK` URLs; `sheetCode` defaults to `schemaCode`), and `steps[]`. A
168
+ `goto.path` starting with
169
+ `/` is prefixed with the base URL; `http(s)://` URLs are used as-is.
170
+
171
+ Actions: `goto`, `wait`, `waitForText`, `fill`, `select`, `check`, `uncheck`,
172
+ `click`, `press`, `eval` (return value lands in the report), `screenshot`,
173
+ `dumpProbe`, `assert`.
174
+
175
+ Assertions (`"action": "assert"` + `kind`): `valueEquals`, `valueMatches`,
176
+ `visible`, `hidden`, `readonly`, `required`, `textContains`, `eventFired`,
177
+ `eventNotFired`, `eventRegistered`, `request`, `noConsoleErrors`,
178
+ `probeLogContains`. Every assertion accepts `optional: true` (a miss is printed
179
+ as `PASS … (optional unmet)` and does not fail the run) and `timeoutMs`.
180
+
181
+ Targeting precedence is `selector` (CSS) > `code` (tries `[data-code]`,
182
+ `[data-field-code]`, `[data-field]`, `[name]`, `#id`) > `label` (visible text;
183
+ tolerates the required star, a trailing colon and i18n, then walks up to
184
+ `.ant-form-item` / `*[class*=control]` / the nearest input-bearing ancestor) >
185
+ `text`. `valueEquals` reads `input.value` / `textarea.value` / a component
186
+ `.value` / `.items` / the read-only text, then trims and drops thousands
187
+ separators; two numeric values compare numerically (`15` == `15.00`).
188
+
189
+ `request` matches `/api/` responses inside the window that started at the last
190
+ action step (that is why `click` then `assert request` works), by URL substring
191
+ (or `"regex": true`), plus optional `errcode` / `status` parsed from the JSON
192
+ body (`withinMs`, default 15s).
193
+
194
+ ### Buttons (live-verified 2026-11-24, 1.1.25/1.1.30)
195
+
196
+ - **Form buttons** (`useLocation:"FORM"`) only render on a **workflow form URL**
197
+ (`/form/detail?…&workItemId=…&workflowInstanceId=…&objectId=…`) and only when the
198
+ current node enabled them (`workflow.setButtons` → `buttonPermission.customBtns[].enabled`).
199
+ A plain `/form/detail?...&isWorkFlow=false` page renders only built-in buttons.
200
+ Order matters: `setButtons` first, then create the instance (old work items do not
201
+ pick up later button changes).
202
+ - **`bindAction:"SCRIPT"` is browser-side only**: list `WITH_OUT_VIEW` runs
203
+ `new Function("scriptData","rowIndex",…)` in the list page (zero HTTP); list
204
+ `WITH_VIEW` stores the script and opens the row's form with `scriptOpen=true`
205
+ (script runs in the form page; exactly one row must be selected). Neither calls
206
+ `/runtime/form/executeCustomButton`.
207
+ - **`executeCustomButton` only executes server actions** (`BUSINESS_RULE`/`FLOW`
208
+ with `operateType:"WITH_OUT_VIEW"`); a `SCRIPT` button there returns an empty
209
+ success. Assert a request with a BUSINESS_RULE button, not a SCRIPT one.
210
+ - List toolbar layout splits buttons into `#list-actions` vs the “…” overflow by
211
+ width; selecting rows can push a button into the overflow. Clear built-in
212
+ actions (`replaceActions:true, actions:[]`) when a scenario must click one.
213
+ - Examples: `frontend-scenarios/form-buttons.json`, `frontend-scenarios/list-buttons.json`.
214
+
215
+ ### Probe
216
+
217
+ An init script injects `window.__omcProbe`: it hooks `window.form` (setter first,
218
+ then a fast poll) and wraps `form.on(event, cb)` to record
219
+ `{event, registeredAt}` and every fired event, wrapping the callback so a throw
220
+ is recorded instead of vanishing. It also wraps `console.*`, `fetch` and
221
+ `XMLHttpRequest` without changing behavior/eavesdropping on bodies. Thus
222
+ `eventFired: onLoad` distinguishes *never registered*, *registered but never
223
+ fired*, and *handler threw*.
224
+
225
+ ### Report
226
+
227
+ `<out>/probe-report.json` holds `scenario`, `baseUrl`, `steps[]`,
228
+ `assertions[]`, `console[]`, `pageErrors[]`, `network[]`, `probe{}` (events /
229
+ registrations / logs / requests), `screenshots[]` (empty unless
230
+ `--screenshots`), and `dataLinks[]` (`{schemaCode,sheetCode,objectId,url,source,at}`).
231
+ Console output is one `PASS`/`FAIL step#N …` line per step with `expected` vs
232
+ `actual` and a reason that names the step and label.
233
+
234
+ **DATA-LINK.** When the scenario creates or updates a record (`/runtime/form/save`,
235
+ `/runtime/form/submit`, `/data/save`, `/data/submit`, `/data/update`), the probe
236
+ reads the new object id out of the response (`data.id` / `data.bizObjectId` /
237
+ `data.objectId` / `data.data.id` / first array item) and prints one
238
+ `DATA-LINK <url>` line at the end of the run. The URL is the portal record shape
239
+ `<baseUrl>/form/detail?schemaCode=…&sheetCode=…&objectId=…&isWorkFlow=false` and
240
+ opens the saved record directly. `schemaCode`/`sheetCode` come from the request
241
+ body/query when present, otherwise from the scenario's top level. `edit=true`
242
+ is deliberately omitted (it belongs to the add page).
243
+
244
+ ### Limitations
245
+
246
+ - `label` heuristics assume Ant-Design-ish markup (`.ant-form-item`,
247
+ `.ant-form-item-label`, `.ant-form-item-required`). Other skins fall back to
248
+ the control/ancestor heuristics; pin the field with `code` or `selector` when
249
+ in doubt.
250
+ - The event probe only sees a **global** `window.form` (documented online-JS
251
+ surface). A page that keeps `form` in a lexical/closure scope is invisible to
252
+ it; `eventFired` will then report "never registered". **Live 1.1.25:** the
253
+ portal executes online JS as `(function(form){…})(form)` with `form` in a
254
+ closure, so `eventFired`/`eventRegistered` are best-effort — assert the
255
+ script's own `console.log` via `probeLogContains` instead (the probe captures
256
+ `console.*` regardless).
257
+ - CloudPivot renders a read-only field as text (no `input`), with the marker on
258
+ a descendant (`field__control__readonly` / `readonly-render`); the probe scans
259
+ descendant classes, not just the container. Pin the field with `code`/`selector`
260
+ when a skin invents new class names.
261
+ - `readonly` / `required` are heuristic (control attributes + container/label
262
+ classes + leading star); a field that renders as plain text without any
263
+ read-only class is reported as editable.
264
+ - Fields re-rendered between a resolution and the assertion can detach the
265
+ marked element; assertions re-resolve on each poll, actions do not.
266
+ - `request` only records `/api/` responses; GraphQL/websocket-driven buttons
267
+ need their own `eval`-based check.