diff --git a/CHANGELOG.md b/CHANGELOG.md index e9e148df..05e64f1e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,9 @@ Sections dated before 2026-09-19 predate the cycle and stay as they are. Named m `docs/RELEASE-PROCESS.md` §8. ## Unreleased +- fix(app-restart, exec): **`app-restart.sh` logs to the project, and exec's watch / change-class lines mark a blanked literal `'…'`**: the restart log went to `${TMPDIR:-/tmp}/-run-local.log`, one file for every project whose model shares a name (several field apps were all `ProbeApp.mpr`); it is now `/.claude/loop/app-restart/run-local.log` beside `start.cmd` (self-gitignored, created only when written; `LOGDIR` still overrides). The advisory lines printed a statement head with its string literals blanked to `''` — `create or modify demo user '' ( Password: '', …` read as an empty user name; a blanked literal now reads `'…'`, and the literal itself (a password, here) is still never printed. Fixtures `test-app-restart.sh` (master 120/123, branch 123/123) and `test-exec-lock-watch.sh` (master 126/128, branch 128/128) — field run on a real Mendix 11.8 app (2026-11-20) +- fix(design-audit): **the #891 guard names the unnamed `controlbar {` mxcli writes**: `readCompleteness()` matched only `controlbar `, so on a DataGrid2 page with New/Edit buttons the guard FAULTed the page correctly (the buttons are unread) while its message said "controlbars: none". Unnamed control bars are now reported as `(unnamed, mdlSource line N)`; named ones keep their name; the verdict is unchanged. Fixture `tests/wave2/test-design-audit-controlbar.sh` over a captured `describe --format elk` of a real Mendix 11.8 page (master 4/5, branch 5/5) — field run 2026-11-20 +- fix(design-audit, e2e-harness-base): **a design-audit that cannot launch its browser no longer leaves the last run's `design-audit.json` reading as current, and the install doc names axe-core**: `e2e-harness-base.md` named only Playwright; followed literally in a container with a global Playwright, `npm i -D playwright` shadowed it with a version whose browser was not downloaded, design-audit crashed at `chromium.launch` (exit 1) and wrote nothing, so the previous run's artifact stayed in place unchanged. A browser that does not launch is now a FAULT row per rung-7 check (the artifact is rewritten, exit 2); any other crash removes the stale artifact and says so (report-normalize then reads design-audit as `fault`). The doc now says to probe for a working Playwright before installing one, and to `npm i -D axe-core`. Fixture `tests/wave2/test-design-audit-stale-artifact.sh` (master 1/5, branch 6/6; Playwright's launch message captured verbatim from the field log) — field run on a real Mendix 11.8 app under `mxcli run --local` (2026-11-20) - new(doctor, bug ledger): **a guard for mxcli's silent MxBuild fallback**: when the project's Mendix version is not in `~/.mxcli/mxbuild/` (and no Studio Pro of that version exists), `mxcli docker build` / `docker check` fall back to the newest cached MxBuild and print its path but no version warning (`run --local` is exact-or-refuse); `bin/doctor.sh` now warns, naming the model version, the cached ones and `./mxcli setup mxbuild -p .mpr` (`mxtk_mxbuild_cache_gap`, warning only, never changes a gate). Ledger entry `BUG-DRAFT-mxbuild-silent-version-fallback`; upstream issue not filed. — a four-app Mendix build (field run), independent review - fix(gate-check): **a fresh clone no longer FAILs Stage 3 as "stale render"**: `blueprint.html` / `process-map.html` freshness used `[ render -ot source ]`, a nanosecond mtime compare, and a checkout stamps files in directory order (`process-map.html` lands before `process-model.json`), so an unedited project read stale on every clone (reproduced: 200-wireframe checkout, 10 of 10 clones). New `bin/lib/render-fresh.sh` keeps `-ot` as the first test (a pass never flips, no git call) and, only where `-ot` would FAIL, asks git once per render (one `log`, one `status`) whether the source was committed after the render's commit; measured 0.19 s for 200 sources all `-ot`-stale on a 300-commit history (a per-source git version cost 12.9 s). Limit: a depth-1 clone cannot see a genuinely stale render. Field run: a four-app Mendix build checked out on a second machine. — a four-app Mendix build (field run), independent review - fix(test-stack-up, e2e-harness-base): **the app port follows the app's configured port, and a multi-app start is no longer pinned to 8080**: with no `APP_PORTS`, `test-stack-up.sh` puts `RUN_LOCAL_APP_PORT`, then `APP_PORT` from the `.docker/.env` beside the `.mpr` (`apps//.docker/.env`; the project-root one as fallback) first, ahead of the old fixed `8080 8081 8084` tail. A fresh `run --local` start for a model under `apps/` with no handshake and no configured port used to fall back to 8080 for every app (`--app-port 8080`); it now exits 4 naming `RUN_LOCAL_APP_PORT`. `e2e-harness-base.md` states that a PAD/Docker runtime listens on 8080 *inside* the container only. Fixtures T28–T32 added. Field run: a four-app Mendix build on 8081–8084 whose fresh start failed with every app pinned to 8080. — a four-app Mendix build (field run), independent review diff --git a/project-bin/app-restart.sh b/project-bin/app-restart.sh index cbb383f2..86ac57b3 100755 --- a/project-bin/app-restart.sh +++ b/project-bin/app-restart.sh @@ -300,7 +300,13 @@ fi REC_ADMIN="$(hs_num adminPort "$HS")" # the probe uses only a recorded admin port, never a guess ADMIN_PORT="$REC_ADMIN"; [ -n "$ADMIN_PORT" ] || ADMIN_PORT=$((PORT + 10)) REC_DIR="$PROJECT_ROOT/.claude/loop/app-restart"; REC="$REC_DIR/start.cmd" -LOG="${LOGDIR:-${TMPDIR:-/tmp}}/$(basename "$MPR" .mpr)-run-local.log" +# The start log is this project's: /.claude/loop/app-restart/run-local.log (self-gitignored, +# beside start.cmd). It was ${TMPDIR:-/tmp}/-run-local.log, one file for every project whose +# model shares a name (field run 2026-11-20: several apps called ProbeApp.mpr wrote into one log). +# LOGDIR still overrides. Created only when something is written, so --probe / --dry-run touch nothing. +LOG="${LOGDIR:+$LOGDIR/$(basename "$MPR" .mpr)-run-local.log}"; LOG="${LOG:-$REC_DIR/run-local.log}" +log_dir() { [ -n "${LOGDIR:-}" ] && return 0 + mkdir -p "$REC_DIR" 2>/dev/null && { [ -f "$REC_DIR/.gitignore" ] || printf '*\n' > "$REC_DIR/.gitignore"; }; } # ── 1b. --probe / --if-client-gone: look before touching anything ─────────── if [ "$MODE" = probe ]; then @@ -328,7 +334,7 @@ if [ "$MODE" = client ]; then _mx="$(find_project_mxcli 2>/dev/null || command -v mxcli 2>/dev/null || true)" if [ -n "$_rs" ] && [ -n "$_mx" ]; then echo " mxcli run restart -p $(basename "$MPR") (a --detach run: mxcli restarts it with its own arguments)" - "$_mx" run restart -p "$MPR" >>"$LOG" 2>&1 >"$LOG" 2>&1 /dev/null || true # a SIGKILLed mxcli leaves its record behind; the new one must be new +log_dir if command -v setsid >/dev/null 2>&1; then ( cd "$START_CWD" && exec setsid nohup "${ARGV[@]}" >>"$LOG" 2>&1 \t" awk "$_MXTK_MDL_LEX"' function head_class(w1, w2, w4, obj) { @@ -267,7 +270,7 @@ mxtk_change_class() { # $1 = MDL script; prints "\t" if (k == "ui") ui++ else if (k == "logic" && logic == "") { h = t; if (length(h) > 60) h = substr(h, 1, 60) "..." - logic = "line " NR ": " h + logic = "line " NR ": " shown(h) } } } @@ -440,7 +443,7 @@ mxtk_watch_compat() { # $1 = MDL script; prints "restart\t" | "unknown else if (v == "CREATE" && o1 == "PAGE" && j == 2) add("new page", NR) else if (v == "CREATE" && o1 == "PAGE") { - if (maybe == "") maybe = "line " NR ": " substr(t, 1, 60) + if (maybe == "") maybe = "line " NR ": " shown(substr(t, 1, 60)) } # The watch-safe list (skills/ui-loop.md "What watch picks up", left column): an # ALTER PAGE / ALTER SNIPPET edit, a new or changed snippet. Everything else that is @@ -454,7 +457,7 @@ mxtk_watch_compat() { # $1 = MDL script; prints "restart\t" | "unknown ; else if (nunk < 3) { h = t; if (length(h) > 50) h = substr(h, 1, 50) "..." - unk = unk (nunk++ ? "; " : "") "line " NR ": " h + unk = unk (nunk++ ? "; " : "") "line " NR ": " shown(h) } else nunk++ } } @@ -470,7 +473,7 @@ mxtk_watch_compat() { # $1 = MDL script; prints "restart\t" | "unknown if (lc ~ re_act) add("widget action changed (the runtime registers actions at boot)", NR) else if (!ui_unk && lc ~ re_ds) { ui_unk = 1 - if (nunk < 3) { h = t; if (length(h) > 50) h = substr(h, 1, 50) "..."; unk = unk (nunk++ ? "; " : "") "line " NR ": " h " (microflow/nanoflow data source)" } + if (nunk < 3) { h = t; if (length(h) > 50) h = substr(h, 1, 50) "..."; unk = unk (nunk++ ? "; " : "") "line " NR ": " shown(h) " (microflow/nanoflow data source)" } else nunk++ } } diff --git a/project-tests/e2e/design-audit.js b/project-tests/e2e/design-audit.js index e1d82d17..77d23f65 100644 --- a/project-tests/e2e/design-audit.js +++ b/project-tests/e2e/design-audit.js @@ -282,7 +282,9 @@ function readCompleteness(doc) { // must span the whole `column X ( … )` head, not one line of it. const customContentCols = [...mdl.matchAll(/^\s*column\s+("?)([A-Za-z_][\w]*)\1\s*\(([^)]*)\)/gm)] .filter((m) => /ShowContentAs:\s*customContent/.test(m[3])).map((m) => m[2]); - const controlbars = [...mdl.matchAll(/^\s*controlbar\s+([A-Za-z_][\w]*)/gm)].map((m) => m[1]); + // mxcli writes a data grid's control bar unnamed (`controlbar {`); a name is optional. + const controlbars = [...mdl.matchAll(/^[ \t]*controlbar\b[ \t]*([A-Za-z_]\w*)?/gm)] + .map((m) => m[1] || `(unnamed, mdlSource line ${mdl.slice(0, m.index).split('\n').length})`); // An empty group in the tree where the MDL has a body is the accordion/object-list // shape from #891 verbatim. @@ -767,6 +769,15 @@ async function appSweep(pages, navMap, controlNotes) { return { checks, ran: false, reason: '--static-only' }; } + const faultAll = (why) => { + for (const qn of pages) for (const [k, title] of Object.entries(titles)) { + checks.push(row({ + id: `design-audit/rung7/${k}/${qn}`, module: moduleOf(qn), page: qn, title, + verdict: 'fault', detail: why, + })); + } + return { checks, ran: false, reason: why }; + }; let helpers, cfg, chromium, axeSource; try { helpers = require('./helpers'); @@ -774,16 +785,15 @@ async function appSweep(pages, navMap, controlNotes) { ({ chromium } = require('playwright')); axeSource = fs.readFileSync(require.resolve('axe-core/axe.min.js'), 'utf8'); } catch (e) { - for (const qn of pages) for (const [k, title] of Object.entries(titles)) { - checks.push(row({ - id: `design-audit/rung7/${k}/${qn}`, module: moduleOf(qn), page: qn, title, - verdict: 'fault', detail: `harness dependency missing: ${e.message}`, - })); - } - return { checks, ran: false, reason: e.message }; + return faultAll(`harness dependency missing: ${e.message}`); } - const browser = await chromium.launch({ headless: true }); + // A Playwright whose browser was never downloaded (a project-local `npm i -D playwright` + // shadowing a global one) throws here. That is "rung 7 did not run", a FAULT row per page — + // not a crash that leaves the previous run's design-audit.json in place. + let browser; + try { browser = await chromium.launch({ headless: true }); } + catch (e) { return faultAll(`browser did not launch: ${String(e.message).split('\n')[0]}`); } const ctx = await browser.newContext({ viewport: { width: 1440, height: 900 } }); const page = await ctx.newPage(); let loggedIn = false; @@ -1038,7 +1048,14 @@ async function runControls(pages, css, wf) { fs.writeFileSync(p, wrap(v)); files[k] = p; } - const browser = await chromium.launch({ headless: true }); + let browser; + try { browser = await chromium.launch({ headless: true }); } + catch (e) { + for (const n of ['rung7-a11y', 'rung7-overflow', 'rung7-structure']) { + out.push(ctlRow(n, `rung 7 ${n}`, false, `browser did not launch: ${String(e.message).split('\n')[0]}`)); + } + return out; + } const ctx = await browser.newContext({ viewport: { width: 1440, height: 900 } }); const pg = await ctx.newPage(); const measure = async (file) => { @@ -1204,6 +1221,12 @@ async function main() { write({ startedAt, checks, instruments, pages, perPage: st.perPage, stats: st.stats, controlRows }); } +function outFile() { + return OPT.out + ? path.resolve(ROOT, OPT.out) + : path.join(ARTIFACTS, OPT.positiveControl ? 'design-audit-control.json' : 'design-audit.json'); +} + function write({ startedAt, checks, instruments, pages, perPage, stats, controlRows = [] }) { const tally = {}; for (const c of checks) tally[c.verdict] = (tally[c.verdict] || 0) + 1; @@ -1231,9 +1254,7 @@ function write({ startedAt, checks, instruments, pages, perPage, stats, controlR instruments, checks, }; - const out = OPT.out - ? path.resolve(ROOT, OPT.out) - : path.join(ARTIFACTS, OPT.positiveControl ? 'design-audit-control.json' : 'design-audit.json'); + const out = outFile(); fs.writeFileSync(out, JSON.stringify(doc, null, 2)); // console: short, honest, no green where there is none @@ -1270,4 +1291,17 @@ function write({ startedAt, checks, instruments, pages, perPage, stats, controlR } } -main().catch((e) => { console.error('design-audit crashed:', e); process.exit(1); }); +// A crash writes no artifact, so the previous run's would be read as this run's: a stale green. +// Remove it — report-normalize then reads design-audit as `fault` ("did not run"), which it is. +main().catch((e) => { + console.error('design-audit crashed:', e); + try { + const out = outFile(); + if (fs.existsSync(out)) { + fs.unlinkSync(out); + console.error(`design-audit: removed the previous run's ${path.relative(ROOT, out)} — this run wrote none, ` + + 'and the old file would read as current.'); + } + } catch (e2) { console.error(`design-audit: could not remove the stale artifact: ${e2.message}`); } + process.exit(1); +}); diff --git a/skills/e2e-harness-base.md b/skills/e2e-harness-base.md index 944b9c2c..f4cbb9b4 100644 --- a/skills/e2e-harness-base.md +++ b/skills/e2e-harness-base.md @@ -26,8 +26,13 @@ Build after completing a module build phase: ## Prerequisites - Node.js available -- Playwright installed: `npm init -y && npm i -D playwright` -- `npx playwright install chromium` +- Playwright, once: first try `node -e "require('playwright').chromium.launch().then(b => b.close())"` + from the project root. If it exits 0, a Playwright with its browser is already there (a global + install, a container image): **do not** `npm i -D playwright` — a project-local copy shadows it + with a version whose browser is not downloaded, and every browser instrument then fails with + `Executable doesn't exist`. Otherwise: `npm init -y && npm i -D playwright && npx playwright install chromium`. +- axe-core: `npm i -D axe-core` — `tests/e2e/design-audit.js` rung 7 (accessibility) needs it; without + it every rung-7 row is a FAULT ("harness dependency missing"). - App running at `http://localhost:8080` — or, when this session cannot reach that host (a cloud container, a devcontainer, a phone), at the public URL from `mxcli run --local --hub`. Point the harness `BASE_URL` at whichever one actually answers; never assume `localhost:8080`. diff --git a/tests/wave2/fixtures/design-audit-controlbar/elk-Task_Overview-mx11.8.json b/tests/wave2/fixtures/design-audit-controlbar/elk-Task_Overview-mx11.8.json new file mode 100644 index 00000000..1ce15785 --- /dev/null +++ b/tests/wave2/fixtures/design-audit-controlbar/elk-Task_Overview-mx11.8.json @@ -0,0 +1 @@ +{"format":"wireframe","type":"page","name":"Tasks.Task_Overview","title":"Tasks","layout":"Atlas_Core.Atlas_Default","root":[{"id":"wf-0","widget":"datagrid","name":"dgTasks","datasource":"database Tasks.Task","columns":[{"caption":"Title","binding":"Title"},{"caption":"Done","binding":"Done"}]}],"mdlSource":"create or modify page Tasks.Task_Overview (Title: 'Tasks', Layout: Atlas_Core.Atlas_Default) {\n datagrid dgTasks (DataSource: database from Tasks.Task, Selection: Single) {\n -- Context: $currentObject (Tasks.Task), $dgTasks (selection)\n controlbar {\n actionbutton btnNew (\n Caption: 'New task',\n Action: create object Tasks.Task then show page Tasks.Task_NewEdit,\n ButtonStyle: Primary\n )\n actionbutton btnEdit (Caption: 'Edit', Action: show page Tasks.Task_NewEdit(Task = $dgTasks))\n }\n column (Attribute: Title, Caption: 'Title')\n column (Attribute: Done, Caption: 'Done')\n }\n};\n\ngrant view on page Tasks.Task_Overview to Tasks.User;\n","sourceMap":{"wf-0":{"startLine":1,"endLine":1}}} \ No newline at end of file diff --git a/tests/wave2/test-app-restart.sh b/tests/wave2/test-app-restart.sh index 50a5eacd..30c61e06 100755 --- a/tests/wave2/test-app-restart.sh +++ b/tests/wave2/test-app-restart.sh @@ -170,6 +170,18 @@ has "says there was nothing to stop" "$OUT" "nothing — recorded pid $D is not has "uses the remembered command" "$OUT" "remembered from the last restart" KILL_LIST="$KILL_LIST $(hs_pid "$P") $(cat "$P/.fakechild" 2>/dev/null)" +echo "-- the start log is this project's, not a /tmp file shared by every model of the same name" +# Field run 2026-11-20: several experiments' models were all ProbeApp.mpr, so they all wrote +# ${TMPDIR:-/tmp}/ProbeApp-run-local.log. Without LOGDIR the log now lives beside start.cmd. +mkdir -p "$WORK/tmpd" +OUT="$( ( cd "$P" && env -u LOGDIR TMPDIR="$WORK/tmpd" FAKE_GOLDEN="$GOLDEN" ./bin/app-restart.sh --timeout 30 ) 2>&1)"; RC=$? +[ "$RC" -eq 0 ] && ok "exit 0" || bad "exit $RC: $(printf '%s' "$OUT" | tail -4)" +PLOG="$P/.claude/loop/app-restart/run-local.log" +[ -f "$PLOG" ] && ok "the start log is /.claude/loop/app-restart/run-local.log" || bad "no per-project start log" "$(ls "$P/.claude/loop/app-restart" 2>&1)" +has "and the output names it" "$OUT" "log: $PLOG" +[ ! -e "$WORK/tmpd/Fixture-run-local.log" ] && ok "nothing written to \$TMPDIR/-run-local.log" || bad "the shared TMPDIR log was written" +KILL_LIST="$KILL_LIST $(hs_pid "$P") $(cat "$P/.fakechild" 2>/dev/null)" + echo "-- #304 review: a stale record whose pid now belongs to another process → that process is never stopped" # A SIGKILLed mxcli leaves its record; the OS reuses the pid. With --cmd the start command no longer # comes from the pid, so only a check on the pid itself can tell. The old code sent it TERM. diff --git a/tests/wave2/test-design-audit-controlbar.sh b/tests/wave2/test-design-audit-controlbar.sh new file mode 100755 index 00000000..4c66a691 --- /dev/null +++ b/tests/wave2/test-design-audit-controlbar.sh @@ -0,0 +1,76 @@ +#!/usr/bin/env bash +# Usage: bash test-design-audit-controlbar.sh [path-to-design-audit.js] +# +# Fixture: design-audit.js's #891 guard names the data grid control bar mxcli actually writes. +# +# The defect (field run 2026-11-20, a real Mendix 11.8 app): readCompleteness() looked for +# `controlbar `, but mxcli writes a DataGrid2 control bar unnamed — `controlbar {`. On a +# grid with New/Edit buttons the guard rightly FAULTed the page (2 buttons unread), yet its +# message said "controlbars: none" while the unread buttons were the control bar's. The verdict +# was right; the explanation pointed away from the cause. +# +# Golden input is CAPTURED: fixtures/design-audit-controlbar/elk-Task_Overview-mx11.8.json is +# `mxcli -p describe --format elk page Tasks.Task_Overview` (mxcli v0.32, Mendix 11.8.0) +# from that app, verbatim — the exact command design-audit.js runs. + +set -uo pipefail + +SUT="${1:-}" +[ -z "$SUT" ] && SUT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)/project-tests/e2e/design-audit.js" +[ -f "$SUT" ] || { echo "SKIP: subject not found at $SUT"; exit 0; } +command -v node >/dev/null 2>&1 || { echo "SKIP: node not installed"; exit 0; } +HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +GOLDEN="$HERE/fixtures/design-audit-controlbar/elk-Task_Overview-mx11.8.json" +[ -f "$GOLDEN" ] || { echo "FAIL — golden capture missing: $GOLDEN"; exit 1; } + +PASS=0; FAIL=0 +ok() { PASS=$((PASS+1)); echo " ok — $1"; } +bad() { FAIL=$((FAIL+1)); echo " FAIL — $1"; [ -n "${2:-}" ] && echo " got: $2"; } + +# design-audit.js runs on load, so lift the functions out of its text instead of requiring it. +IFS= read -r -d '' JS <<'JSEOF' || true +const fs = require('fs'); +const [sut, golden] = process.argv.slice(1); +const js = fs.readFileSync(sut, 'utf8'); +// To the top-level closing `}` line: brace counting is fooled by the `\\{` inside the guard's own regex. +const lift = (name) => { + const i = js.indexOf(`\nfunction ${name}(`); + if (i < 0) return null; + const j = js.indexOf('\n}\n', i); + return j < 0 ? null : js.slice(i + 1, j + 2); +}; +const names = ['walkElk', 'mdlWidgetInstances', 'readCompleteness']; +const src = names.map(lift); +if (src.some((x) => !x)) { console.log('LIFT-FAIL ' + names.filter((n, i) => !src[i]).join(',')); process.exit(0); } +// mdlWidgetInstances reads the file's own MDL_NON_WIDGET_TYPES set; lift that verbatim too. +const ci = js.indexOf('const MDL_NON_WIDGET_TYPES'); +const consts = ci < 0 ? 'const MDL_NON_WIDGET_TYPES = new Set();' : js.slice(ci, js.indexOf(']);', ci) + 3); +const { readCompleteness } = new Function(`${consts}\n${src.join('\n')}\nreturn { readCompleteness };`)(); +const doc = JSON.parse(fs.readFileSync(golden, 'utf8')); +const r = readCompleteness(doc); +console.log('PARTIAL ' + r.partial); +console.log('UNREAD ' + r.unread.join(',')); +console.log('BARS ' + r.controlbars.length + '|' + r.controlbars.join(',')); +// A named control bar (older MDL shape) still reports its name. +const named = readCompleteness({ root: doc.root, mdlSource: doc.mdlSource.replace('controlbar {', 'controlbar cbTasks {') }); +console.log('NAMED ' + named.controlbars.join(',')); +// A page without a control bar reports none; `controlbar` inside another word is not one. +const none = readCompleteness({ root: doc.root, mdlSource: "create page M.P (Title: 'x') {\n container cnt (Class: 'mycontrolbar') {\n }\n};" }); +console.log('NONE ' + none.controlbars.length); +JSEOF +OUT="$(node -e "$JS" "$SUT" "$GOLDEN" 2>&1)" +line() { printf '%s\n' "$OUT" | sed -n "s/^$1 //p"; } +if printf '%s\n' "$OUT" | grep -q '^LIFT-FAIL'; then bad "could not lift the guard from design-audit.js" "$OUT"; else + [ "$(line PARTIAL)" = true ] && ok "the captured page is partially read (verdict unchanged)" || bad "partial" "$OUT" + printf '%s' "$(line UNREAD)" | grep -q 'btnNew' && ok "the unread widgets are the control bar's buttons" || bad "unread" "$(line UNREAD)" + case "$(line BARS)" in + 1\|*unnamed*) ok "the unnamed \`controlbar {\` mxcli writes is reported: $(line BARS | cut -d'|' -f2)" ;; + *) bad "the unnamed control bar is not reported (message would say 'controlbars: none')" "$(line BARS)" ;; + esac + [ "$(line NAMED)" = cbTasks ] && ok "a named control bar still reports its name" || bad "named control bar" "$(line NAMED)" + [ "$(line NONE)" = 0 ] && ok "no control bar → none; a class value containing 'controlbar' is not one" || bad "false control bar" "$(line NONE)" +fi + +echo "" +echo "PASS=$PASS FAIL=$FAIL" +[ "$FAIL" -eq 0 ] diff --git a/tests/wave2/test-design-audit-stale-artifact.sh b/tests/wave2/test-design-audit-stale-artifact.sh new file mode 100755 index 00000000..c58507ef --- /dev/null +++ b/tests/wave2/test-design-audit-stale-artifact.sh @@ -0,0 +1,95 @@ +#!/usr/bin/env bash +# Usage: bash test-design-audit-stale-artifact.sh [path-to-design-audit.js] +# +# Fixture: design-audit.js never leaves the previous run's design-audit.json behind as if current. +# +# The defect (field run 2026-11-20, a real Mendix 11.8 app under `mxcli run --local`): following +# skills/e2e-harness-base.md literally (`npm i -D playwright`) shadowed the container's global +# Playwright with a newer one whose browser was not downloaded. design-audit then crashed at +# chromium.launch (main().catch, exit 1) and wrote nothing — so artifacts/design-audit.json from +# the run before stayed in place, unchanged, and read as this run's result. +# Now: a browser that does not launch is a FAULT row per rung-7 check (the artifact is +# rewritten, exit 2), and any other crash removes the stale artifact (report-normalize then reads +# design-audit as `fault`, "did not run"). +# +# Golden input: the launch error is Playwright's own message, verbatim from the field log +# (runtime/designaudit2.log), thrown by a stub `playwright` module so no browser is needed. + +set -uo pipefail + +SUT="${1:-}" +[ -z "$SUT" ] && SUT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)/project-tests/e2e/design-audit.js" +[ -f "$SUT" ] || { echo "SKIP: subject not found at $SUT"; exit 0; } +command -v node >/dev/null 2>&1 || { echo "SKIP: node not installed"; exit 0; } +E2E="$(cd "$(dirname "$SUT")" && pwd)" + +PASS=0; FAIL=0 +ok() { PASS=$((PASS+1)); echo " ok — $1"; } +bad() { FAIL=$((FAIL+1)); echo " FAIL — $1"; [ -n "${2:-}" ] && echo " got: $2"; } + +WORK="$(mktemp -d "${TMPDIR:-/tmp}/dastale.XXXXXX")" +trap 'rm -rf "$WORK"' EXIT +D="$WORK/tests/e2e"; mkdir -p "$D/artifacts" "$WORK/node_modules/playwright" "$WORK/node_modules/axe-core" +: > "$WORK/Fixture.mpr" +for f in design-audit.js scope-ensure.js settle.js config.js helpers.js otel.js; do + [ -f "$E2E/$f" ] && cp "$E2E/$f" "$D/" +done +cat > "$D/project.config.js" <<'EOF' +'use strict'; +const path = require('path'); +const root = path.resolve(__dirname, '..', '..'); +module.exports = { root, rootSource: 'fixture', mpr: path.join(root, 'Fixture.mpr'), mprName: 'Fixture.mpr', + id: 'fixture', displayName: 'fixture', otelService: 'fixture', defaultPort: '1', mxcli: './mxcli', + credentials: () => ({ user: 'u', pass: 'p', fallbackUser: '', fallbackPass: '' }), + readySelectors: ['.mx-page'], signOutPattern: null, dsCss: path.join(root, 'design', 'ds.css'), + NAV: {}, TARGETS: {}, PAGE_WIREFRAME: {}, probePage: () => null, exemplars: {}, walkthroughs: [], + roles: {}, walkthrough: null }; +EOF +printf '#!/bin/sh\necho "stub mxcli: no model here" >&2\nexit 1\n' > "$WORK/mxcli"; chmod +x "$WORK/mxcli" +echo '/* axe stub */' > "$WORK/node_modules/axe-core/axe.min.js" +echo '{"name":"axe-core","version":"0.0.0","main":"axe.min.js"}' > "$WORK/node_modules/axe-core/package.json" +echo '{"name":"playwright","version":"0.0.0","main":"index.js"}' > "$WORK/node_modules/playwright/package.json" + +STALE='{"instrument":"design-audit","STALE_MARKER":true,"checks":[]}' +run() { # $1 = playwright stub mode + cat > "$WORK/node_modules/playwright/index.js" < { + if ('$1' === 'nolaunch') throw new Error(MSG); + return { newContext: async () => { throw new Error('stub: context crashed'); }, close: async () => {} }; +} } }; +EOF + printf '%s' "$STALE" > "$D/artifacts/design-audit.json" + OUT="$(cd "$D" && MXCLI="$WORK/mxcli" APP_PORT=1 NODE_PATH="$WORK/node_modules" timeout 120 node design-audit.js --page M.Page 2>&1)"; RC=$? +} + +echo "== the browser does not launch (Playwright's own message) ==" +run nolaunch +F="$D/artifacts/design-audit.json" +if grep -q STALE_MARKER "$F" 2>/dev/null; then + bad "the previous run's design-audit.json is still there, unchanged" "rc=$RC $(printf '%s' "$OUT" | grep -m1 crashed)" +else + ok "design-audit.json was rewritten by this run" + node -e ' + const d = JSON.parse(require("fs").readFileSync(process.argv[1], "utf8")); + const r7 = d.checks.filter((c) => /^design-audit\/rung7\/(a11y|overflow|structure)\//.test(c.id)); + process.exit(r7.length === 3 && r7.every((c) => c.verdict === "fault" && /browser did not launch: .*Executable doesn.t exist/.test(c.detail)) ? 0 : 1); + ' "$F" && ok "each browser rung-7 check (a11y, overflow, structure) is a FAULT naming the launch failure" || bad "rung-7 rows do not name the launch failure" "$(node -e 'require(process.argv[1]).checks.filter((c) => /rung7/.test(c.id)).forEach((c) => console.log(c.id, c.verdict, String(c.detail).slice(0, 140)))' "$F")" +fi +[ "$RC" -eq 2 ] && ok "exit 2 (instrument fault), not a crash" || bad "exit code on a browser that does not launch" "rc=$RC" + +echo "== any other crash ==" +run crash +if [ -f "$F" ] && grep -q STALE_MARKER "$F"; then + bad "a crash left the previous run's design-audit.json in place" "rc=$RC" +else + ok "a crash leaves no stale design-audit.json behind" +fi +printf '%s\n' "$OUT" | grep -q "removed the previous run's" && ok "and says it removed it" || bad "no line about the removed artifact" "$(printf '%s' "$OUT" | tail -3)" +[ "$RC" -eq 1 ] && ok "a crash still exits 1" || bad "crash exit code" "rc=$RC" + +echo "" +echo "PASS=$PASS FAIL=$FAIL" +[ "$FAIL" -eq 0 ] diff --git a/tests/wave2/test-exec-lock-watch.sh b/tests/wave2/test-exec-lock-watch.sh index 766bfdd0..c6c903fb 100755 --- a/tests/wave2/test-exec-lock-watch.sh +++ b/tests/wave2/test-exec-lock-watch.sh @@ -395,6 +395,17 @@ neg "alter page set Action = close_page" "alter page M.P { set Action = close_pa neg "alter page set OnChange = save_changes" "alter page M.P { set OnChange = save_changes on sw }\n" printf "alter page M.P {\n set Caption = 'never closed\n set Class = 'x' on b;\n" > "$WORK/open.mdl" expect "$WORK/open.mdl" "$UNK" "unterminated" "a string that never closes is unknown, never watch-safe" +# Field run 2026-11-20: the head of a demo-user statement printed its literals blank — +# `create or modify demo user '' ( Password: '', ...` — reading as an empty user name. A blanked +# literal now shows as '…'; the literal itself (here a password) is never printed. +printf "create or modify demo user 'demo_administrator' ( Password: 'Fx-Secret-9', Entity: Administration.Account, UserRoles: ('Administrator') );\n" > "$WORK/demouser.mdl" +OUT="$(cd "$WORK" && bash "$SUBJECT" --watch-compat demouser.mdl 2>&1)" +case "$OUT" in *"demo user '…' ( Password: '…'"*) ok "watch line marks blanked literals '…' (not an empty '')" ;; + *) bad "watch line still blanks literals to '': $OUT" ;; esac +OUT2="$(cd "$WORK" && bash "$SUBJECT" --change-class demouser.mdl 2>&1)" +case "$OUT2" in *"demo user '…'"*) ok "change-class line marks them the same way" ;; *) bad "change-class line: $OUT2" ;; esac +case "$OUT $OUT2" in *Fx-Secret-9*|*demo_administrator*) bad "a string literal (the password) was printed" ;; + *) ok "no literal printed: the password stays masked" ;; esac echo "-- watch-compat in a real run" cp "$GAL/05-demo-data.mdl" "$P/mdlsource/demo.mdl"