639 lines
33 KiB
TypeScript
639 lines
33 KiB
TypeScript
#!/usr/bin/env tsx
|
|
import assert from "node:assert/strict";
|
|
import { mkdtemp, rm, writeFile } from "node:fs/promises";
|
|
import os from "node:os";
|
|
import path from "node:path";
|
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
import { createElement } from "react";
|
|
import { renderToStaticMarkup } from "react-dom/server";
|
|
|
|
import { AppShell } from "@hivegrid/ui-app";
|
|
import {
|
|
createAutomationEditorFixturePage,
|
|
createChatDetailInterimFixturePage,
|
|
createChatIndexInterimFixturePage,
|
|
createCrmInterimFixturePage,
|
|
createLeadInterimFixturePage,
|
|
createProjektBoardInterimFixturePage,
|
|
createProjektOperationsInterimFixturePage,
|
|
createDashboardInterimFixturePage,
|
|
createHotSwapDrillPage,
|
|
createHrCoreInterimFixturePage,
|
|
createHrWorkflowsInterimFixturePage,
|
|
createMockPage,
|
|
createMockRegistry,
|
|
createP20InterimFixturePage,
|
|
createP21InterimFixturePage,
|
|
createSpotlightInterimFixturePage,
|
|
createTelephonyInterimFixturePage,
|
|
createVaP24aInterimFixturePage,
|
|
createVaP26aInterimFixturePage,
|
|
createVaP26bInterimFixturePages,
|
|
createVaP26cInterimFixturePage,
|
|
generateHotSwapMock,
|
|
generateMockPageHtml,
|
|
type P20InterimViewModels,
|
|
type P21InterimViewModels,
|
|
} from "@hivegrid/ui-mock";
|
|
|
|
export async function verifyUiHotSwap() {
|
|
const page = createHotSwapDrillPage();
|
|
const p20InterimPage = createP20InterimFixturePage({
|
|
subscription: { status: "empty" },
|
|
usage: { status: "empty" },
|
|
billing: { status: "empty" },
|
|
demoData: { status: "empty" },
|
|
checklist: { status: "empty" },
|
|
} satisfies P20InterimViewModels);
|
|
// AK-P21 (AD-28) — the five privacy screens must survive the ui-mock swap.
|
|
const p21InterimPage = createP21InterimFixturePage({
|
|
hub: { status: "empty" },
|
|
exportJobs: { status: "empty" },
|
|
deletion: { status: "empty" },
|
|
subprocessors: { status: "empty" },
|
|
avv: { status: "empty" },
|
|
} satisfies P21InterimViewModels);
|
|
const vaP24aInterimPage = createVaP24aInterimFixturePage();
|
|
const vaP26aInterimPage = createVaP26aInterimFixturePage();
|
|
const vaP26bInterimPages = createVaP26bInterimFixturePages();
|
|
const vaP26bInterimPage = vaP26bInterimPages[0];
|
|
assert.ok(vaP26bInterimPage);
|
|
const vaP26cInterimPage = createVaP26cInterimFixturePage();
|
|
const replacementPage = createMockPage({
|
|
...page,
|
|
id: "phase-c-hot-swap-replacement",
|
|
titleKey: "mock.phase-c.hot-swap.replacement.title",
|
|
state: {
|
|
status: "ready",
|
|
data: {
|
|
cards: [
|
|
{ labelKey: "mock.phase-c.hot-swap.metrics.modules", value: "4", trend: "up" },
|
|
{ labelKey: "mock.phase-c.hot-swap.metrics.swap", value: "active", trend: "flat" },
|
|
],
|
|
activity: [{ labelKey: "mock.phase-c.hot-swap.activity.registrySwap", meta: "replacement" }],
|
|
},
|
|
},
|
|
registries: {
|
|
...page.registries,
|
|
sidebar: [...(page.registries?.sidebar ?? []), { id: "phase-c-replacement", href: page.route, labelKey: "mock.phase-c.hot-swap.replacement.label" }],
|
|
breadcrumbs: [...(page.registries?.breadcrumbs ?? []), { id: "replacement", href: page.route, labelKey: "mock.phase-c.hot-swap.replacement.label" }],
|
|
},
|
|
});
|
|
const dashboardPage = createDashboardInterimFixturePage();
|
|
const spotlightInterimPage = createSpotlightInterimFixturePage();
|
|
const crmInterimPage = createCrmInterimFixturePage();
|
|
const leadInterimPage = createLeadInterimFixturePage();
|
|
const projektBoardInterimPage = createProjektBoardInterimFixturePage();
|
|
const projektOperationsInterimPage = createProjektOperationsInterimFixturePage();
|
|
const telephonyInterimPage = createTelephonyInterimFixturePage();
|
|
const chatIndexInterimPage = createChatIndexInterimFixturePage();
|
|
const chatDetailInterimPage = createChatDetailInterimFixturePage();
|
|
const automationEditorPage = createAutomationEditorFixturePage();
|
|
const hrCoreInterimPage = createHrCoreInterimFixturePage();
|
|
const hrWorkflowsInterimPage = createHrWorkflowsInterimFixturePage();
|
|
const registry = createMockRegistry([
|
|
page,
|
|
automationEditorPage,
|
|
replacementPage,
|
|
dashboardPage,
|
|
spotlightInterimPage,
|
|
crmInterimPage,
|
|
leadInterimPage,
|
|
projektBoardInterimPage,
|
|
projektOperationsInterimPage,
|
|
p20InterimPage,
|
|
p21InterimPage,
|
|
telephonyInterimPage,
|
|
vaP26aInterimPage,
|
|
chatIndexInterimPage,
|
|
chatDetailInterimPage,
|
|
...vaP26bInterimPages,
|
|
vaP26cInterimPage,
|
|
hrCoreInterimPage,
|
|
hrWorkflowsInterimPage,
|
|
]);
|
|
const vaP24aReplacementRegistry = createMockRegistry([p20InterimPage, vaP24aInterimPage]);
|
|
const activePage = registry.get(page.route);
|
|
const activeP20InterimPage = registry.get(p20InterimPage.route);
|
|
const activeP21InterimPage = registry.get(p21InterimPage.route);
|
|
const activeTelephonyInterimPage = registry.get(telephonyInterimPage.route);
|
|
const activeChatIndexInterimPage = registry.get(chatIndexInterimPage.route);
|
|
const activeChatDetailInterimPage = registry.get(chatDetailInterimPage.route);
|
|
const activeVaP24aInterimPage = vaP24aReplacementRegistry.get(vaP24aInterimPage.route);
|
|
const activeVaP26aInterimPage = registry.get(vaP26aInterimPage.route);
|
|
const activeVaP26bInterimPage = registry.get(vaP26bInterimPage.route);
|
|
const activeVaP26cInterimPage = registry.get(vaP26cInterimPage.route);
|
|
const activeCrmInterimPage = registry.get(crmInterimPage.route);
|
|
const activeLeadInterimPage = registry.get(leadInterimPage.route);
|
|
const activeProjektBoardInterimPage = registry.get(projektBoardInterimPage.route);
|
|
|
|
assert.equal(activePage?.id, "phase-c-hot-swap-replacement");
|
|
assert.equal(activeCrmInterimPage?.id, "r-p6-crm-interim");
|
|
assert.equal(activeLeadInterimPage?.id, "r-p7-leads-interim");
|
|
assert.equal(activeProjektBoardInterimPage?.id, "r-p8-projects-interim");
|
|
// R-P9 Plantafel/acceptance interim screens (AD-28): route-addressable in the
|
|
// mock registry and producing module/html artifacts like every drill page.
|
|
const activeProjektOperationsInterimPage = registry.get(projektOperationsInterimPage.route);
|
|
assert.equal(activeProjektOperationsInterimPage?.id, "r-p9-operations-interim");
|
|
assert.equal(activeP20InterimPage?.id, "ak-p20-interim");
|
|
assert.equal(activeP21InterimPage?.id, "ak-p21-interim");
|
|
assert.equal(activeTelephonyInterimPage?.id, "ak-p15a-telephony-interim");
|
|
assert.equal(activeChatIndexInterimPage?.id, "ak-p15b-chat-index-interim");
|
|
assert.equal(activeChatDetailInterimPage?.id, "ak-p15b-chat-detail-interim");
|
|
assert.equal(activeVaP24aInterimPage?.id, "va-p24a-interim");
|
|
assert.equal(activeVaP26aInterimPage?.id, "va-p26a-customer-portal-interim");
|
|
assert.equal(activeVaP26bInterimPage?.id, "va-p26b-customer-portal-interim");
|
|
assert.deepEqual(
|
|
vaP26bInterimPages.map((candidate) => registry.get(candidate.route)?.route),
|
|
vaP26bInterimPages.map((candidate) => candidate.route)
|
|
);
|
|
assert.equal(activeVaP26cInterimPage?.id, "va-p26c-customer-portal-domain-interim");
|
|
|
|
// R-P12b automation flow editor (Subframe-integrated, visual baseline
|
|
// r-p12b-editor): route-addressable in the mock registry and producing
|
|
// module/html artifacts like every drill page (AGENTS.md DoD D.20).
|
|
const activeAutomationEditorPage = registry.get(automationEditorPage.route);
|
|
assert.equal(activeAutomationEditorPage?.id, "r-p12b-editor");
|
|
const automationEditorModule = generateHotSwapMock(automationEditorPage);
|
|
const automationEditorHtml = generateMockPageHtml(automationEditorPage);
|
|
assert.match(automationEditorModule, /r-p12b-editor/);
|
|
const importedAutomationEditorPage = await importGeneratedHotSwapModule(automationEditorModule);
|
|
assert.equal(importedAutomationEditorPage.route, automationEditorPage.route);
|
|
assert.equal(importedAutomationEditorPage.state.status, "ready");
|
|
assert.match(automationEditorHtml, /data-ui-mock-page="r-p12b-editor"/);
|
|
const automationEditorShellHtml = renderToStaticMarkup(
|
|
createElement(
|
|
AppShell,
|
|
{ registries: activeAutomationEditorPage?.registries },
|
|
createElement("main", {
|
|
"data-hot-swap-route": activeAutomationEditorPage?.route,
|
|
"data-hot-swap-status": activeAutomationEditorPage?.state.status,
|
|
"data-hot-swap-page": activeAutomationEditorPage?.id,
|
|
dangerouslySetInnerHTML: { __html: automationEditorHtml },
|
|
})
|
|
)
|
|
);
|
|
assert.match(automationEditorShellHtml, /data-hot-swap-page="r-p12b-editor"/);
|
|
|
|
// AK-P17a HR core interim screens (AD-28): route-addressable in the mock
|
|
// registry and producing module/html artifacts like every drill page. The
|
|
// vault fixture additionally proves the password-safe never-list contract:
|
|
// only presence flags survive into the generated module, never a secret.
|
|
const activeHrCoreInterimPage = registry.get(hrCoreInterimPage.route);
|
|
assert.equal(activeHrCoreInterimPage?.id, "ak-p17a-hr-core-interim");
|
|
const hrCoreInterimModule = generateHotSwapMock(hrCoreInterimPage);
|
|
const hrCoreInterimHtml = generateMockPageHtml(hrCoreInterimPage);
|
|
assert.match(hrCoreInterimModule, /ak-p17a-hr-core-interim/);
|
|
assert.match(hrCoreInterimModule, /"designStatus": "interim"/);
|
|
assert.match(hrCoreInterimModule, /"hasPassword": true/);
|
|
assert.doesNotMatch(hrCoreInterimModule, /"username"|"password":|"notes":/);
|
|
const importedHrCoreInterimPage = await importGeneratedHotSwapModule(hrCoreInterimModule);
|
|
assert.equal(importedHrCoreInterimPage.route, "/:tenant/hr/directory");
|
|
assert.equal(importedHrCoreInterimPage.state.status, "ready");
|
|
assert.match(hrCoreInterimHtml, /data-ui-mock-page="ak-p17a-hr-core-interim"/);
|
|
const hrCoreInterimShellHtml = renderToStaticMarkup(
|
|
createElement(
|
|
AppShell,
|
|
{ registries: activeHrCoreInterimPage?.registries },
|
|
createElement("main", {
|
|
"data-hot-swap-route": activeHrCoreInterimPage?.route,
|
|
"data-hot-swap-status": activeHrCoreInterimPage?.state.status,
|
|
"data-hot-swap-page": activeHrCoreInterimPage?.id,
|
|
dangerouslySetInnerHTML: { __html: hrCoreInterimHtml },
|
|
})
|
|
)
|
|
);
|
|
assert.match(hrCoreInterimShellHtml, /data-hot-swap-page="ak-p17a-hr-core-interim"/);
|
|
|
|
// AK-P17b HR leave workflow interim screen (AD-28): same drill contract.
|
|
const activeHrWorkflowsInterimPage = registry.get(hrWorkflowsInterimPage.route);
|
|
assert.equal(activeHrWorkflowsInterimPage?.id, "ak-p17b-hr-leave-interim");
|
|
const hrWorkflowsInterimModule = generateHotSwapMock(hrWorkflowsInterimPage);
|
|
const hrWorkflowsInterimHtml = generateMockPageHtml(hrWorkflowsInterimPage);
|
|
assert.match(hrWorkflowsInterimModule, /ak-p17b-hr-leave-interim/);
|
|
assert.match(hrWorkflowsInterimModule, /"designStatus": "interim"/);
|
|
assert.match(hrWorkflowsInterimModule, /"hasConflict": true/);
|
|
const importedHrWorkflowsInterimPage = await importGeneratedHotSwapModule(hrWorkflowsInterimModule);
|
|
assert.equal(importedHrWorkflowsInterimPage.route, "/:tenant/hr/leave");
|
|
assert.equal(importedHrWorkflowsInterimPage.state.status, "ready");
|
|
assert.match(hrWorkflowsInterimHtml, /data-ui-mock-page="ak-p17b-hr-leave-interim"/);
|
|
const hrWorkflowsInterimShellHtml = renderToStaticMarkup(
|
|
createElement(
|
|
AppShell,
|
|
{ registries: activeHrWorkflowsInterimPage?.registries },
|
|
createElement("main", {
|
|
"data-hot-swap-route": activeHrWorkflowsInterimPage?.route,
|
|
"data-hot-swap-status": activeHrWorkflowsInterimPage?.state.status,
|
|
"data-hot-swap-page": activeHrWorkflowsInterimPage?.id,
|
|
dangerouslySetInnerHTML: { __html: hrWorkflowsInterimHtml },
|
|
})
|
|
)
|
|
);
|
|
assert.match(hrWorkflowsInterimShellHtml, /data-hot-swap-page="ak-p17b-hr-leave-interim"/);
|
|
|
|
// R-P11b dashboard interim screen (AD-28): the fixture page is route-addressable
|
|
// in the mock registry and produces module/html artifacts like every drill page.
|
|
assert.equal(registry.get(dashboardPage.route)?.id, "r-p11b-dashboard-interim");
|
|
const dashboardModule = generateHotSwapMock(dashboardPage);
|
|
const dashboardHtml = generateMockPageHtml(dashboardPage);
|
|
assert.match(dashboardModule, /r-p11b-dashboard-interim/);
|
|
const importedDashboardPage = await importGeneratedHotSwapModule(dashboardModule);
|
|
assert.equal(importedDashboardPage.route, "/mock/r-p11b/dashboard");
|
|
assert.equal(importedDashboardPage.state.status, "ready");
|
|
assert.match(dashboardHtml, /data-ui-mock-route="\/mock\/r-p11b\/dashboard"/);
|
|
|
|
// R-P11a Spotlight interim screen (AD-28): the fixture swaps in as global
|
|
// chrome via the shell.commandPalette portal slot (no sidebar entry, no
|
|
// user-facing route) and produces module/html artifacts like every drill page.
|
|
const activeSpotlightInterimPage = registry.get(spotlightInterimPage.route);
|
|
assert.equal(activeSpotlightInterimPage?.id, "r-p11a-spotlight-interim");
|
|
const spotlightInterimModule = generateHotSwapMock(spotlightInterimPage);
|
|
const spotlightInterimHtml = generateMockPageHtml(spotlightInterimPage);
|
|
assert.match(spotlightInterimModule, /r-p11a-spotlight-interim/);
|
|
assert.match(spotlightInterimModule, /"designStatus": "interim"/);
|
|
assert.match(spotlightInterimModule, /"slot": "shell.commandPalette"/);
|
|
assert.match(spotlightInterimModule, /"permission": "search.use"/);
|
|
const importedSpotlightInterimPage = await importGeneratedHotSwapModule(spotlightInterimModule);
|
|
assert.equal(importedSpotlightInterimPage.route, "/mock/r-p11a/spotlight");
|
|
assert.equal(importedSpotlightInterimPage.state.status, "ready");
|
|
assert.match(spotlightInterimHtml, /data-ui-mock-route="\/mock\/r-p11a\/spotlight"/);
|
|
const spotlightInterimShellHtml = renderToStaticMarkup(
|
|
createElement(
|
|
AppShell,
|
|
{ registries: activeSpotlightInterimPage?.registries },
|
|
createElement("main", {
|
|
"data-hot-swap-route": activeSpotlightInterimPage?.route,
|
|
"data-hot-swap-status": activeSpotlightInterimPage?.state.status,
|
|
"data-hot-swap-page": activeSpotlightInterimPage?.id,
|
|
dangerouslySetInnerHTML: { __html: spotlightInterimHtml },
|
|
})
|
|
)
|
|
);
|
|
assert.match(spotlightInterimShellHtml, /data-portal-count="1"/);
|
|
assert.match(spotlightInterimShellHtml, /data-hot-swap-page="r-p11a-spotlight-interim"/);
|
|
|
|
const mockModule = generateHotSwapMock(page);
|
|
const mockHtml = generateMockPageHtml(page);
|
|
const replacementHtml = generateMockPageHtml(replacementPage);
|
|
const p20InterimModule = generateHotSwapMock(p20InterimPage);
|
|
const p20InterimHtml = generateMockPageHtml(p20InterimPage);
|
|
const p21InterimModule = generateHotSwapMock(p21InterimPage);
|
|
const p21InterimHtml = generateMockPageHtml(p21InterimPage);
|
|
const crmInterimModule = generateHotSwapMock(crmInterimPage);
|
|
const crmInterimHtml = generateMockPageHtml(crmInterimPage);
|
|
const leadInterimModule = generateHotSwapMock(leadInterimPage);
|
|
const leadInterimHtml = generateMockPageHtml(leadInterimPage);
|
|
const projektBoardInterimModule = generateHotSwapMock(projektBoardInterimPage);
|
|
const projektBoardInterimHtml = generateMockPageHtml(projektBoardInterimPage);
|
|
const projektOperationsInterimModule = generateHotSwapMock(projektOperationsInterimPage);
|
|
const projektOperationsInterimHtml = generateMockPageHtml(projektOperationsInterimPage);
|
|
assert.match(projektOperationsInterimModule, /r-p9-operations-interim/);
|
|
assert.match(projektOperationsInterimModule, /"designStatus": "interim"/);
|
|
assert.match(projektOperationsInterimHtml, /data-ui-mock-route="\/:tenant\/projects\/plantafel"/);
|
|
const telephonyInterimModule = generateHotSwapMock(telephonyInterimPage);
|
|
const telephonyInterimHtml = generateMockPageHtml(telephonyInterimPage);
|
|
const chatIndexInterimModule = generateHotSwapMock(chatIndexInterimPage);
|
|
const chatIndexInterimHtml = generateMockPageHtml(chatIndexInterimPage);
|
|
const chatDetailInterimModule = generateHotSwapMock(chatDetailInterimPage);
|
|
const chatDetailInterimHtml = generateMockPageHtml(chatDetailInterimPage);
|
|
const vaP24aInterimModule = generateHotSwapMock(vaP24aInterimPage);
|
|
const vaP24aInterimHtml = generateMockPageHtml(vaP24aInterimPage);
|
|
const vaP26aInterimModule = generateHotSwapMock(vaP26aInterimPage);
|
|
const vaP26aInterimHtml = generateMockPageHtml(vaP26aInterimPage);
|
|
const vaP26bInterimModule = generateHotSwapMock(vaP26bInterimPage);
|
|
const vaP26bInterimHtml = generateMockPageHtml(vaP26bInterimPage);
|
|
const vaP26cInterimModule = generateHotSwapMock(vaP26cInterimPage);
|
|
const vaP26cInterimHtml = generateMockPageHtml(vaP26cInterimPage);
|
|
const shellHtml = renderToStaticMarkup(
|
|
createElement(
|
|
AppShell,
|
|
{ registries: activePage?.registries },
|
|
createElement("main", {
|
|
"data-hot-swap-route": activePage?.route,
|
|
"data-hot-swap-status": activePage?.state.status,
|
|
"data-hot-swap-page": activePage?.id,
|
|
dangerouslySetInnerHTML: { __html: replacementHtml },
|
|
})
|
|
)
|
|
);
|
|
const p20InterimShellHtml = renderToStaticMarkup(
|
|
createElement(
|
|
AppShell,
|
|
{ registries: activeP20InterimPage?.registries },
|
|
createElement("main", {
|
|
"data-hot-swap-route": activeP20InterimPage?.route,
|
|
"data-hot-swap-status": activeP20InterimPage?.state.status,
|
|
"data-hot-swap-page": activeP20InterimPage?.id,
|
|
dangerouslySetInnerHTML: { __html: p20InterimHtml },
|
|
})
|
|
)
|
|
);
|
|
const p21InterimShellHtml = renderToStaticMarkup(
|
|
createElement(
|
|
AppShell,
|
|
{ registries: activeP21InterimPage?.registries },
|
|
createElement("main", {
|
|
"data-hot-swap-route": activeP21InterimPage?.route,
|
|
"data-hot-swap-status": activeP21InterimPage?.state.status,
|
|
"data-hot-swap-page": activeP21InterimPage?.id,
|
|
dangerouslySetInnerHTML: { __html: p21InterimHtml },
|
|
})
|
|
)
|
|
);
|
|
const crmInterimShellHtml = renderToStaticMarkup(
|
|
createElement(
|
|
AppShell,
|
|
{ registries: activeCrmInterimPage?.registries },
|
|
createElement("main", {
|
|
"data-hot-swap-route": activeCrmInterimPage?.route,
|
|
"data-hot-swap-status": activeCrmInterimPage?.state.status,
|
|
"data-hot-swap-page": activeCrmInterimPage?.id,
|
|
dangerouslySetInnerHTML: { __html: crmInterimHtml },
|
|
})
|
|
)
|
|
);
|
|
const leadInterimShellHtml = renderToStaticMarkup(
|
|
createElement(
|
|
AppShell,
|
|
{ registries: activeLeadInterimPage?.registries },
|
|
createElement("main", {
|
|
"data-hot-swap-route": activeLeadInterimPage?.route,
|
|
"data-hot-swap-status": activeLeadInterimPage?.state.status,
|
|
"data-hot-swap-page": activeLeadInterimPage?.id,
|
|
dangerouslySetInnerHTML: { __html: leadInterimHtml },
|
|
})
|
|
)
|
|
);
|
|
const projektBoardInterimShellHtml = renderToStaticMarkup(
|
|
createElement(
|
|
AppShell,
|
|
{ registries: activeProjektBoardInterimPage?.registries },
|
|
createElement("main", {
|
|
"data-hot-swap-route": activeProjektBoardInterimPage?.route,
|
|
"data-hot-swap-status": activeProjektBoardInterimPage?.state.status,
|
|
"data-hot-swap-page": activeProjektBoardInterimPage?.id,
|
|
dangerouslySetInnerHTML: { __html: projektBoardInterimHtml },
|
|
})
|
|
)
|
|
);
|
|
const telephonyInterimShellHtml = renderToStaticMarkup(
|
|
createElement(
|
|
AppShell,
|
|
{ registries: activeTelephonyInterimPage?.registries },
|
|
createElement("main", {
|
|
"data-hot-swap-route": activeTelephonyInterimPage?.route,
|
|
"data-hot-swap-status": activeTelephonyInterimPage?.state.status,
|
|
"data-hot-swap-page": activeTelephonyInterimPage?.id,
|
|
dangerouslySetInnerHTML: { __html: telephonyInterimHtml },
|
|
})
|
|
)
|
|
);
|
|
const chatIndexInterimShellHtml = renderToStaticMarkup(
|
|
createElement(
|
|
AppShell,
|
|
{ registries: activeChatIndexInterimPage?.registries },
|
|
createElement("main", {
|
|
"data-hot-swap-route": activeChatIndexInterimPage?.route,
|
|
"data-hot-swap-status": activeChatIndexInterimPage?.state.status,
|
|
"data-hot-swap-page": activeChatIndexInterimPage?.id,
|
|
dangerouslySetInnerHTML: { __html: chatIndexInterimHtml },
|
|
})
|
|
)
|
|
);
|
|
const chatDetailInterimShellHtml = renderToStaticMarkup(
|
|
createElement(
|
|
AppShell,
|
|
{ registries: activeChatDetailInterimPage?.registries },
|
|
createElement("main", {
|
|
"data-hot-swap-route": activeChatDetailInterimPage?.route,
|
|
"data-hot-swap-status": activeChatDetailInterimPage?.state.status,
|
|
"data-hot-swap-page": activeChatDetailInterimPage?.id,
|
|
dangerouslySetInnerHTML: { __html: chatDetailInterimHtml },
|
|
})
|
|
)
|
|
);
|
|
const vaP24aInterimShellHtml = renderToStaticMarkup(
|
|
createElement(
|
|
AppShell,
|
|
{ registries: activeVaP24aInterimPage?.registries },
|
|
createElement("main", {
|
|
"data-hot-swap-route": activeVaP24aInterimPage?.route,
|
|
"data-hot-swap-status": activeVaP24aInterimPage?.state.status,
|
|
"data-hot-swap-page": activeVaP24aInterimPage?.id,
|
|
dangerouslySetInnerHTML: { __html: vaP24aInterimHtml },
|
|
})
|
|
)
|
|
);
|
|
const vaP26aInterimShellHtml = renderToStaticMarkup(
|
|
createElement(
|
|
AppShell,
|
|
{ registries: activeVaP26aInterimPage?.registries },
|
|
createElement("main", {
|
|
"data-hot-swap-route": activeVaP26aInterimPage?.route,
|
|
"data-hot-swap-status": activeVaP26aInterimPage?.state.status,
|
|
"data-hot-swap-page": activeVaP26aInterimPage?.id,
|
|
dangerouslySetInnerHTML: { __html: vaP26aInterimHtml },
|
|
})
|
|
)
|
|
);
|
|
const vaP26bInterimShellHtml = renderToStaticMarkup(
|
|
createElement(
|
|
AppShell,
|
|
{ registries: activeVaP26bInterimPage?.registries },
|
|
createElement("main", {
|
|
"data-hot-swap-route": activeVaP26bInterimPage?.route,
|
|
"data-hot-swap-status": activeVaP26bInterimPage?.state.status,
|
|
"data-hot-swap-page": activeVaP26bInterimPage?.id,
|
|
dangerouslySetInnerHTML: { __html: vaP26bInterimHtml },
|
|
})
|
|
)
|
|
);
|
|
const vaP26cInterimShellHtml = renderToStaticMarkup(
|
|
createElement(
|
|
AppShell,
|
|
{ registries: activeVaP26cInterimPage?.registries },
|
|
createElement("main", {
|
|
"data-hot-swap-route": activeVaP26cInterimPage?.route,
|
|
"data-hot-swap-status": activeVaP26cInterimPage?.state.status,
|
|
"data-hot-swap-page": activeVaP26cInterimPage?.id,
|
|
dangerouslySetInnerHTML: { __html: vaP26cInterimHtml },
|
|
})
|
|
)
|
|
);
|
|
|
|
assert.match(mockModule, /export const mockPage =/);
|
|
assert.match(mockModule, /phase-c-hot-swap/);
|
|
const importedMockPage = await importGeneratedHotSwapModule(mockModule);
|
|
assert.equal(importedMockPage.id, "phase-c-hot-swap");
|
|
assert.equal(importedMockPage.route, "/mock/phase-c/hot-swap");
|
|
assert.equal(importedMockPage.state.status, "ready");
|
|
assert.match(mockHtml, /data-ui-mock-route="\/mock\/phase-c\/hot-swap"/);
|
|
assert.match(replacementHtml, /phase-c-hot-swap-replacement/);
|
|
assert.notEqual(replacementHtml, mockHtml);
|
|
assert.match(shellHtml, /data-ui-shell="app"/);
|
|
assert.match(shellHtml, /data-sidebar-count="3"/);
|
|
assert.match(shellHtml, /data-breadcrumb-count="4"/);
|
|
assert.match(shellHtml, /data-mobile-count="1"/);
|
|
assert.match(shellHtml, /data-portal-count="1"/);
|
|
assert.match(shellHtml, /data-hot-swap-route="\/mock\/phase-c\/hot-swap"/);
|
|
assert.match(shellHtml, /data-hot-swap-status="ready"/);
|
|
assert.match(shellHtml, /data-hot-swap-page="phase-c-hot-swap-replacement"/);
|
|
const importedP20InterimPage = await importGeneratedHotSwapModule(p20InterimModule);
|
|
assert.equal(importedP20InterimPage.id, "ak-p20-interim");
|
|
assert.equal(importedP20InterimPage.route, "/:tenant/settings/billing");
|
|
assert.match(p20InterimModule, /"designStatus": "interim"/);
|
|
assert.match(p20InterimHtml, /data-ui-mock-page="ak-p20-interim"/);
|
|
assert.match(p20InterimHtml, /\/:tenant\/settings\/workspace\/demo-data/);
|
|
assert.match(p20InterimShellHtml, /data-sidebar-count="5"/);
|
|
assert.match(p20InterimShellHtml, /data-breadcrumb-count="2"/);
|
|
assert.match(p20InterimShellHtml, /data-hot-swap-page="ak-p20-interim"/);
|
|
const importedP21InterimPage = await importGeneratedHotSwapModule(p21InterimModule);
|
|
assert.equal(importedP21InterimPage.id, "ak-p21-interim");
|
|
assert.equal(importedP21InterimPage.route, "/:tenant/settings/profile/data");
|
|
assert.match(p21InterimModule, /"designStatus": "interim"/);
|
|
assert.match(p21InterimHtml, /data-ui-mock-page="ak-p21-interim"/);
|
|
assert.match(p21InterimHtml, /\/:tenant\/settings\/compliance\/tenant-deletion/);
|
|
assert.match(p21InterimShellHtml, /data-sidebar-count="5"/);
|
|
assert.match(p21InterimShellHtml, /data-breadcrumb-count="2"/);
|
|
assert.match(p21InterimShellHtml, /data-hot-swap-page="ak-p21-interim"/);
|
|
const importedTelephonyInterimPage = await importGeneratedHotSwapModule(telephonyInterimModule);
|
|
assert.equal(importedTelephonyInterimPage.id, "ak-p15a-telephony-interim");
|
|
assert.equal(importedTelephonyInterimPage.route, "/:tenant/calls");
|
|
assert.match(telephonyInterimModule, /"designStatus": "interim"/);
|
|
assert.match(telephonyInterimModule, /"clickToCall"/);
|
|
assert.match(telephonyInterimHtml, /data-ui-mock-page="ak-p15a-telephony-interim"/);
|
|
assert.match(telephonyInterimShellHtml, /data-sidebar-count="2"/);
|
|
assert.match(telephonyInterimShellHtml, /data-breadcrumb-count="2"/);
|
|
assert.match(telephonyInterimShellHtml, /data-hot-swap-page="ak-p15a-telephony-interim"/);
|
|
|
|
const importedCrmInterimPage = await importGeneratedHotSwapModule(crmInterimModule);
|
|
assert.equal(importedCrmInterimPage.id, "r-p6-crm-interim");
|
|
assert.equal(importedCrmInterimPage.route, "/:tenant/contacts");
|
|
assert.equal(importedCrmInterimPage.state.status, "ready");
|
|
assert.match(crmInterimModule, /"designStatus": "interim"/);
|
|
assert.match(crmInterimModule, /"displayName": "Solaris GmbH"/);
|
|
assert.match(crmInterimHtml, /data-ui-mock-page="r-p6-crm-interim"/);
|
|
assert.match(crmInterimShellHtml, /data-sidebar-count="2"/);
|
|
assert.match(crmInterimShellHtml, /data-breadcrumb-count="1"/);
|
|
assert.match(crmInterimShellHtml, /data-hot-swap-page="r-p6-crm-interim"/);
|
|
|
|
const importedLeadInterimPage = await importGeneratedHotSwapModule(leadInterimModule);
|
|
assert.equal(importedLeadInterimPage.id, "r-p7-leads-interim");
|
|
assert.equal(importedLeadInterimPage.route, "/:tenant/leads");
|
|
assert.equal(importedLeadInterimPage.state.status, "ready");
|
|
assert.match(leadInterimModule, /"designStatus": "interim"/);
|
|
assert.match(leadInterimModule, /"displayName": "Anna Anfrage"/);
|
|
assert.match(leadInterimHtml, /data-ui-mock-page="r-p7-leads-interim"/);
|
|
assert.match(leadInterimShellHtml, /data-sidebar-count="2"/);
|
|
assert.match(leadInterimShellHtml, /data-breadcrumb-count="1"/);
|
|
assert.match(leadInterimShellHtml, /data-hot-swap-page="r-p7-leads-interim"/);
|
|
|
|
const importedProjektBoardInterimPage = await importGeneratedHotSwapModule(projektBoardInterimModule);
|
|
assert.equal(importedProjektBoardInterimPage.id, "r-p8-projects-interim");
|
|
assert.equal(importedProjektBoardInterimPage.route, "/:tenant/projects");
|
|
assert.equal(importedProjektBoardInterimPage.state.status, "ready");
|
|
assert.match(projektBoardInterimModule, /"designStatus": "interim"/);
|
|
assert.match(projektBoardInterimModule, /"projektname": "Wärmepumpe Familie Muster"/);
|
|
assert.match(projektBoardInterimHtml, /data-ui-mock-page="r-p8-projects-interim"/);
|
|
assert.match(projektBoardInterimShellHtml, /data-sidebar-count="2"/);
|
|
assert.match(projektBoardInterimShellHtml, /data-breadcrumb-count="1"/);
|
|
assert.match(projektBoardInterimShellHtml, /data-hot-swap-page="r-p8-projects-interim"/);
|
|
|
|
const importedChatIndexInterimPage = await importGeneratedHotSwapModule(chatIndexInterimModule);
|
|
assert.equal(importedChatIndexInterimPage.id, "ak-p15b-chat-index-interim");
|
|
assert.equal(importedChatIndexInterimPage.route, "/:tenant/chat");
|
|
assert.equal(importedChatIndexInterimPage.state.status, "ready");
|
|
assert.match(chatIndexInterimModule, /"designStatus": "interim"/);
|
|
assert.match(chatIndexInterimModule, /"permission": "chat\.read_own_channels"/);
|
|
assert.match(chatIndexInterimHtml, /data-ui-mock-page="ak-p15b-chat-index-interim"/);
|
|
assert.match(chatIndexInterimShellHtml, /data-sidebar-count="1"/);
|
|
assert.match(chatIndexInterimShellHtml, /data-breadcrumb-count="1"/);
|
|
assert.match(chatIndexInterimShellHtml, /data-hot-swap-page="ak-p15b-chat-index-interim"/);
|
|
|
|
const importedChatDetailInterimPage = await importGeneratedHotSwapModule(chatDetailInterimModule);
|
|
assert.equal(importedChatDetailInterimPage.id, "ak-p15b-chat-detail-interim");
|
|
assert.equal(importedChatDetailInterimPage.route, "/:tenant/chat/:id");
|
|
assert.equal(importedChatDetailInterimPage.state.status, "ready");
|
|
assert.match(chatDetailInterimModule, /"source": "http_ack"/);
|
|
assert.doesNotMatch(chatDetailInterimModule, /"source": "local_echo"/);
|
|
assert.match(chatDetailInterimHtml, /data-ui-mock-page="ak-p15b-chat-detail-interim"/);
|
|
assert.match(chatDetailInterimShellHtml, /data-sidebar-count="1"/);
|
|
assert.match(chatDetailInterimShellHtml, /data-breadcrumb-count="2"/);
|
|
assert.match(chatDetailInterimShellHtml, /data-hot-swap-page="ak-p15b-chat-detail-interim"/);
|
|
|
|
const importedVaP24aInterimPage = await importGeneratedHotSwapModule(vaP24aInterimModule);
|
|
assert.equal(importedVaP24aInterimPage.id, "va-p24a-interim");
|
|
assert.equal(importedVaP24aInterimPage.route, "/:tenant/settings/billing");
|
|
assert.match(vaP24aInterimModule, /"designStatus": "interim"/);
|
|
assert.match(vaP24aInterimModule, /"minimumSeatQuantity": 3/);
|
|
assert.match(vaP24aInterimHtml, /data-ui-mock-page="va-p24a-interim"/);
|
|
assert.match(vaP24aInterimShellHtml, /data-sidebar-count="1"/);
|
|
assert.match(vaP24aInterimShellHtml, /data-breadcrumb-count="2"/);
|
|
assert.match(vaP24aInterimShellHtml, /data-hot-swap-page="va-p24a-interim"/);
|
|
const importedVaP26aInterimPage = await importGeneratedHotSwapModule(vaP26aInterimModule);
|
|
assert.equal(importedVaP26aInterimPage.id, "va-p26a-customer-portal-interim");
|
|
assert.equal(importedVaP26aInterimPage.route, "/:tenant");
|
|
assert.match(vaP26aInterimModule, /"designStatus": "interim"/);
|
|
assert.match(vaP26aInterimModule, /"portalName": "Acme Kundenportal"/);
|
|
assert.match(vaP26aInterimHtml, /data-ui-mock-page="va-p26a-customer-portal-interim"/);
|
|
assert.match(vaP26aInterimShellHtml, /data-sidebar-count="2"/);
|
|
assert.match(vaP26aInterimShellHtml, /data-breadcrumb-count="2"/);
|
|
assert.match(vaP26aInterimShellHtml, /data-portal-count="1"/);
|
|
assert.match(vaP26aInterimShellHtml, /data-hot-swap-page="va-p26a-customer-portal-interim"/);
|
|
const importedVaP26bInterimPage = await importGeneratedHotSwapModule(vaP26bInterimModule);
|
|
assert.equal(importedVaP26bInterimPage.id, "va-p26b-customer-portal-interim");
|
|
assert.equal(importedVaP26bInterimPage.route, "/:tenant/upload");
|
|
assert.match(vaP26bInterimModule, /"designStatus": "interim"/);
|
|
assert.match(vaP26bInterimModule, /"viewerKind": "customer"/);
|
|
assert.match(vaP26bInterimModule, /"kind": "subcontractor"/);
|
|
assert.match(vaP26bInterimModule, /"eventType": "lifecycle"/);
|
|
assert.match(vaP26bInterimHtml, /data-ui-mock-page="va-p26b-customer-portal-interim"/);
|
|
assert.match(vaP26bInterimShellHtml, /data-sidebar-count="3"/);
|
|
assert.match(vaP26bInterimShellHtml, /data-breadcrumb-count="2"/);
|
|
assert.match(vaP26bInterimShellHtml, /data-portal-count="1"/);
|
|
assert.match(vaP26bInterimShellHtml, /data-hot-swap-page="va-p26b-customer-portal-interim"/);
|
|
for (const candidate of vaP26bInterimPages) {
|
|
const importedCandidate = await importGeneratedHotSwapModule(generateHotSwapMock(candidate));
|
|
assert.equal(importedCandidate.route, candidate.route);
|
|
assert.equal(registry.get(candidate.route)?.id, candidate.id);
|
|
}
|
|
const importedVaP26cInterimPage = await importGeneratedHotSwapModule(vaP26cInterimModule);
|
|
assert.equal(importedVaP26cInterimPage.id, "va-p26c-customer-portal-domain-interim");
|
|
assert.equal(importedVaP26cInterimPage.route, "/:tenant/settings/customer-portal/domain");
|
|
assert.match(vaP26cInterimModule, /"designStatus": "interim"/);
|
|
assert.match(vaP26cInterimModule, /"pendingSwitch":/);
|
|
assert.match(vaP26cInterimModule, /"canActivateSwitch": true/);
|
|
assert.match(vaP26cInterimHtml, /data-ui-mock-page="va-p26c-customer-portal-domain-interim"/);
|
|
assert.match(vaP26cInterimShellHtml, /data-sidebar-count="1"/);
|
|
assert.match(vaP26cInterimShellHtml, /data-breadcrumb-count="3"/);
|
|
assert.match(vaP26cInterimShellHtml, /data-hot-swap-page="va-p26c-customer-portal-domain-interim"/);
|
|
}
|
|
|
|
const isCli = process.argv[1] && fileURLToPath(import.meta.url) === path.resolve(process.argv[1]);
|
|
|
|
if (isCli) {
|
|
await verifyUiHotSwap();
|
|
process.stdout.write("UI hot-swap drill verified.\n");
|
|
}
|
|
|
|
async function importGeneratedHotSwapModule(source: string) {
|
|
const tempDir = await mkdtemp(path.join(os.tmpdir(), "hivegrid-ui-hot-swap-"));
|
|
const modulePath = path.join(tempDir, "hot-swap.mjs");
|
|
|
|
try {
|
|
await writeFile(modulePath, source, "utf8");
|
|
const imported = (await import(`${pathToFileURL(modulePath).href}?t=${Date.now()}`)) as { default?: unknown; mockPage?: unknown };
|
|
assert.deepEqual(imported.default, imported.mockPage);
|
|
assert.ok(isMockPage(imported.mockPage));
|
|
return imported.mockPage;
|
|
} finally {
|
|
await rm(tempDir, { recursive: true, force: true });
|
|
}
|
|
}
|
|
|
|
function isMockPage(value: unknown): value is ReturnType<typeof createHotSwapDrillPage> {
|
|
if (!value || typeof value !== "object") return false;
|
|
const candidate = value as Partial<ReturnType<typeof createHotSwapDrillPage>>;
|
|
return typeof candidate.id === "string" && typeof candidate.route === "string" && typeof candidate.state === "object";
|
|
}
|