推进 OPFS G-code 程序路径 helper
This commit is contained in:
@@ -22,6 +22,7 @@
|
||||
saveSessionSnapshot,
|
||||
} from "../../runtime/opfs/snapshot-store.js";
|
||||
import {
|
||||
gcodeFilenameFromProgramPath,
|
||||
loadGcodeProgram,
|
||||
loadMachineTextFiles,
|
||||
saveGcodeProgram,
|
||||
@@ -328,6 +329,16 @@ TOOL_TABLE = browser-tool.tbl
|
||||
"linuxcnc/gcode/browser-custom.ngc",
|
||||
"custom G-code path",
|
||||
);
|
||||
assertEqual(
|
||||
gcodeFilenameFromProgramPath("linuxcnc/gcode/browser-custom.ngc"),
|
||||
"browser-custom.ngc",
|
||||
"custom G-code filename from OPFS path",
|
||||
);
|
||||
await assertRejects(
|
||||
"browser G-code invalid program OPFS path",
|
||||
() => Promise.resolve(gcodeFilenameFromProgramPath("linuxcnc/machines/browser-custom.ngc")),
|
||||
/Invalid G-code program OPFS path/,
|
||||
);
|
||||
await saveGcodeProgram("browser-smoke.ngc", "G0 X0 Y0\nM2\n");
|
||||
assertEqual(await loadGcodeProgram("browser-smoke.ngc"), "G0 X0 Y0\nM2\n", "gcode text");
|
||||
await saveGcodeProgram("browser-custom.ngc", "G1 X1 F10\nM2\n");
|
||||
|
||||
@@ -25,6 +25,7 @@ import {
|
||||
validateSessionSnapshot,
|
||||
} from "../../../runtime/opfs/snapshot-store.js";
|
||||
import {
|
||||
gcodeFilenameFromProgramPath,
|
||||
loadGcodeProgram,
|
||||
loadMachineTextFiles,
|
||||
machineFilePaths,
|
||||
@@ -201,6 +202,18 @@ assertGcodeProgramStoragePath(
|
||||
"custom-fixture.ngc",
|
||||
gcodeProgramPath("custom-fixture.ngc"),
|
||||
);
|
||||
assert.equal(
|
||||
gcodeFilenameFromProgramPath("linuxcnc/gcode/fixture.ngc"),
|
||||
"fixture.ngc",
|
||||
);
|
||||
assert.throws(
|
||||
() => gcodeFilenameFromProgramPath("linuxcnc/machines/xyzab-tdr/fixture.ngc"),
|
||||
/Invalid G-code program OPFS path/,
|
||||
);
|
||||
assert.throws(
|
||||
() => gcodeFilenameFromProgramPath("linuxcnc/gcode/nested/fixture.ngc"),
|
||||
/Invalid G-code program OPFS path/,
|
||||
);
|
||||
assertPreviewCacheStoragePath("fixture", previewCachePath("fixture"));
|
||||
assertPreviewCacheStoragePath(
|
||||
"fixture",
|
||||
|
||||
Reference in New Issue
Block a user