feat: strengthen module contracts and shared WebUI runtime
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import type {
|
||||
DashboardWidgetsUiCapability,
|
||||
OrganizationFunctionActionContext,
|
||||
OrganizationFunctionActionContribution,
|
||||
PlatformWebModule
|
||||
@@ -71,6 +72,51 @@ for (const testCase of cases) {
|
||||
assert(uiCapability("files.fileExplorer", [access, files]) === filesCapability, "files capability should return the module-provided object");
|
||||
assert(uiCapability("mail.profiles", [access, mail]) === mailCapability, "mail capability should return the module-provided object");
|
||||
|
||||
const configurableDashboardWidgets: DashboardWidgetsUiCapability = {
|
||||
widgets: [
|
||||
{
|
||||
id: "files.recent",
|
||||
surfaceId: "files.widget.recent",
|
||||
title: "Recent files",
|
||||
moduleId: "files",
|
||||
supportedSizes: ["medium", "wide"],
|
||||
defaultConfiguration: { limit: 10, includeFolders: false },
|
||||
configurationFields: [
|
||||
{
|
||||
id: "limit",
|
||||
label: "Items",
|
||||
kind: "number",
|
||||
min: 1,
|
||||
max: 50
|
||||
},
|
||||
{
|
||||
id: "includeFolders",
|
||||
label: "Include folders",
|
||||
kind: "boolean"
|
||||
}
|
||||
],
|
||||
render: ({ configuration, effectiveView, instanceId }) =>
|
||||
`${instanceId}:${effectiveView?.activeViewId ?? "full"}:${String(configuration.limit)}`
|
||||
}
|
||||
]
|
||||
};
|
||||
const dashboardProvider: PlatformWebModule = {
|
||||
id: "dashboard-provider",
|
||||
label: "Dashboard provider",
|
||||
version: "test",
|
||||
uiCapabilities: {
|
||||
"dashboard.widgets": configurableDashboardWidgets
|
||||
}
|
||||
};
|
||||
const resolvedDashboardWidgets = uiCapability<DashboardWidgetsUiCapability>(
|
||||
"dashboard.widgets",
|
||||
[dashboardProvider]
|
||||
);
|
||||
assert(
|
||||
resolvedDashboardWidgets?.widgets[0].configurationFields?.length === 2,
|
||||
"dashboard widget capabilities should retain provider-defined configuration"
|
||||
);
|
||||
|
||||
const routes = routeContributionsForModules([access, files, mail, campaigns]).map((route) => route.path);
|
||||
assert(routes.join(",") === "/campaigns,/files,/mail", "routes should aggregate and sort by contribution order");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user