推进 INI 面板 session snapshot workflow helper
This commit is contained in:
107
wasm-port/tests/ui/node/verify_ini_panel_session_workflow.mjs
Normal file
107
wasm-port/tests/ui/node/verify_ini_panel_session_workflow.mjs
Normal file
@@ -0,0 +1,107 @@
|
||||
import assert from "node:assert/strict";
|
||||
|
||||
import {
|
||||
saveMachineSessionSnapshotWorkflow,
|
||||
} from "../../../runtime/ui/ini-panel/session-workflow.js";
|
||||
|
||||
const calls = [];
|
||||
const workflow = await saveMachineSessionSnapshotWorkflow({
|
||||
machineId: "xyzab-tdr",
|
||||
snapshotId: "ui-machine-session",
|
||||
snapshotFilename: "ui-machine-session.json",
|
||||
snapshotLabel: "ui-machine-session/ui-machine-session.json",
|
||||
iniText: "[EMC]\nMACHINE = xyzab-tdr\n",
|
||||
toolTableText: "T2 P7 Z3.125 D1.5 I12 J34 Q4 ;ui session tool\n",
|
||||
parameterText: "5161 0.0\n",
|
||||
gcodeFilename: "ui-session.ngc",
|
||||
gcodeText: "G0 X1.0 Y2.0 (Comment)\nG1 X3.0 Y4.0 F120.0\n",
|
||||
metadata: {
|
||||
source: "ini-panel",
|
||||
workflow: "save-session-snapshot",
|
||||
snapshotLabel: "ui-machine-session/ui-machine-session.json",
|
||||
defaultGcodeOpfsPath: "linuxcnc/gcode/ui-session.ngc",
|
||||
},
|
||||
saveMachineTextFiles: async (machineId, files) => {
|
||||
calls.push(["saveMachineTextFiles", machineId, files]);
|
||||
},
|
||||
saveGcodeProgram: async (filename, text) => {
|
||||
calls.push(["saveGcodeProgram", filename, text]);
|
||||
},
|
||||
saveMachineSessionSnapshot: async (snapshotId, machineId, options) => {
|
||||
calls.push(["saveMachineSessionSnapshot", snapshotId, machineId, options]);
|
||||
return {
|
||||
sessionId: snapshotId,
|
||||
metadata: options.metadata,
|
||||
payload: {
|
||||
files: {
|
||||
ini: "linuxcnc/machines/xyzab-tdr/machine.ini",
|
||||
parameters: "linuxcnc/machines/xyzab-tdr/linuxcnc.var",
|
||||
toolTable: "linuxcnc/machines/xyzab-tdr/tool.tbl",
|
||||
gcode: "linuxcnc/gcode/ui-session.ngc",
|
||||
},
|
||||
},
|
||||
};
|
||||
},
|
||||
});
|
||||
|
||||
assert.deepEqual(calls, [
|
||||
[
|
||||
"saveMachineTextFiles",
|
||||
"xyzab-tdr",
|
||||
{
|
||||
ini: "[EMC]\nMACHINE = xyzab-tdr\n",
|
||||
toolTable: "T2 P7 Z3.125 D1.5 I12 J34 Q4 ;ui session tool\n",
|
||||
parameters: "5161 0.0\n",
|
||||
},
|
||||
],
|
||||
[
|
||||
"saveGcodeProgram",
|
||||
"ui-session.ngc",
|
||||
"G0 X1.0 Y2.0 (Comment)\nG1 X3.0 Y4.0 F120.0\n",
|
||||
],
|
||||
[
|
||||
"saveMachineSessionSnapshot",
|
||||
"ui-machine-session",
|
||||
"xyzab-tdr",
|
||||
{
|
||||
filename: "ui-machine-session.json",
|
||||
gcodeFilename: "ui-session.ngc",
|
||||
metadata: {
|
||||
source: "ini-panel",
|
||||
workflow: "save-session-snapshot",
|
||||
snapshotLabel: "ui-machine-session/ui-machine-session.json",
|
||||
defaultGcodeOpfsPath: "linuxcnc/gcode/ui-session.ngc",
|
||||
},
|
||||
},
|
||||
],
|
||||
]);
|
||||
|
||||
assert.deepEqual(workflow.summary, {
|
||||
snapshotLabel: "ui-machine-session/ui-machine-session.json",
|
||||
workflow: "save-session-snapshot",
|
||||
defaultGcodeOpfsPath: "linuxcnc/gcode/ui-session.ngc",
|
||||
iniOpfsPath: "linuxcnc/machines/xyzab-tdr/machine.ini",
|
||||
parameterOpfsPath: "linuxcnc/machines/xyzab-tdr/linuxcnc.var",
|
||||
toolTableOpfsPath: "linuxcnc/machines/xyzab-tdr/tool.tbl",
|
||||
gcodeOpfsPath: "linuxcnc/gcode/ui-session.ngc",
|
||||
});
|
||||
|
||||
assert.deepEqual(workflow.fields, {
|
||||
sessionIni: "linuxcnc/machines/xyzab-tdr/machine.ini",
|
||||
sessionParameters: "linuxcnc/machines/xyzab-tdr/linuxcnc.var",
|
||||
sessionToolTable: "linuxcnc/machines/xyzab-tdr/tool.tbl",
|
||||
sessionGcode: "linuxcnc/gcode/ui-session.ngc",
|
||||
sessionSnapshot: "ui-machine-session/ui-machine-session.json",
|
||||
});
|
||||
|
||||
assert.deepEqual(workflow.logLines, [
|
||||
"Snapshot: ui-machine-session/ui-machine-session.json",
|
||||
"Workflow: save-session-snapshot",
|
||||
"Default G-code: linuxcnc/gcode/ui-session.ngc",
|
||||
"INI: linuxcnc/machines/xyzab-tdr/machine.ini",
|
||||
"Parameter file: linuxcnc/machines/xyzab-tdr/linuxcnc.var",
|
||||
"Tool table file: linuxcnc/machines/xyzab-tdr/tool.tbl",
|
||||
"G-code: linuxcnc/gcode/ui-session.ngc",
|
||||
]);
|
||||
|
||||
console.log("ini_panel_session_workflow_node_smoke=ok");
|
||||
6
wasm-port/tests/ui/node/verify_ini_panel_session_workflow.sh
Executable file
6
wasm-port/tests/ui/node/verify_ini_panel_session_workflow.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_session_workflow.mjs"
|
||||
@@ -5,6 +5,7 @@ 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_session_workflow.sh"
|
||||
"$ROOT_DIR/tests/ui/node/verify_ini_panel_machine_file_summary.sh"
|
||||
"$ROOT_DIR/tests/ui/node/verify_ini_panel_state_summary.sh"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user