第 6 组:源码链接、构建和文档约束闭环完成
This commit is contained in:
66
web/test-browser-wasm-smoke-app-sections.js
Normal file
66
web/test-browser-wasm-smoke-app-sections.js
Normal file
@@ -0,0 +1,66 @@
|
||||
export async function runBrowserAppOpfsSections(context) {
|
||||
const {
|
||||
browserHasOpfs,
|
||||
createHiddenAppFrame,
|
||||
disposeAppFrame,
|
||||
expectIncludes,
|
||||
expectText,
|
||||
getAppFrameSimulator,
|
||||
parseAppFrameProgram,
|
||||
runSection,
|
||||
waitFor,
|
||||
waitForAppAlarm,
|
||||
waitForAppControls,
|
||||
} = context;
|
||||
if (!browserHasOpfs()) {
|
||||
return;
|
||||
}
|
||||
await runSection("browser app opfs save", async () => {
|
||||
const appFrame = await createHiddenAppFrame();
|
||||
try {
|
||||
await waitForAppControls(appFrame, "app frame did not load CNC controls");
|
||||
parseAppFrameProgram(appFrame, "G21 G90\nG0 X1\nG28.1\nM30\n");
|
||||
await waitForAppAlarm(appFrame, "OK ", "app frame did not parse program");
|
||||
const appSimulator = await getAppFrameSimulator(appFrame, "app frame did not create OPFS simulator workspace");
|
||||
const savedProgram = new TextDecoder().decode(await appSimulator.fs.opfs.readFile("programs/current.ngc"));
|
||||
expectText(savedProgram, "G21 G90\nG0 X1\nG28.1\nM30\n",
|
||||
"app frame did not persist current program into OPFS");
|
||||
const savedParameterFile = new TextDecoder().decode(await appSimulator.fs.opfs.readFile("parameters/rs274ngc.var"));
|
||||
expectIncludes(savedParameterFile, "5161\t1.000000",
|
||||
"app frame did not persist LinuxCNC parameter state into OPFS");
|
||||
} finally {
|
||||
await disposeAppFrame(appFrame);
|
||||
}
|
||||
});
|
||||
await runSection("browser app opfs restore", async () => {
|
||||
const restoredAppFrame = await createHiddenAppFrame();
|
||||
try {
|
||||
await waitForAppControls(restoredAppFrame, "restored app frame did not load CNC controls");
|
||||
await waitFor(() => {
|
||||
const restoredInput = restoredAppFrame.contentDocument?.querySelector("#programInput");
|
||||
return restoredInput?.value === "G21 G90\nG0 X1\nG28.1\nM30\n";
|
||||
}, "app frame did not restore current program from OPFS after reload");
|
||||
await waitForAppAlarm(
|
||||
restoredAppFrame,
|
||||
"OPFS PROGRAM RESTORED",
|
||||
"app frame did not report OPFS program restore after reload",
|
||||
);
|
||||
await getAppFrameSimulator(restoredAppFrame, "restored app frame did not create OPFS simulator workspace");
|
||||
parseAppFrameProgram(
|
||||
restoredAppFrame,
|
||||
"G21 G90\nF100\nO10 if [#5161 EQ 1]\nG1 X12\nO10 endif\nM30\n",
|
||||
);
|
||||
await waitForAppAlarm(
|
||||
restoredAppFrame,
|
||||
"OK ",
|
||||
"restored app frame did not parse program with reloaded parameter state",
|
||||
);
|
||||
await waitFor(
|
||||
() => restoredAppFrame.contentDocument?.querySelector("#axisX")?.value === "12.000",
|
||||
"app frame did not reload LinuxCNC parameter state from OPFS after reload",
|
||||
);
|
||||
} finally {
|
||||
await disposeAppFrame(restoredAppFrame);
|
||||
}
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user