推进 OPFS G-code 程序路径 helper

This commit is contained in:
2026-06-14 15:57:35 +08:00
parent a158f66071
commit d40a6422e8
5 changed files with 115 additions and 13 deletions

View File

@@ -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",