Add governed View surface runtime
This commit is contained in:
@@ -10,6 +10,11 @@ import {
|
||||
routeContributionsForModules,
|
||||
uiCapability
|
||||
} from "../src/platform/moduleLogic";
|
||||
import {
|
||||
isViewSurfaceVisible,
|
||||
viewSurfaceCatalogueForModules,
|
||||
visibleRoutesForProjection
|
||||
} from "../src/platform/views";
|
||||
import { scopeGrants } from "../src/utils/permissions";
|
||||
|
||||
function assert(condition: unknown, message: string): void {
|
||||
@@ -96,3 +101,73 @@ functionAction.onClick({
|
||||
});
|
||||
assert(selectedFunctionId === "function-1", "organization function actions receive their row context");
|
||||
assert(!("render" in functionAction), "organization function actions expose metadata instead of arbitrary rendered controls");
|
||||
|
||||
const viewAwareFiles: PlatformWebModule = {
|
||||
...files,
|
||||
navItems: [{ to: "/files", label: "Files", order: 20 }],
|
||||
viewSurfaces: [
|
||||
{
|
||||
id: "files.settings.connectors",
|
||||
moduleId: "files",
|
||||
kind: "section",
|
||||
label: "File connectors"
|
||||
}
|
||||
]
|
||||
};
|
||||
const viewCatalogue = viewSurfaceCatalogueForModules([viewAwareFiles]);
|
||||
assert(
|
||||
viewCatalogue.some((surface) => surface.id === "files.module"),
|
||||
"view catalogue should derive a module root"
|
||||
);
|
||||
assert(
|
||||
viewCatalogue.some((surface) => surface.id === "files.nav.files"),
|
||||
"view catalogue should derive navigation surfaces"
|
||||
);
|
||||
assert(
|
||||
viewCatalogue.some((surface) => surface.id === "files.route.files"),
|
||||
"view catalogue should derive route surfaces"
|
||||
);
|
||||
|
||||
const filesView = {
|
||||
activeViewId: "view-files",
|
||||
activeRevisionId: "revision-files",
|
||||
activeViewName: "Files only",
|
||||
visibleSurfaceIds: [
|
||||
"files.module",
|
||||
"files.nav.files",
|
||||
"files.route.files"
|
||||
],
|
||||
locked: false,
|
||||
availableViews: [],
|
||||
provenance: [],
|
||||
diagnostics: []
|
||||
};
|
||||
assert(
|
||||
isViewSurfaceVisible(filesView, "files.route.files", viewCatalogue),
|
||||
"selected child surfaces should remain visible when their ancestor is selected"
|
||||
);
|
||||
assert(
|
||||
!isViewSurfaceVisible(filesView, "files.settings.connectors", viewCatalogue),
|
||||
"unselected sections should be hidden"
|
||||
);
|
||||
assert(
|
||||
visibleRoutesForProjection([viewAwareFiles], filesView).length === 1,
|
||||
"selected routes should remain in the effective route list"
|
||||
);
|
||||
|
||||
const missingParentView = {
|
||||
...filesView,
|
||||
visibleSurfaceIds: ["files.route.files"]
|
||||
};
|
||||
assert(
|
||||
!isViewSurfaceVisible(
|
||||
missingParentView,
|
||||
"files.route.files",
|
||||
viewCatalogue
|
||||
),
|
||||
"a selected child should stay hidden when its module ancestor is not selected"
|
||||
);
|
||||
assert(
|
||||
isViewSurfaceVisible(filesView, "future.module.action", viewCatalogue),
|
||||
"unknown surfaces should fail open for forward compatibility and recovery"
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user