推进 OPFS 会话快照清单能力

This commit is contained in:
2026-06-14 14:50:23 +08:00
parent d5c11a852a
commit 2bff22e0d9
4 changed files with 165 additions and 4 deletions

View File

@@ -16,6 +16,7 @@ import {
toolTablePath,
} from "../../../runtime/opfs/path-model.js";
import {
createMachineSessionSnapshotPayload,
createSessionSnapshot,
loadSessionSnapshot,
saveSessionSnapshot,
@@ -216,12 +217,38 @@ assertSessionSnapshotStoragePath(
assertMachineFileStoragePaths("xyzab-tdr", defaultMachinePaths("xyzab-tdr"));
assertMachineFileStoragePaths("xyzab-tdr", machineFilePaths("xyzab-tdr"));
const snapshotPayload = {
const snapshotPayload = createMachineSessionSnapshotPayload("xyzab-tdr", {
gcodeFilename: "fixture.ngc",
});
assert.deepEqual(snapshotPayload, {
machineId: "xyzab-tdr",
files: {
ini: machineIniPath("xyzab-tdr"),
parameters: parameterFilePath("xyzab-tdr"),
toolTable: toolTablePath("xyzab-tdr"),
gcode: gcodeProgramPath("fixture.ngc"),
},
};
});
assert.deepEqual(
createMachineSessionSnapshotPayload("custom-machine", {
parameterFilename: "custom.var",
toolTableFilename: "custom-tool.tbl",
gcodeOpfsPath: "linuxcnc/gcode/custom-fixture.ngc",
}),
{
machineId: "custom-machine",
files: {
ini: "linuxcnc/machines/custom-machine/machine.ini",
parameters: "linuxcnc/machines/custom-machine/custom.var",
toolTable: "linuxcnc/machines/custom-machine/custom-tool.tbl",
gcode: "linuxcnc/gcode/custom-fixture.ngc",
},
},
);
assert.throws(
() => createMachineSessionSnapshotPayload("bad-machine", { gcodeFilename: "../escape.ngc" }),
/Invalid G-code filename/,
);
const snapshot = createSessionSnapshot("session-1", snapshotPayload, {
createdAt: "2026-06-08T00:00:00.000Z",
metadata: { source: "node-smoke" },