推进 INI 面板 launcher link view-model helper
This commit is contained in:
@@ -5,7 +5,8 @@ import { dirname, resolve } from "node:path";
|
||||
|
||||
import {
|
||||
INI_PANEL_ENTRIES,
|
||||
getIniPanelEntryManifest,
|
||||
createIniPanelLauncherLinkViewModel,
|
||||
getVisibleIniPanelEntries,
|
||||
} from "../../../runtime/ui/ini-panel/ui-shell.js";
|
||||
|
||||
const __dirname = dirname(fileURLToPath(import.meta.url));
|
||||
@@ -15,8 +16,9 @@ const shellText = readFileSync(resolve(root, "runtime/ui/ini-panel/ui-shell.js")
|
||||
|
||||
const requiredShellExports = [
|
||||
"INI_PANEL_ENTRIES",
|
||||
"createIniPanelLauncherLinkViewModel",
|
||||
"getIniPanelEntryByHref",
|
||||
"getIniPanelEntryManifest",
|
||||
"getVisibleIniPanelEntries",
|
||||
"createMachineSessionControlPageController",
|
||||
"renderMachineSessionControlView",
|
||||
];
|
||||
@@ -36,7 +38,15 @@ for (const [label, path] of requiredPages) {
|
||||
assert.match(docText, new RegExp(`\\| ${label} \\| \`${path.replaceAll("/", "\\/")}\``));
|
||||
}
|
||||
|
||||
assert.deepEqual(getIniPanelEntryManifest(), INI_PANEL_ENTRIES);
|
||||
assert.deepEqual(getVisibleIniPanelEntries(), INI_PANEL_ENTRIES);
|
||||
assert.deepEqual(
|
||||
createIniPanelLauncherLinkViewModel(),
|
||||
INI_PANEL_ENTRIES.map(({ id, href, title }) => ({
|
||||
entryId: id,
|
||||
href,
|
||||
label: title,
|
||||
})),
|
||||
);
|
||||
|
||||
for (const entry of INI_PANEL_ENTRIES) {
|
||||
const escapedHref = entry.href.replace(".", "\\.");
|
||||
|
||||
@@ -2,13 +2,16 @@ import assert from "node:assert/strict";
|
||||
|
||||
import {
|
||||
INI_PANEL_ENTRIES,
|
||||
createIniPanelLauncherLinkViewModel,
|
||||
createMachineSessionControlPageController,
|
||||
getIniPanelEntryByHref,
|
||||
getIniPanelEntryManifest,
|
||||
getVisibleIniPanelEntries,
|
||||
renderMachineSessionControlView,
|
||||
} from "../../../runtime/ui/ini-panel/ui-shell.js";
|
||||
|
||||
assert.deepEqual(getIniPanelEntryManifest(), INI_PANEL_ENTRIES);
|
||||
assert.deepEqual(getVisibleIniPanelEntries(), INI_PANEL_ENTRIES);
|
||||
assert.equal(getIniPanelEntryByHref("./index.html")?.id, "edit-run");
|
||||
assert.equal(typeof createMachineSessionControlPageController, "function");
|
||||
assert.equal(typeof renderMachineSessionControlView, "function");
|
||||
@@ -16,6 +19,24 @@ assert.equal(typeof renderMachineSessionControlView, "function");
|
||||
const shellManifest = getIniPanelEntryManifest();
|
||||
shellManifest[0].title = "changed";
|
||||
assert.equal(INI_PANEL_ENTRIES[0].title, "Open edit and run panel");
|
||||
const visibleEntries = getVisibleIniPanelEntries();
|
||||
visibleEntries[0].title = "changed";
|
||||
assert.equal(INI_PANEL_ENTRIES[0].title, "Open edit and run panel");
|
||||
assert.deepEqual(createIniPanelLauncherLinkViewModel(), [
|
||||
{
|
||||
entryId: "edit-run",
|
||||
href: "./index.html",
|
||||
label: "Open edit and run panel",
|
||||
},
|
||||
{
|
||||
entryId: "control-view",
|
||||
href: "./control-page.html",
|
||||
label: "Open read-only control view",
|
||||
},
|
||||
]);
|
||||
const launcherLinks = createIniPanelLauncherLinkViewModel();
|
||||
launcherLinks[0].label = "changed";
|
||||
assert.equal(INI_PANEL_ENTRIES[0].title, "Open edit and run panel");
|
||||
|
||||
const panelFrame = {
|
||||
contentWindow: {
|
||||
|
||||
Reference in New Issue
Block a user