137 lines
4.9 KiB
HTML
137 lines
4.9 KiB
HTML
<!doctype html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<title>LinuxCNC INI Launch Smoke</title>
|
|
</head>
|
|
<body>
|
|
<pre id="status">running</pre>
|
|
<script type="module">
|
|
import {
|
|
createControlPageBrowserApiMethods,
|
|
createIniPanelLaunchApiManifest,
|
|
createIniPanelLauncherLinkViewModel,
|
|
createIniPanelShellViewModel,
|
|
getIniPanelEntryByHref,
|
|
getVisibleIniPanelEntries,
|
|
} from "../../runtime/ui/ini-panel/ui-shell.js";
|
|
|
|
function assertEqual(actual, expected, label) {
|
|
if (actual !== expected) {
|
|
throw new Error(`${label}: expected ${expected}, got ${actual}`);
|
|
}
|
|
}
|
|
|
|
async function loadLaunchFrame() {
|
|
const frame = document.createElement("iframe");
|
|
frame.src = "../../runtime/ui/ini-panel/launch.html";
|
|
document.body.appendChild(frame);
|
|
await new Promise((resolve, reject) => {
|
|
frame.addEventListener("load", resolve, { once: true });
|
|
frame.addEventListener("error", reject, { once: true });
|
|
});
|
|
return frame.contentDocument;
|
|
}
|
|
|
|
try {
|
|
const visibleEntries = getVisibleIniPanelEntries();
|
|
assertEqual(visibleEntries.length, 2, "launch visible entry length");
|
|
const launcherLinks = createIniPanelLauncherLinkViewModel();
|
|
assertEqual(launcherLinks.length, 2, "launcher link model length");
|
|
assertEqual(launcherLinks[0].entryId, "edit-run", "launcher link entry id");
|
|
assertEqual(launcherLinks[0].label, "Open edit and run panel", "launcher link label");
|
|
assertEqual(launcherLinks[0].href, "./index.html", "launcher link href");
|
|
assertEqual(getIniPanelEntryByHref("./index.html").id, "edit-run", "launch manifest edit entry");
|
|
assertEqual(
|
|
getIniPanelEntryByHref("./control-page.html").title,
|
|
"Open read-only control view",
|
|
"launch manifest control entry",
|
|
);
|
|
assertEqual(
|
|
createIniPanelShellViewModel().controlPage.browserApiMethods.join(","),
|
|
createControlPageBrowserApiMethods().join(","),
|
|
"launch shell control-page browser API methods",
|
|
);
|
|
assertEqual(
|
|
createIniPanelShellViewModel().launchApiManifest.apiName,
|
|
"ini-panel-launch",
|
|
"launch shell API manifest name",
|
|
);
|
|
assertEqual(
|
|
createIniPanelShellViewModel().launchApiManifest.methods.join(","),
|
|
createIniPanelLaunchApiManifest().methods.join(","),
|
|
"launch shell API manifest methods",
|
|
);
|
|
|
|
const launchDoc = await loadLaunchFrame();
|
|
const launchApi = launchDoc.defaultView.linuxCncIniPanelLaunchApi;
|
|
if (!launchApi?.getLaunchApiManifest || !launchApi?.getLauncherLinks || !launchApi?.getControlPageApiMethods) {
|
|
throw new Error("launch API namespace did not expose shell helpers");
|
|
}
|
|
const launchApiManifest = launchApi.getLaunchApiManifest();
|
|
assertEqual(
|
|
launchApiManifest.apiName,
|
|
"ini-panel-launch",
|
|
"launch API manifest name",
|
|
);
|
|
assertEqual(
|
|
launchApiManifest.methods.join(","),
|
|
"getLaunchApiManifest,getLauncherLinks,getControlPageApiMethods",
|
|
"launch API manifest methods",
|
|
);
|
|
assertEqual(
|
|
launchApiManifest.visibleEntries.length,
|
|
2,
|
|
"launch API manifest visible entry count",
|
|
);
|
|
assertEqual(
|
|
launchApiManifest.targetPages[1].href,
|
|
"./control-page.html",
|
|
"launch API manifest control target",
|
|
);
|
|
assertEqual(
|
|
launchApiManifest.persistenceCapabilities.length,
|
|
3,
|
|
"launch API manifest persistence capability count",
|
|
);
|
|
assertEqual(
|
|
launchApiManifest.persistenceCapabilities.map((capability) => capability.id).join(","),
|
|
"machine-files,session-snapshot,readonly-status",
|
|
"launch API manifest persistence capability ids",
|
|
);
|
|
assertEqual(
|
|
launchApiManifest.persistenceCapabilities[2].scope,
|
|
"control-page",
|
|
"launch API manifest readonly status scope",
|
|
);
|
|
assertEqual(
|
|
launchDoc.querySelector('a[href="./index.html"]').textContent,
|
|
"Open edit and run panel",
|
|
"launch panel edit link",
|
|
);
|
|
assertEqual(
|
|
launchDoc.querySelector('a[href="./control-page.html"]').textContent,
|
|
"Open read-only control view",
|
|
"launch panel control link",
|
|
);
|
|
assertEqual(
|
|
launchApi.getLauncherLinks().length,
|
|
2,
|
|
"launch API launcher link count",
|
|
);
|
|
assertEqual(
|
|
launchApi.getControlPageApiMethods().join(","),
|
|
createControlPageBrowserApiMethods().join(","),
|
|
"launch API control-page browser methods",
|
|
);
|
|
status.textContent = "browser_ini_launch_smoke=ok";
|
|
console.log("browser_ini_launch_smoke=ok");
|
|
} catch (error) {
|
|
status.textContent = `browser_ini_launch_smoke=failed: ${error.message}`;
|
|
console.error(error);
|
|
throw error;
|
|
}
|
|
</script>
|
|
</body>
|
|
</html>
|