推进 INI 面板状态汇总 helper
This commit is contained in:
@@ -71,6 +71,7 @@ UI helper docs:
|
||||
- `wasm-port/docs/ui-run-summary-helpers.md`
|
||||
- `wasm-port/docs/ui-session-summary-helpers.md`
|
||||
- `wasm-port/docs/ui-machine-file-helpers.md`
|
||||
- `wasm-port/docs/ui-panel-state-summary.md`
|
||||
|
||||
The current browser smoke validation command is:
|
||||
|
||||
|
||||
46
wasm-port/docs/ui-panel-state-summary.md
Normal file
46
wasm-port/docs/ui-panel-state-summary.md
Normal file
@@ -0,0 +1,46 @@
|
||||
# UI Panel State Summary
|
||||
|
||||
## Purpose
|
||||
|
||||
`runtime/ui/ini-panel/panel-state-summary.js` contains a pure helper for
|
||||
bundling the already-observed host/runtime boundary state of the INI panel into
|
||||
a single machine-readable snapshot.
|
||||
|
||||
The helper does not implement CNC behavior. It only packages the summary
|
||||
objects produced by the run/session/machine-file helpers and the visible badge
|
||||
state so browser tests or future UI consumers can compare panel state without
|
||||
reading ad hoc DOM text.
|
||||
|
||||
## `createIniPanelStateSummary(input)`
|
||||
|
||||
`input` may contain:
|
||||
|
||||
```js
|
||||
{
|
||||
badges: { ini: "INI WASM: ready", interp: "Interpreter WASM: ready", opfs: "OPFS: ready" },
|
||||
machine: { machine: "xyzab-tdr", kinematics: "trivkins" },
|
||||
machineFiles: { iniOpfsPath: "...", toolTableOpfsPath: "...", parameterOpfsPath: "...", gcodeOpfsPath: "..." },
|
||||
sessionSnapshot: { snapshotLabel: "...", workflow: "save-session-snapshot" },
|
||||
sessionLoad: { iniOpfsPath: "...", iniWasmPath: "..." },
|
||||
run: { runStatus: "ok", programSource: "snapshot" },
|
||||
fiveaxisRemap: "ok"
|
||||
}
|
||||
```
|
||||
|
||||
The returned snapshot preserves those nested objects and normalizes missing
|
||||
badge entries to `null`.
|
||||
|
||||
## Boundary Rules
|
||||
|
||||
- Do not parse G-code text in this helper.
|
||||
- Do not infer CNC semantics from the nested summaries.
|
||||
- Keep the helper as a bundling layer over already-observed UI boundary state.
|
||||
|
||||
## Validation
|
||||
|
||||
The helper is covered by:
|
||||
|
||||
```bash
|
||||
wasm-port/tests/ui/node/verify_ini_panel_state_summary.sh
|
||||
wasm-port/tests/ui/node/verify_ui_node_smokes.sh
|
||||
```
|
||||
23
wasm-port/runtime/ui/ini-panel/panel-state-summary.js
Normal file
23
wasm-port/runtime/ui/ini-panel/panel-state-summary.js
Normal file
@@ -0,0 +1,23 @@
|
||||
export function createIniPanelStateSummary({
|
||||
badges = {},
|
||||
machine = null,
|
||||
machineFiles = null,
|
||||
sessionSnapshot = null,
|
||||
sessionLoad = null,
|
||||
run = null,
|
||||
fiveaxisRemap = null,
|
||||
} = {}) {
|
||||
return {
|
||||
badges: {
|
||||
ini: badges.ini ?? null,
|
||||
interp: badges.interp ?? null,
|
||||
opfs: badges.opfs ?? null,
|
||||
},
|
||||
machine,
|
||||
machineFiles,
|
||||
sessionSnapshot,
|
||||
sessionLoad,
|
||||
run,
|
||||
fiveaxisRemap: fiveaxisRemap ?? null,
|
||||
};
|
||||
}
|
||||
84
wasm-port/tests/ui/node/verify_ini_panel_state_summary.mjs
Normal file
84
wasm-port/tests/ui/node/verify_ini_panel_state_summary.mjs
Normal file
@@ -0,0 +1,84 @@
|
||||
import assert from "node:assert/strict";
|
||||
|
||||
import { createIniPanelStateSummary } from "../../../runtime/ui/ini-panel/panel-state-summary.js";
|
||||
|
||||
const summary = createIniPanelStateSummary({
|
||||
badges: {
|
||||
ini: "INI WASM: ready",
|
||||
interp: "Interpreter WASM: ready",
|
||||
opfs: "OPFS: ready",
|
||||
},
|
||||
machine: {
|
||||
machine: "xyzab-tdr",
|
||||
kinematics: "trivkins",
|
||||
},
|
||||
machineFiles: {
|
||||
iniOpfsPath: "linuxcnc/machines/xyzab-tdr/machine.ini",
|
||||
toolTableOpfsPath: "linuxcnc/machines/xyzab-tdr/tool.tbl",
|
||||
parameterOpfsPath: "linuxcnc/machines/xyzab-tdr/linuxcnc.var",
|
||||
gcodeOpfsPath: "linuxcnc/gcode/ui-session.ngc",
|
||||
},
|
||||
sessionSnapshot: {
|
||||
snapshotLabel: "ui-machine-session/ui-machine-session.json",
|
||||
workflow: "save-session-snapshot",
|
||||
},
|
||||
sessionLoad: {
|
||||
iniOpfsPath: "linuxcnc/machines/xyzab-tdr/machine.ini",
|
||||
iniWasmPath: "/work/session-machine.ini",
|
||||
},
|
||||
run: {
|
||||
runStatus: "ok",
|
||||
programSource: "snapshot",
|
||||
},
|
||||
fiveaxisRemap: "ok",
|
||||
});
|
||||
|
||||
assert.deepEqual(summary, {
|
||||
badges: {
|
||||
ini: "INI WASM: ready",
|
||||
interp: "Interpreter WASM: ready",
|
||||
opfs: "OPFS: ready",
|
||||
},
|
||||
machine: {
|
||||
machine: "xyzab-tdr",
|
||||
kinematics: "trivkins",
|
||||
},
|
||||
machineFiles: {
|
||||
iniOpfsPath: "linuxcnc/machines/xyzab-tdr/machine.ini",
|
||||
toolTableOpfsPath: "linuxcnc/machines/xyzab-tdr/tool.tbl",
|
||||
parameterOpfsPath: "linuxcnc/machines/xyzab-tdr/linuxcnc.var",
|
||||
gcodeOpfsPath: "linuxcnc/gcode/ui-session.ngc",
|
||||
},
|
||||
sessionSnapshot: {
|
||||
snapshotLabel: "ui-machine-session/ui-machine-session.json",
|
||||
workflow: "save-session-snapshot",
|
||||
},
|
||||
sessionLoad: {
|
||||
iniOpfsPath: "linuxcnc/machines/xyzab-tdr/machine.ini",
|
||||
iniWasmPath: "/work/session-machine.ini",
|
||||
},
|
||||
run: {
|
||||
runStatus: "ok",
|
||||
programSource: "snapshot",
|
||||
},
|
||||
fiveaxisRemap: "ok",
|
||||
});
|
||||
|
||||
assert.deepEqual(
|
||||
createIniPanelStateSummary(),
|
||||
{
|
||||
badges: {
|
||||
ini: null,
|
||||
interp: null,
|
||||
opfs: null,
|
||||
},
|
||||
machine: null,
|
||||
machineFiles: null,
|
||||
sessionSnapshot: null,
|
||||
sessionLoad: null,
|
||||
run: null,
|
||||
fiveaxisRemap: null,
|
||||
},
|
||||
);
|
||||
|
||||
console.log("ini_panel_state_summary_node_smoke=ok");
|
||||
6
wasm-port/tests/ui/node/verify_ini_panel_state_summary.sh
Executable file
6
wasm-port/tests/ui/node/verify_ini_panel_state_summary.sh
Executable file
@@ -0,0 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
ROOT_DIR="$(cd "$(dirname "$0")/../../.." && pwd)"
|
||||
|
||||
node "$ROOT_DIR/tests/ui/node/verify_ini_panel_state_summary.mjs"
|
||||
@@ -6,5 +6,6 @@ ROOT_DIR="$(cd "$(dirname "$0")/../../.." && pwd)"
|
||||
"$ROOT_DIR/tests/ui/node/verify_ini_panel_run_summary.sh"
|
||||
"$ROOT_DIR/tests/ui/node/verify_ini_panel_session_summary.sh"
|
||||
"$ROOT_DIR/tests/ui/node/verify_ini_panel_machine_file_summary.sh"
|
||||
"$ROOT_DIR/tests/ui/node/verify_ini_panel_state_summary.sh"
|
||||
|
||||
echo "ui_node_smokes=ok"
|
||||
|
||||
Reference in New Issue
Block a user