推进 INI 面板 run readiness workflow helper
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import assert from "node:assert/strict";
|
||||
|
||||
import {
|
||||
createRunSessionReadinessState,
|
||||
runGcodeSessionWorkflow,
|
||||
selectSessionGcodeProgram,
|
||||
} from "../../../runtime/ui/ini-panel/run-workflow.js";
|
||||
@@ -42,6 +43,61 @@ assert.deepEqual(snapshotProgram, {
|
||||
wasmPath: "/work/ui-session.ngc",
|
||||
});
|
||||
|
||||
const readiness = createRunSessionReadinessState({
|
||||
loadedSession: {
|
||||
ini: {
|
||||
wasmPath: "/work/session-machine.ini",
|
||||
},
|
||||
},
|
||||
snapshot: {
|
||||
sessionId: "ui-machine-session",
|
||||
metadata: {
|
||||
workflow: "save-session-snapshot",
|
||||
snapshotLabel: "ui-machine-session/ui-machine-session.json",
|
||||
defaultGcodeOpfsPath: "linuxcnc/gcode/ui-session.ngc",
|
||||
},
|
||||
payload: {
|
||||
files: {
|
||||
gcode: "linuxcnc/gcode/snapshot-session.ngc",
|
||||
},
|
||||
},
|
||||
},
|
||||
defaultFilename: "ui-session.ngc",
|
||||
defaultOpfsPath: "linuxcnc/gcode/ui-session.ngc",
|
||||
wasmPath: "/work/ui-session.ngc",
|
||||
gcodeFilenameFromProgramPath: (path) => path.split("/").at(-1),
|
||||
});
|
||||
|
||||
assert.deepEqual(readiness, {
|
||||
phase: "ready",
|
||||
canRun: true,
|
||||
missing: [],
|
||||
loadedSession: {
|
||||
iniWasmPath: "/work/session-machine.ini",
|
||||
},
|
||||
snapshot: {
|
||||
present: true,
|
||||
label: "ui-machine-session/ui-machine-session.json",
|
||||
workflow: "save-session-snapshot",
|
||||
gcodeOpfsPath: "linuxcnc/gcode/snapshot-session.ngc",
|
||||
},
|
||||
defaultProgram: {
|
||||
filename: "ui-session.ngc",
|
||||
opfsPath: "linuxcnc/gcode/ui-session.ngc",
|
||||
wasmPath: "/work/ui-session.ngc",
|
||||
},
|
||||
program: {
|
||||
filename: "snapshot-session.ngc",
|
||||
opfsPath: "linuxcnc/gcode/snapshot-session.ngc",
|
||||
source: "snapshot",
|
||||
wasmPath: "/work/ui-session.ngc",
|
||||
},
|
||||
runButton: {
|
||||
enabled: true,
|
||||
reason: null,
|
||||
},
|
||||
});
|
||||
|
||||
const calls = [];
|
||||
const workflow = await runGcodeSessionWorkflow({
|
||||
interp: {
|
||||
@@ -126,6 +182,7 @@ assert.deepEqual(workflow.fields, {
|
||||
runOpfsPath: "linuxcnc/gcode/snapshot-session.ngc",
|
||||
runWasmPath: "/work/ui-session.ngc",
|
||||
});
|
||||
assert.deepEqual(workflow.readiness, readiness);
|
||||
|
||||
assert.deepEqual(workflow.motionSnapshots, [{ line: 1 }]);
|
||||
|
||||
|
||||
@@ -13,6 +13,60 @@ import {
|
||||
renderMachineSessionControlView,
|
||||
} from "../../../runtime/ui/ini-panel/control-view-renderer.js";
|
||||
|
||||
const runReadinessFixture = {
|
||||
phase: "ready",
|
||||
canRun: true,
|
||||
missing: [],
|
||||
loadedSession: {
|
||||
iniWasmPath: "/work/session-machine.ini",
|
||||
},
|
||||
snapshot: {
|
||||
present: true,
|
||||
label: "ui-machine-session/ui-machine-session.json",
|
||||
workflow: "save-session-snapshot",
|
||||
gcodeOpfsPath: "linuxcnc/gcode/ui-session.ngc",
|
||||
},
|
||||
defaultProgram: {
|
||||
filename: "ui-session.ngc",
|
||||
opfsPath: "linuxcnc/gcode/ui-session.ngc",
|
||||
wasmPath: "/work/ui-session.ngc",
|
||||
},
|
||||
program: {
|
||||
filename: "ui-session.ngc",
|
||||
opfsPath: "linuxcnc/gcode/ui-session.ngc",
|
||||
source: "default",
|
||||
wasmPath: "/work/ui-session.ngc",
|
||||
},
|
||||
runButton: {
|
||||
enabled: true,
|
||||
reason: null,
|
||||
},
|
||||
};
|
||||
|
||||
const expectedRunReadinessReport = {
|
||||
phase: "ready",
|
||||
canRun: true,
|
||||
missing: [],
|
||||
buttonEnabled: true,
|
||||
buttonReason: null,
|
||||
programSource: "default",
|
||||
programOpfsPath: "linuxcnc/gcode/ui-session.ngc",
|
||||
programWasmPath: "/work/ui-session.ngc",
|
||||
iniWasmPath: "/work/session-machine.ini",
|
||||
};
|
||||
|
||||
const expectedEmptyRunReadinessReport = {
|
||||
phase: null,
|
||||
canRun: false,
|
||||
missing: [],
|
||||
buttonEnabled: false,
|
||||
buttonReason: null,
|
||||
programSource: null,
|
||||
programOpfsPath: null,
|
||||
programWasmPath: null,
|
||||
iniWasmPath: null,
|
||||
};
|
||||
|
||||
const summary = createIniPanelStateSummary({
|
||||
badges: {
|
||||
ini: "INI WASM: ready",
|
||||
@@ -37,6 +91,7 @@ const summary = createIniPanelStateSummary({
|
||||
iniOpfsPath: "linuxcnc/machines/xyzab-tdr/machine.ini",
|
||||
iniWasmPath: "/work/session-machine.ini",
|
||||
},
|
||||
runReadiness: runReadinessFixture,
|
||||
run: {
|
||||
runStatus: "ok",
|
||||
programSource: "snapshot",
|
||||
@@ -68,6 +123,7 @@ assert.deepEqual(summary, {
|
||||
iniOpfsPath: "linuxcnc/machines/xyzab-tdr/machine.ini",
|
||||
iniWasmPath: "/work/session-machine.ini",
|
||||
},
|
||||
runReadiness: runReadinessFixture,
|
||||
run: {
|
||||
runStatus: "ok",
|
||||
programSource: "snapshot",
|
||||
@@ -87,6 +143,7 @@ assert.deepEqual(
|
||||
machineFiles: null,
|
||||
sessionSnapshot: null,
|
||||
sessionLoad: null,
|
||||
runReadiness: null,
|
||||
run: null,
|
||||
fiveaxisRemap: null,
|
||||
},
|
||||
@@ -108,6 +165,7 @@ assert.deepEqual(
|
||||
sessionLoad: {
|
||||
iniWasmPath: "/work/session-machine.ini",
|
||||
},
|
||||
runReadiness: runReadinessFixture,
|
||||
selectedProgram: {
|
||||
source: "snapshot",
|
||||
opfsPath: "linuxcnc/gcode/ui-session.ngc",
|
||||
@@ -149,6 +207,7 @@ assert.deepEqual(
|
||||
sessionLoad: {
|
||||
iniWasmPath: "/work/session-machine.ini",
|
||||
},
|
||||
runReadiness: runReadinessFixture,
|
||||
run: {
|
||||
runStatus: "ok",
|
||||
programSource: "snapshot",
|
||||
@@ -219,6 +278,7 @@ assert.deepEqual(
|
||||
parameterWasmPath: "/work/session-linuxcnc.var",
|
||||
toolTableWasmPath: "/work/session-tool.tbl",
|
||||
},
|
||||
runReadiness: runReadinessFixture,
|
||||
selectedProgram: {
|
||||
source: "snapshot",
|
||||
opfsPath: "linuxcnc/gcode/ui-session.ngc",
|
||||
@@ -261,6 +321,7 @@ assert.deepEqual(
|
||||
opfsPath: "linuxcnc/gcode/ui-session.ngc",
|
||||
wasmPath: "/work/ui-session.ngc",
|
||||
},
|
||||
runReadiness: expectedRunReadinessReport,
|
||||
run: {
|
||||
status: "ok",
|
||||
canonicalEventCount: 2,
|
||||
@@ -299,6 +360,7 @@ const expectedExportReport = {
|
||||
opfsPath: null,
|
||||
wasmPath: null,
|
||||
},
|
||||
runReadiness: expectedEmptyRunReadinessReport,
|
||||
run: {
|
||||
status: null,
|
||||
canonicalEventCount: 0,
|
||||
@@ -350,6 +412,7 @@ assert.deepEqual(
|
||||
runStatus: "ok",
|
||||
runWorkflow: "save-session-snapshot",
|
||||
},
|
||||
runReadiness: runReadinessFixture,
|
||||
run: {
|
||||
runStatus: "ok",
|
||||
canonicalEventCount: 2,
|
||||
@@ -364,6 +427,7 @@ assert.deepEqual(
|
||||
interp: "Interpreter WASM: ready",
|
||||
opfs: "OPFS: ready",
|
||||
},
|
||||
runReadiness: expectedRunReadinessReport,
|
||||
lastAction: "run-gcode",
|
||||
error: null,
|
||||
session: {
|
||||
@@ -407,6 +471,7 @@ const expectedBundleReport = {
|
||||
opfsPath: null,
|
||||
wasmPath: null,
|
||||
},
|
||||
runReadiness: expectedRunReadinessReport,
|
||||
run: {
|
||||
status: "ok",
|
||||
canonicalEventCount: 2,
|
||||
@@ -434,6 +499,7 @@ assert.deepEqual(
|
||||
runStatus: "ok",
|
||||
runWorkflow: "save-session-snapshot",
|
||||
},
|
||||
runReadiness: runReadinessFixture,
|
||||
run: {
|
||||
runStatus: "ok",
|
||||
canonicalEventCount: 2,
|
||||
@@ -458,6 +524,7 @@ assert.deepEqual(
|
||||
},
|
||||
lastAction: "run-gcode",
|
||||
error: null,
|
||||
runReadiness: expectedRunReadinessReport,
|
||||
session: {
|
||||
snapshotLabel: "ui-machine-session/ui-machine-session.json",
|
||||
workflow: "save-session-snapshot",
|
||||
@@ -501,6 +568,7 @@ assert.deepEqual(
|
||||
toolTable: null,
|
||||
gcode: "linuxcnc/gcode/ui-session.ngc",
|
||||
},
|
||||
runReadiness: expectedRunReadinessReport,
|
||||
run: {
|
||||
status: "ok",
|
||||
canonicalEventCount: 2,
|
||||
@@ -539,6 +607,8 @@ assert.deepEqual(
|
||||
id: "run",
|
||||
title: "Run",
|
||||
rows: [
|
||||
{ label: "Ready", value: "ready" },
|
||||
{ label: "Button", value: "enabled" },
|
||||
{ label: "Status", value: "ok" },
|
||||
{ label: "Canonical events", value: 2 },
|
||||
{ label: "Motion snapshots", value: 2 },
|
||||
@@ -578,6 +648,7 @@ const renderedControlView = renderMachineSessionControlView(
|
||||
lastAction: "run-gcode",
|
||||
error: null,
|
||||
session: expectedBundleReport.session,
|
||||
runReadiness: expectedBundleReport.runReadiness,
|
||||
run: expectedBundleReport.run,
|
||||
},
|
||||
}),
|
||||
@@ -588,7 +659,7 @@ assert.equal(renderedControlView.sectionNodes.length, 3);
|
||||
assert.equal(renderedControlView.sectionNodes[2].dataset.sectionId, "run");
|
||||
assert.equal(
|
||||
renderedControlView.sectionNodes[2].children[1].children[3].textContent,
|
||||
"2",
|
||||
"enabled",
|
||||
);
|
||||
|
||||
assert.deepEqual(
|
||||
|
||||
Reference in New Issue
Block a user