diff --git a/web/test-browser-wasm-smoke-opfs-mirror-sections.js b/web/test-browser-wasm-smoke-opfs-mirror-sections.js index d36a6be..a52a05c 100644 --- a/web/test-browser-wasm-smoke-opfs-mirror-sections.js +++ b/web/test-browser-wasm-smoke-opfs-mirror-sections.js @@ -1,8 +1,11 @@ export async function runBrowserOpfsMirrorSections(context, simulator) { const { + expectEvent, expectMissingWasmPath, expectText, + near, runSection, + withSmokeSimulator, } = context; await runSection("opfs wasm mirror persist file", async () => { @@ -20,6 +23,25 @@ export async function runBrowserOpfsMirrorSections(context, simulator) { "persisted WASM filesystem file was not readable from OPFS"); }); + await runSection("opfs persisted wasm mirror parse in new instance", async () => { + await withSmokeSimulator(async (restoredMirrorSimulator) => { + // LinuxCNC source basis: rs274ngc_pre.cc read_text() reads + // program blocks after the OPFS file is mirrored into the WASM FS. + const persistedProgram = new TextDecoder().decode( + await restoredMirrorSimulator.fs.opfs.readFile("programs/browser-persisted.ngc"), + ); + expectText(persistedProgram, "G21 G90\nG0 X2\n", + "persisted WASM mirror file was not restored from OPFS in a new instance"); + const persistedEvents = await restoredMirrorSimulator.parseFile( + "programs/browser-persisted.ngc", + "linuxcnc", + { backend: "linuxcnc-rs274" }, + ); + expectEvent(persistedEvents, (event) => event.type === "rapid" && near(event.end.x, 2), + "persisted WASM mirror file was not parsed through LinuxCNC in a new instance"); + }); + }); + await runSection("opfs copy and move mirror files", async () => { // LinuxCNC source basis: rs274ngc_pre.cc save_parameters() // links the current parameter file to filename + ".bak", then