推进 INI 面板 launch API manifest
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
<script type="module">
|
||||
import {
|
||||
createControlPageBrowserApiMethods,
|
||||
createIniPanelLaunchApiManifest,
|
||||
createIniPanelLauncherLinkViewModel,
|
||||
createIniPanelShellViewModel,
|
||||
getIniPanelEntryByHref,
|
||||
@@ -51,12 +52,43 @@
|
||||
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?.getLauncherLinks || !launchApi?.getControlPageApiMethods) {
|
||||
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(
|
||||
launchDoc.querySelector('a[href="./index.html"]').textContent,
|
||||
"Open edit and run panel",
|
||||
|
||||
@@ -8,6 +8,7 @@ import {
|
||||
controlPageStatusText,
|
||||
createControlPageSessionLoadState,
|
||||
createControlPageBrowserApiMethods,
|
||||
createIniPanelLaunchApiManifest,
|
||||
createIniPanelLauncherLinkViewModel,
|
||||
createIniPanelShellControlPageContract,
|
||||
createIniPanelShellViewModel,
|
||||
@@ -39,6 +40,7 @@ const requiredShellExports = [
|
||||
"controlPageStatusText",
|
||||
"createControlPageBrowserApiMethods",
|
||||
"createControlPageSessionLoadState",
|
||||
"createIniPanelLaunchApiManifest",
|
||||
"createIniPanelLauncherLinkViewModel",
|
||||
"createIniPanelShellControlPageContract",
|
||||
"createIniPanelShellViewModel",
|
||||
@@ -96,6 +98,7 @@ assert.deepEqual(
|
||||
);
|
||||
assert.deepEqual(createIniPanelShellViewModel().pages, getVisibleIniPanelEntries());
|
||||
assert.deepEqual(createIniPanelShellViewModel().launcherLinks, createIniPanelLauncherLinkViewModel());
|
||||
assert.deepEqual(createIniPanelShellViewModel().launchApiManifest, createIniPanelLaunchApiManifest());
|
||||
assert.deepEqual(
|
||||
createIniPanelShellViewModel().controlPage.contract,
|
||||
createIniPanelShellControlPageContract(),
|
||||
@@ -128,8 +131,10 @@ assert.equal(createIniPanelShellViewModel().controlPage.readStatus, readMachineS
|
||||
assert.equal(createIniPanelShellViewModel().controlPage.refresh, refreshMachineSessionControlPage);
|
||||
assert.equal(typeof createIniPanelShellViewModel().controlPage.renderView, "function");
|
||||
assert.match(shellText, /\bexport function createControlPageBrowserApiMethods\b/);
|
||||
assert.match(shellText, /\bexport function createIniPanelLaunchApiManifest\b/);
|
||||
assert.match(controlPageText, /\bgetControlPageApiMethods\b/);
|
||||
assert.match(launchText, /\blinuxCncIniPanelLaunchApi\b/);
|
||||
assert.match(launchText, /\bgetLaunchApiManifest\b/);
|
||||
assert.match(launchText, /\bgetControlPageApiMethods\b/);
|
||||
assert.match(controlPageText, /\bgetControlPageContract\b/);
|
||||
assert.match(controlPageText, /\breadControlPageStatus\b/);
|
||||
@@ -137,6 +142,8 @@ assert.match(controlPageText, /\bcreateIniPanelShellControlPageContract\b/);
|
||||
assert.match(docText, /\blinuxCncIniPanelControlPageApi\.getControlPageApiMethods\b/);
|
||||
assert.match(docText, /\blinuxCncIniPanelControlPageApi\.getControlPageContract\b/);
|
||||
assert.match(docText, /\blinuxCncIniPanelControlPageApi\.readControlPageStatus\b/);
|
||||
assert.match(docText, /\bcreateIniPanelLaunchApiManifest\b/);
|
||||
assert.match(docText, /\blinuxCncIniPanelLaunchApi\.getLaunchApiManifest\b/);
|
||||
assert.match(docText, /\blinuxCncIniPanelLaunchApi\.getControlPageApiMethods\b/);
|
||||
|
||||
for (const entry of INI_PANEL_ENTRIES) {
|
||||
|
||||
@@ -5,6 +5,7 @@ import { fileURLToPath } from "node:url";
|
||||
|
||||
import {
|
||||
createControlPageBrowserApiMethods,
|
||||
createIniPanelLaunchApiManifest,
|
||||
createIniPanelShellControlPageContract,
|
||||
createIniPanelShellViewModel,
|
||||
createMachineSessionControlPageController,
|
||||
@@ -55,6 +56,7 @@ assert.deepEqual(contract, {
|
||||
});
|
||||
|
||||
const shellViewModel = createIniPanelShellViewModel();
|
||||
assert.deepEqual(shellViewModel.launchApiManifest, createIniPanelLaunchApiManifest());
|
||||
assert.deepEqual(Object.keys(shellViewModel.controlPage), [
|
||||
"browserApiMethods",
|
||||
"contract",
|
||||
|
||||
@@ -4,6 +4,7 @@ import {
|
||||
INI_PANEL_ENTRIES,
|
||||
controlPageStatusText,
|
||||
createControlPageBrowserApiMethods,
|
||||
createIniPanelLaunchApiManifest,
|
||||
createIniPanelLauncherLinkViewModel,
|
||||
createIniPanelShellControlPageContract,
|
||||
createIniPanelShellViewModel,
|
||||
@@ -46,6 +47,7 @@ assert.equal(typeof createMachineSessionControlPageController, "function");
|
||||
assert.equal(typeof createMachineSessionReadonlyStatus, "function");
|
||||
assert.equal(typeof createMachineSessionReadonlyStatusApiManifest, "function");
|
||||
assert.equal(typeof createControlPageBrowserApiMethods, "function");
|
||||
assert.equal(typeof createIniPanelLaunchApiManifest, "function");
|
||||
assert.equal(typeof createIniPanelShellControlPageContract, "function");
|
||||
assert.equal(typeof loadMachineSessionForControlPageWorkflow, "function");
|
||||
assert.equal(typeof readMachineSessionReadonlyStatus, "function");
|
||||
@@ -87,6 +89,7 @@ assert.deepEqual(shellViewModel.pages, [
|
||||
},
|
||||
]);
|
||||
assert.deepEqual(shellViewModel.launcherLinks, createIniPanelLauncherLinkViewModel());
|
||||
assert.deepEqual(shellViewModel.launchApiManifest, createIniPanelLaunchApiManifest());
|
||||
assert.deepEqual(shellViewModel.controlPage.browserApiMethods, createControlPageBrowserApiMethods());
|
||||
assert.equal(shellViewModel.controlPage.createController, createMachineSessionControlPageController);
|
||||
assert.deepEqual(shellViewModel.controlPage.contract, createIniPanelShellControlPageContract());
|
||||
|
||||
Reference in New Issue
Block a user