按建议,继续完成后续工作
结论:已新增 OPFS host-side 路径模型,覆盖 INI、tool table、parameter、G-code、preview cache 与 session snapshot 存储目标,并让 file-service 和浏览器 smoke 复用该模型;聚合 smoke 验证通过。
This commit is contained in:
@@ -5,6 +5,16 @@ import {
|
||||
loadTextFile,
|
||||
saveTextFile,
|
||||
} from "../../../runtime/opfs/file-service.js";
|
||||
import {
|
||||
defaultMachinePaths,
|
||||
gcodeProgramPath,
|
||||
machineIniPath,
|
||||
normalizeOpfsPath,
|
||||
parameterFilePath,
|
||||
previewCachePath,
|
||||
sessionSnapshotPath,
|
||||
toolTablePath,
|
||||
} from "../../../runtime/opfs/path-model.js";
|
||||
|
||||
class MockFileHandle {
|
||||
constructor(name) {
|
||||
@@ -63,6 +73,19 @@ const storage = {
|
||||
|
||||
assert.equal(await getOpfsRoot(storage), root);
|
||||
|
||||
assert.equal(normalizeOpfsPath("linuxcnc/machines/xyzab.ini"), "linuxcnc/machines/xyzab.ini");
|
||||
assert.equal(machineIniPath("xyzab-tdr"), "linuxcnc/machines/xyzab-tdr/machine.ini");
|
||||
assert.equal(toolTablePath("xyzab-tdr"), "linuxcnc/machines/xyzab-tdr/tool.tbl");
|
||||
assert.equal(parameterFilePath("xyzab-tdr"), "linuxcnc/machines/xyzab-tdr/linuxcnc.var");
|
||||
assert.equal(gcodeProgramPath("fixture.ngc"), "linuxcnc/gcode/fixture.ngc");
|
||||
assert.equal(previewCachePath("fixture"), "linuxcnc/preview-cache/fixture/preview.json");
|
||||
assert.equal(sessionSnapshotPath("session-1"), "linuxcnc/sessions/session-1/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",
|
||||
});
|
||||
|
||||
await saveTextFile(
|
||||
"linuxcnc/machines/xyzab.ini",
|
||||
"[EMC]\nMACHINE = opfs-smoke\n",
|
||||
@@ -81,6 +104,10 @@ await assert.rejects(
|
||||
() => saveTextFile("../escape.ini", "", storage),
|
||||
/Invalid OPFS path/,
|
||||
);
|
||||
assert.throws(
|
||||
() => machineIniPath("../escape"),
|
||||
/Invalid machine id/,
|
||||
);
|
||||
await assert.rejects(
|
||||
() => getOpfsRoot({}),
|
||||
/OPFS is not available/,
|
||||
|
||||
Reference in New Issue
Block a user