Guard OPFS preview-cache staging

This commit is contained in:
2026-06-13 18:00:29 +08:00
parent 422d9f42c7
commit c699c7769d
2 changed files with 75 additions and 1 deletions

View File

@@ -111,6 +111,14 @@ function assertSessionSnapshotStoragePath(sessionId, path, filename = "snapshot.
);
}
function assertPreviewCacheStoragePath(cacheKey, path, filename = "preview.json") {
assert.equal(
path,
`linuxcnc/preview-cache/${cacheKey}/${filename}`,
`${cacheKey}/${filename} preview cache OPFS path drift`,
);
}
assert.equal(await getOpfsRoot(storage), root);
assert.equal(normalizeOpfsPath("linuxcnc/machines/xyzab.ini"), "linuxcnc/machines/xyzab.ini");
@@ -122,7 +130,12 @@ assertGcodeProgramStoragePath(
"custom-fixture.ngc",
gcodeProgramPath("custom-fixture.ngc"),
);
assert.equal(previewCachePath("fixture"), "linuxcnc/preview-cache/fixture/preview.json");
assertPreviewCacheStoragePath("fixture", previewCachePath("fixture"));
assertPreviewCacheStoragePath(
"fixture",
previewCachePath("fixture", "custom-preview.json"),
"custom-preview.json",
);
assertSessionSnapshotStoragePath(
"session-1",
sessionSnapshotPath("session-1"),