Guard OPFS path helper staging
This commit is contained in:
@@ -119,6 +119,18 @@ function assertPreviewCacheStoragePath(cacheKey, path, filename = "preview.json"
|
||||
);
|
||||
}
|
||||
|
||||
function assertMachineFileStoragePaths(machineId, paths) {
|
||||
assert.deepEqual(
|
||||
paths,
|
||||
{
|
||||
ini: `linuxcnc/machines/${machineId}/machine.ini`,
|
||||
toolTable: `linuxcnc/machines/${machineId}/tool.tbl`,
|
||||
parameters: `linuxcnc/machines/${machineId}/linuxcnc.var`,
|
||||
},
|
||||
`${machineId} machine file OPFS path drift`,
|
||||
);
|
||||
}
|
||||
|
||||
assert.equal(await getOpfsRoot(storage), root);
|
||||
|
||||
assert.equal(normalizeOpfsPath("linuxcnc/machines/xyzab.ini"), "linuxcnc/machines/xyzab.ini");
|
||||
@@ -145,12 +157,8 @@ assertSessionSnapshotStoragePath(
|
||||
sessionSnapshotPath("session-1", "custom-snapshot.json"),
|
||||
"custom-snapshot.json",
|
||||
);
|
||||
assert.deepEqual(defaultMachinePaths("xyzab-tdr"), {
|
||||
ini: "linuxcnc/machines/xyzab-tdr/machine.ini",
|
||||
toolTable: "linuxcnc/machines/xyzab-tdr/tool.tbl",
|
||||
parameters: "linuxcnc/machines/xyzab-tdr/linuxcnc.var",
|
||||
});
|
||||
assert.deepEqual(machineFilePaths("xyzab-tdr"), defaultMachinePaths("xyzab-tdr"));
|
||||
assertMachineFileStoragePaths("xyzab-tdr", defaultMachinePaths("xyzab-tdr"));
|
||||
assertMachineFileStoragePaths("xyzab-tdr", machineFilePaths("xyzab-tdr"));
|
||||
|
||||
const snapshotPayload = {
|
||||
files: {
|
||||
@@ -653,6 +661,10 @@ assert.throws(
|
||||
() => sessionSnapshotPath("session-1", "nested/snapshot.json"),
|
||||
/Invalid session snapshot filename/,
|
||||
);
|
||||
assert.throws(
|
||||
() => previewCachePath("fixture", "nested/preview.json"),
|
||||
/Invalid preview cache filename/,
|
||||
);
|
||||
assert.throws(
|
||||
() => gcodeProgramPath("../escape.ngc"),
|
||||
/Invalid G-code filename/,
|
||||
|
||||
Reference in New Issue
Block a user