Update hivegrid-cloud reference to latest main
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e98d38e716
commit
7b21524c86
3781 files changed
+373484
-225607
No files matched your search
+2
-4
@@ -82,13 +82,11 @@ describe("AdminSidebar", () => {
|
||||
expect(Array.isArray(sidebar)).toBe(true);
|
||||
expect(serialized).toContain("/dashboard");
|
||||
expect(serialized).toContain("/accounts");
|
||||
expect(serialized).toContain("/analytics/overview");
|
||||
expect(serialized).toContain("/audit-trails");
|
||||
expect(serialized).toContain("/notifications/messages");
|
||||
expect(serialized).toContain("/feature-flags/flags");
|
||||
expect(serialized).toContain("/onboarding/onboardings");
|
||||
expect(serialized).toContain("/metrics/summary");
|
||||
expect(serialized).toContain("/settings/profile");
|
||||
expect(serialized).not.toContain("/metrics");
|
||||
expect(sidebar).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
@@ -100,7 +98,7 @@ describe("AdminSidebar", () => {
|
||||
);
|
||||
expect(sidebar.at(-1)?.items).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({ id: "ui.nav.admin.switchToApp", path: "/", exact: true }),
|
||||
expect.objectContaining({ id: "ui.nav.admin.switchToApp", path: "/select-tenant", permission: "admin.accounts.view", exact: true }),
|
||||
])
|
||||
);
|
||||
const emittedPaths = serialized.match(/"path":"[^"]*"/g) ?? [];
|
||||
|
||||
+20
-95
@@ -6,7 +6,6 @@ import { AppConfiguration } from "~/utils/db/appConfiguration.db.server";
|
||||
import IconSettings from "~/components/layouts/icons/IconSettings";
|
||||
import IconApp from "~/components/layouts/icons/IconApp";
|
||||
import IconKeys from "~/components/layouts/icons/IconKeys";
|
||||
import IconEntities from "~/components/layouts/icons/IconEntities";
|
||||
import IconAnalytics from "~/components/layouts/icons/IconAnalytics";
|
||||
import IconDocs from "~/components/layouts/icons/IconDocs";
|
||||
import IconEmails from "~/components/layouts/icons/IconEmails";
|
||||
@@ -14,18 +13,13 @@ import IconEvents from "~/components/layouts/icons/IconEvents";
|
||||
import IconFeatureFlags from "~/components/layouts/icons/IconFeatureFlags";
|
||||
import IconHelpDesk from "~/components/layouts/icons/IconHelpDesk";
|
||||
import IconMetrics from "~/components/layouts/icons/IconMetrics";
|
||||
import IconNavigation from "~/components/layouts/icons/IconNavigation";
|
||||
import IconNotifications from "~/components/layouts/icons/IconNotifications";
|
||||
import IconOnboarding from "~/components/layouts/icons/IconOnboarding";
|
||||
import IconPortals from "~/components/layouts/icons/IconPortals";
|
||||
import IconWorkflows from "~/components/layouts/icons/IconWorkflows";
|
||||
import { UI_NAV_IDS } from "~/application/ui/uiRegistry";
|
||||
import { adminPath } from "~/utils/app/CanonicalUrlUtils";
|
||||
import { absoluteAppRootPath, type PublicDomainRoutingConfig } from "~/utils/app/CrossHostUrls";
|
||||
import type { PublicDomainRoutingConfig } from "~/utils/app/CrossHostUrls";
|
||||
import { disabledPluginRouteSlugs } from "~/utils/app/PublicRouteSegments";
|
||||
|
||||
const adminSidebarPath = (path?: string) => adminPath(path, { mode: "host-aware" });
|
||||
const rootAppFallbackPath = "/";
|
||||
const disabledAdminRouteSlugs = new Set<string>(disabledPluginRouteSlugs);
|
||||
|
||||
function isAdminRouteEnabled(slug: string) {
|
||||
@@ -42,7 +36,7 @@ type Props = {
|
||||
routing?: PublicDomainRoutingConfig;
|
||||
};
|
||||
|
||||
export const AdminSidebar = ({ t, appConfiguration, routing }: Props): SideBarItem[] => [
|
||||
export const AdminSidebar = ({ t, appConfiguration }: Props): SideBarItem[] => [
|
||||
{
|
||||
id: "ui.nav.admin.primary",
|
||||
title: "",
|
||||
@@ -92,6 +86,13 @@ export const AdminSidebar = ({ t, appConfiguration, routing }: Props): SideBarIt
|
||||
items: [],
|
||||
permission: "admin.accounts.view",
|
||||
},
|
||||
{
|
||||
id: "ui.nav.admin.accounts.billing",
|
||||
title: t("admin.billing.title"),
|
||||
path: adminSidebarPath("accounts/billing"),
|
||||
items: [],
|
||||
permission: "admin.account.subscription",
|
||||
},
|
||||
{
|
||||
id: "ui.nav.admin.accounts.rolesAndPermissions",
|
||||
title: t("app.sidebar.rolesAndPermissions"),
|
||||
@@ -117,32 +118,16 @@ export const AdminSidebar = ({ t, appConfiguration, routing }: Props): SideBarIt
|
||||
permission: "admin.accounts.view",
|
||||
},
|
||||
{
|
||||
id: UI_NAV_IDS.adminAnalytics,
|
||||
title: t("app.sidebar.analytics"),
|
||||
path: adminSidebarPath("analytics"),
|
||||
icon: <IconAnalytics />,
|
||||
id: UI_NAV_IDS.adminAudit,
|
||||
title: t("admin.auditAndEvents"),
|
||||
path: adminSidebarPath("audit"),
|
||||
icon: <IconEvents />,
|
||||
isCollapsible: true,
|
||||
items: [
|
||||
{ id: "ui.nav.admin.analytics.overview", title: t("app.sidebar.overview"), path: adminSidebarPath("analytics/overview"), permission: "admin.analytics.view" },
|
||||
{ id: "ui.nav.admin.analytics.pageViews", title: t("app.sidebar.pageViews"), path: adminSidebarPath("analytics/page-views"), permission: "admin.analytics.view" },
|
||||
{ id: "ui.nav.admin.analytics.visitors", title: t("app.sidebar.visitors"), path: adminSidebarPath("analytics/visitors"), permission: "admin.analytics.view" },
|
||||
{ id: "ui.nav.admin.analytics.events", title: t("models.event.plural"), path: adminSidebarPath("analytics/events"), permission: "admin.analytics.view" },
|
||||
{ id: "ui.nav.admin.analytics.settings", title: t("app.sidebar.settings"), path: adminSidebarPath("analytics/settings"), permission: "admin.settings.analytics.view" },
|
||||
{ id: "ui.nav.admin.audit.viewer", title: t("app.sidebar.audit"), path: adminSidebarPath("audit"), permission: "admin.auditTrails.view" },
|
||||
{ id: "ui.nav.admin.audit.trails", title: t("app.sidebar.auditTrails"), path: adminSidebarPath("audit-trails"), permission: "admin.auditTrails.view" },
|
||||
{ id: "ui.nav.admin.audit.events", title: t("models.event.plural"), path: adminSidebarPath("events"), permission: "admin.events.view" },
|
||||
],
|
||||
permission: "admin.analytics.view",
|
||||
},
|
||||
{
|
||||
id: UI_NAV_IDS.adminEvents,
|
||||
title: t("models.event.plural"),
|
||||
path: adminSidebarPath("events"),
|
||||
icon: <IconEvents />,
|
||||
permission: "admin.events.view",
|
||||
},
|
||||
{
|
||||
id: UI_NAV_IDS.adminAuditTrails,
|
||||
title: t("app.sidebar.auditTrails"),
|
||||
path: adminSidebarPath("audit-trails"),
|
||||
icon: <IconEvents />,
|
||||
permission: "admin.auditTrails.view",
|
||||
},
|
||||
{
|
||||
@@ -161,31 +146,10 @@ export const AdminSidebar = ({ t, appConfiguration, routing }: Props): SideBarIt
|
||||
],
|
||||
},
|
||||
{
|
||||
id: "ui.nav.admin.build",
|
||||
title: t("segments.build"),
|
||||
id: "ui.nav.admin.platform",
|
||||
title: t("segments.platform"),
|
||||
path: "",
|
||||
items: [
|
||||
{
|
||||
id: UI_NAV_IDS.adminEntities,
|
||||
title: t("models.entity.plural"),
|
||||
path: adminSidebarPath("entities"),
|
||||
icon: <IconEntities />,
|
||||
permission: "admin.entities.view",
|
||||
},
|
||||
...enabledAdminRouteItem("workflow-engine", {
|
||||
id: UI_NAV_IDS.adminWorkflows,
|
||||
title: t("models.workflow.plural"),
|
||||
path: adminSidebarPath("workflow-engine"),
|
||||
icon: <IconWorkflows />,
|
||||
isCollapsible: true,
|
||||
items: [
|
||||
{ id: "ui.nav.admin.workflows.workflows", title: t("models.workflow.plural"), path: adminSidebarPath("workflow-engine/workflows") },
|
||||
{ id: "ui.nav.admin.workflows.executions", title: t("app.sidebar.executions"), path: adminSidebarPath("workflow-engine/executions") },
|
||||
{ id: "ui.nav.admin.workflows.templates", title: t("models.entity.templates"), path: adminSidebarPath("workflow-engine/templates") },
|
||||
{ id: "ui.nav.admin.workflows.credentials", title: t("app.sidebar.credentials"), path: adminSidebarPath("workflow-engine/credentials") },
|
||||
{ id: "ui.nav.admin.workflows.variables", title: t("app.sidebar.variables"), path: adminSidebarPath("workflow-engine/variables") },
|
||||
],
|
||||
}),
|
||||
{
|
||||
id: UI_NAV_IDS.adminApi,
|
||||
title: t("settings.api.title"),
|
||||
@@ -197,8 +161,6 @@ export const AdminSidebar = ({ t, appConfiguration, routing }: Props): SideBarIt
|
||||
items: [
|
||||
{ id: "ui.nav.admin.api.keys", title: t("app.sidebar.apiKeys"), path: adminSidebarPath("api/keys"), permission: "admin.apiKeys.view" },
|
||||
{ id: "ui.nav.admin.api.logs", title: t("app.sidebar.logs"), path: adminSidebarPath("api/logs"), permission: "admin.apiKeys.view" },
|
||||
{ id: "ui.nav.admin.api.docs", title: t("app.sidebar.docs"), path: adminSidebarPath("api/docs"), permission: "admin.apiKeys.view" },
|
||||
{ id: "ui.nav.admin.api.credits", title: t("app.sidebar.credits"), path: adminSidebarPath("api/credits"), permission: "admin.apiKeys.view" },
|
||||
],
|
||||
},
|
||||
{
|
||||
@@ -213,18 +175,6 @@ export const AdminSidebar = ({ t, appConfiguration, routing }: Props): SideBarIt
|
||||
],
|
||||
permission: "admin.featureFlags.view",
|
||||
},
|
||||
{
|
||||
id: UI_NAV_IDS.adminNavigation,
|
||||
title: t("admin.navigation.title"),
|
||||
path: adminSidebarPath("navigation"),
|
||||
icon: <IconNavigation className="size-4" />,
|
||||
},
|
||||
...enabledAdminRouteItem("portals", {
|
||||
id: UI_NAV_IDS.adminPortals,
|
||||
title: t("app.sidebar.portals"),
|
||||
path: adminSidebarPath("portals"),
|
||||
icon: <IconPortals />,
|
||||
}),
|
||||
],
|
||||
},
|
||||
{
|
||||
@@ -281,31 +231,6 @@ export const AdminSidebar = ({ t, appConfiguration, routing }: Props): SideBarIt
|
||||
{ id: "ui.nav.admin.helpDesk.feedback", title: t("app.sidebar.feedback"), path: adminSidebarPath("help-desk/feedback") },
|
||||
],
|
||||
}),
|
||||
{
|
||||
id: UI_NAV_IDS.adminOnboarding,
|
||||
title: t("app.sidebar.onboarding"),
|
||||
path: adminSidebarPath("onboarding"),
|
||||
icon: <IconOnboarding />,
|
||||
isCollapsible: true,
|
||||
items: [
|
||||
{ id: "ui.nav.admin.onboarding.onboardings", title: t("app.sidebar.onboardings"), path: adminSidebarPath("onboarding/onboardings"), permission: "admin.onboarding.view" },
|
||||
{ id: "ui.nav.admin.onboarding.sessions", title: t("app.sidebar.sessions"), path: adminSidebarPath("onboarding/sessions"), permission: "admin.onboarding.view" },
|
||||
],
|
||||
permission: "admin.onboarding.view",
|
||||
},
|
||||
{
|
||||
id: UI_NAV_IDS.adminMetrics,
|
||||
title: t("app.sidebar.metrics"),
|
||||
path: adminSidebarPath("metrics"),
|
||||
icon: <IconMetrics />,
|
||||
isCollapsible: true,
|
||||
items: [
|
||||
{ id: "ui.nav.admin.metrics.summary", title: t("app.sidebar.summary"), path: adminSidebarPath("metrics/summary"), permission: "admin.metrics.view" },
|
||||
{ id: "ui.nav.admin.metrics.logs", title: t("app.sidebar.logs"), path: adminSidebarPath("metrics/logs"), permission: "admin.metrics.view" },
|
||||
{ id: "ui.nav.admin.metrics.settings", title: t("app.sidebar.settings"), path: adminSidebarPath("metrics/settings"), permission: "admin.metrics.view" },
|
||||
],
|
||||
permission: "admin.metrics.view",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
@@ -330,7 +255,6 @@ export const AdminSidebar = ({ t, appConfiguration, routing }: Props): SideBarIt
|
||||
path: adminSidebarPath("settings/authentication"),
|
||||
permission: "admin.settings.authentication.view",
|
||||
},
|
||||
{ id: "ui.nav.admin.settings.analytics", title: t("settings.admin.analytics.title"), path: adminSidebarPath("settings/analytics"), permission: "admin.settings.analytics.view" },
|
||||
{
|
||||
id: "ui.nav.admin.settings.transactionalEmails",
|
||||
title: t("settings.admin.transactionalEmails.title"),
|
||||
@@ -345,8 +269,9 @@ export const AdminSidebar = ({ t, appConfiguration, routing }: Props): SideBarIt
|
||||
{
|
||||
id: UI_NAV_IDS.adminSwitchToApp,
|
||||
title: t("admin.switchToApp"),
|
||||
path: routing ? absoluteAppRootPath(routing) : rootAppFallbackPath,
|
||||
path: adminSidebarPath("select-tenant"),
|
||||
icon: <IconApp />,
|
||||
permission: "admin.accounts.view",
|
||||
exact: true,
|
||||
},
|
||||
],
|
||||
|
||||
+50
-113
@@ -2,48 +2,55 @@ import { existsSync } from "node:fs";
|
||||
import { vi, describe, it, expect } from "vitest";
|
||||
import { AppSidebar } from "./AppSidebar";
|
||||
import { UI_NAV_IDS } from "~/application/ui/uiRegistry";
|
||||
import { EntitySimple } from "~/utils/db/entities/entities.db.server";
|
||||
import { resolveRepoPath } from "~/utils/testing/repoPaths";
|
||||
|
||||
// R-P6B-β (AD-2): the generic entity-builder is gone, so AppSidebar no longer
|
||||
// renders dynamic per-entity / entity-group nav. Only typed product features and
|
||||
// static targets remain.
|
||||
|
||||
describe("AppSidebar", () => {
|
||||
const starterProductAccess = {
|
||||
dashboard: { allowed: true },
|
||||
"crm-basic": { allowed: true },
|
||||
projects: { allowed: true },
|
||||
automation: { allowed: false },
|
||||
"email-marketing": { allowed: false },
|
||||
api: { allowed: false },
|
||||
"workflow-engine": { allowed: false },
|
||||
"ai-credits": { allowed: true },
|
||||
};
|
||||
const proProductAccess = {
|
||||
dashboard: { allowed: true },
|
||||
"crm-basic": { allowed: true },
|
||||
projects: { allowed: true },
|
||||
automation: { allowed: false },
|
||||
"email-marketing": { allowed: true },
|
||||
"email-inbox": { allowed: true },
|
||||
api: { allowed: true },
|
||||
"workflow-engine": { allowed: false },
|
||||
"ai-credits": { allowed: true },
|
||||
};
|
||||
const businessProductAccess = {
|
||||
dashboard: { allowed: true },
|
||||
"crm-basic": { allowed: true },
|
||||
projects: { allowed: true },
|
||||
automation: { allowed: true },
|
||||
"email-marketing": { allowed: true },
|
||||
"email-inbox": { allowed: true },
|
||||
api: { allowed: true },
|
||||
"workflow-engine": { allowed: true },
|
||||
"ai-credits": { allowed: true },
|
||||
};
|
||||
|
||||
it("returns the expected sidebar items", () => {
|
||||
it("returns the expected static sidebar items", () => {
|
||||
const t = vi.fn().mockImplementation((v: string) => v) as any;
|
||||
const i18n = { exists: vi.fn().mockReturnValue(false) } as any;
|
||||
const entities = [
|
||||
{ name: "entity1", slug: "entity1", titlePlural: "Entity 1", showInSidebar: true, icon: "" },
|
||||
{ name: "entity2", slug: "entity2", titlePlural: "Entity 2", showInSidebar: false, icon: "" },
|
||||
{ name: "entity3", slug: "entity3", titlePlural: "Entity 3", showInSidebar: true, icon: "" },
|
||||
] as EntitySimple[];
|
||||
|
||||
const result = AppSidebar({ t, i18n, tenantId: "test-user", entities, entityGroups: [], appConfiguration: null });
|
||||
const result = AppSidebar({ t, i18n, tenantId: "test-user", appConfiguration: null });
|
||||
const serialized = JSON.stringify(result);
|
||||
|
||||
expect(result[0]).toMatchObject({
|
||||
title: "",
|
||||
path: "",
|
||||
items: [
|
||||
expect(result[0].items).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
id: "ui.nav.app.dashboard",
|
||||
title: "app.sidebar.dashboard",
|
||||
@@ -54,25 +61,13 @@ describe("AppSidebar", () => {
|
||||
title: "app.sidebar.notifications",
|
||||
path: "/test-user/notifications",
|
||||
}),
|
||||
expect.objectContaining({
|
||||
id: "ui.nav.app.entity.entity1",
|
||||
title: "Entity 1",
|
||||
path: "/test-user/entity1",
|
||||
permission: "entity.entity1.view",
|
||||
}),
|
||||
expect.objectContaining({
|
||||
id: "ui.nav.app.entity.entity3",
|
||||
title: "Entity 3",
|
||||
path: "/test-user/entity3",
|
||||
permission: "entity.entity3.view",
|
||||
}),
|
||||
],
|
||||
});
|
||||
])
|
||||
);
|
||||
expect(result[1]).toMatchObject({
|
||||
title: "",
|
||||
path: "",
|
||||
isSecondary: true,
|
||||
items: [
|
||||
items: expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
id: "ui.nav.app.settings",
|
||||
title: "app.sidebar.settings",
|
||||
@@ -85,8 +80,10 @@ describe("AppSidebar", () => {
|
||||
path: "/dashboard",
|
||||
adminOnly: true,
|
||||
}),
|
||||
],
|
||||
]),
|
||||
});
|
||||
expect(serialized).not.toContain("ui.nav.app.entity.");
|
||||
expect(serialized).not.toContain("ui.nav.app.entityGroup.");
|
||||
expect(serialized).not.toContain("/app/");
|
||||
expect(serialized).not.toContain("/admin/");
|
||||
expect(serialized).not.toContain("/blog");
|
||||
@@ -102,113 +99,50 @@ describe("AppSidebar", () => {
|
||||
const t = vi.fn().mockImplementation((v: string) => v) as any;
|
||||
const i18n = { exists: vi.fn().mockReturnValue(false) } as any;
|
||||
|
||||
const starter = JSON.stringify(
|
||||
AppSidebar({ t, i18n, tenantId: "starter", entities: [], entityGroups: [], appConfiguration: null, productAccess: starterProductAccess })
|
||||
);
|
||||
const pro = JSON.stringify(
|
||||
AppSidebar({ t, i18n, tenantId: "pro", entities: [], entityGroups: [], appConfiguration: null, productAccess: proProductAccess })
|
||||
);
|
||||
const business = JSON.stringify(
|
||||
AppSidebar({ t, i18n, tenantId: "business", entities: [], entityGroups: [], appConfiguration: null, productAccess: businessProductAccess })
|
||||
);
|
||||
const starter = JSON.stringify(AppSidebar({ t, i18n, tenantId: "starter", appConfiguration: null, productAccess: starterProductAccess }));
|
||||
const pro = JSON.stringify(AppSidebar({ t, i18n, tenantId: "pro", appConfiguration: null, productAccess: proProductAccess }));
|
||||
const business = JSON.stringify(AppSidebar({ t, i18n, tenantId: "business", appConfiguration: null, productAccess: businessProductAccess }));
|
||||
|
||||
expect(starter).toContain("/starter/crm");
|
||||
expect(starter).toContain("/starter/settings/credits");
|
||||
expect(starter).toContain("/starter/contacts");
|
||||
expect(starter).toContain("/starter/projects");
|
||||
expect(starter).not.toContain("/starter/settings/credits");
|
||||
expect(starter).not.toContain("/starter/email-marketing");
|
||||
expect(starter).not.toContain("/starter/emails");
|
||||
expect(starter).not.toContain("/starter/automations");
|
||||
expect(starter).not.toContain("/starter/settings/api");
|
||||
expect(starter).not.toContain("/starter/workflow-engine");
|
||||
|
||||
expect(pro).toContain("/pro/crm");
|
||||
expect(pro).toContain("/pro/contacts");
|
||||
expect(pro).toContain("/pro/projects");
|
||||
expect(pro).toContain("/pro/email-marketing");
|
||||
expect(pro).toContain("/pro/emails");
|
||||
expect(pro).not.toContain("/pro/automations");
|
||||
expect(pro).toContain("/pro/settings/api");
|
||||
expect(pro).not.toContain("/pro/workflow-engine");
|
||||
|
||||
expect(business).toContain("/business/crm");
|
||||
expect(business).toContain("/business/contacts");
|
||||
expect(business).toContain("/business/projects");
|
||||
expect(business).toContain("/business/email-marketing");
|
||||
expect(business).toContain("/business/automations");
|
||||
expect(business).toContain("/business/settings/api");
|
||||
expect(business).toContain("/business/workflow-engine");
|
||||
});
|
||||
|
||||
it("marks collapsible entity groups as expand-only parents", () => {
|
||||
const t = vi.fn().mockImplementation((v: string) => v) as any;
|
||||
const i18n = { exists: vi.fn().mockReturnValue(false) } as any;
|
||||
const entities = [
|
||||
{ name: "company", slug: "companies", titlePlural: "Companies", showInSidebar: true, icon: "" },
|
||||
] as EntitySimple[];
|
||||
|
||||
const result = AppSidebar({
|
||||
t,
|
||||
i18n,
|
||||
tenantId: "acme",
|
||||
entities: [],
|
||||
entityGroups: [
|
||||
{
|
||||
slug: "sales",
|
||||
title: "Sales",
|
||||
icon: "",
|
||||
collapsible: true,
|
||||
section: null,
|
||||
entities: [{ entity: entities[0] }],
|
||||
},
|
||||
] as any,
|
||||
appConfiguration: null,
|
||||
});
|
||||
const group = result[0].items?.find((item) => item.id === "ui.nav.app.entityGroup.sales");
|
||||
|
||||
expect(group).toMatchObject({
|
||||
isCollapsible: true,
|
||||
path: "/acme/g/sales",
|
||||
});
|
||||
expect(group?.items?.[0]).toMatchObject({ title: "shared.overview", path: "/acme/g/sales" });
|
||||
});
|
||||
|
||||
it("translates DB-backed labels only when locale keys exist", () => {
|
||||
const t = vi.fn().mockImplementation((v: string) => `translated:${v}`) as any;
|
||||
const i18n = { exists: vi.fn().mockImplementation((value: string) => value === "models.contact.plural" || value === "groups.sales") } as any;
|
||||
const entities = [
|
||||
{ name: "contact", slug: "contacts", titlePlural: "models.contact.plural", showInSidebar: true, icon: "" },
|
||||
{ name: "custom", slug: "custom", titlePlural: "Custom records", showInSidebar: true, icon: "" },
|
||||
] as EntitySimple[];
|
||||
|
||||
const result = AppSidebar({
|
||||
t,
|
||||
i18n,
|
||||
tenantId: "acme",
|
||||
entities,
|
||||
entityGroups: [
|
||||
{
|
||||
slug: "sales",
|
||||
title: "groups.sales",
|
||||
icon: "",
|
||||
collapsible: true,
|
||||
section: null,
|
||||
entities: [{ entity: entities[0] }],
|
||||
},
|
||||
] as any,
|
||||
appConfiguration: null,
|
||||
});
|
||||
const serialized = JSON.stringify(result);
|
||||
|
||||
expect(serialized).toContain("translated:models.contact.plural");
|
||||
expect(serialized).toContain("translated:groups.sales");
|
||||
expect(serialized).toContain("Custom records");
|
||||
expect(serialized).not.toContain('"models.contact.plural"');
|
||||
expect(serialized).not.toContain('"groups.sales"');
|
||||
});
|
||||
|
||||
it("keeps static tenant sidebar targets backed by registered route files", () => {
|
||||
const t = vi.fn().mockImplementation((v: string) => v) as any;
|
||||
const i18n = { exists: vi.fn().mockReturnValue(false) } as any;
|
||||
const result = AppSidebar({ t, i18n, tenantId: "acme", entities: [], entityGroups: [], appConfiguration: null, productAccess: businessProductAccess });
|
||||
const result = AppSidebar({ t, i18n, tenantId: "acme", appConfiguration: null, productAccess: businessProductAccess });
|
||||
const serialized = JSON.stringify(result);
|
||||
|
||||
expect(serialized).toContain("/acme/dashboard");
|
||||
expect(serialized).toContain("/acme/notifications");
|
||||
expect(serialized).toContain("/acme/crm");
|
||||
expect(serialized).toContain("/acme/contacts");
|
||||
expect(serialized).toContain("/acme/projects");
|
||||
expect(serialized).toContain("/acme/automations");
|
||||
expect(serialized).toContain("/acme/email-marketing");
|
||||
expect(serialized).toContain("/acme/workflow-engine");
|
||||
expect(serialized).toContain("/acme/settings/api");
|
||||
expect(serialized).toContain("/acme/settings/credits");
|
||||
expect(serialized).not.toContain("/acme/settings/credits");
|
||||
expect(serialized).toContain("/acme/settings");
|
||||
expect(serialized).toContain("/acme/settings/profile");
|
||||
expect(serialized).not.toContain("/app/");
|
||||
@@ -217,11 +151,14 @@ describe("AppSidebar", () => {
|
||||
[
|
||||
"apps/web/app/routes/app.$tenant/dashboard.tsx",
|
||||
"apps/web/app/routes/app.$tenant/notifications.tsx",
|
||||
"apps/web/app/routes/app.$tenant/crm.tsx",
|
||||
"apps/web/app/routes/app.$tenant/contacts._index.tsx",
|
||||
"apps/web/app/routes/app.$tenant/projects._index.tsx",
|
||||
"apps/web/app/routes/app.$tenant/automations._index.tsx",
|
||||
"apps/web/app/routes/app.$tenant/automations.$id.edit.tsx",
|
||||
"apps/web/app/routes/app.$tenant/automations.templates._index.tsx",
|
||||
"apps/web/app/routes/app.$tenant/email-marketing.tsx",
|
||||
"apps/web/app/routes/app.$tenant/__workflows/workflow-engine.tsx",
|
||||
"apps/web/app/routes/app.$tenant/settings/api/index.tsx",
|
||||
"apps/web/app/routes/app.$tenant/settings/credits.tsx",
|
||||
"apps/web/app/routes/app.$tenant/settings.tsx",
|
||||
"apps/web/app/routes/app.$tenant/settings/profile.tsx",
|
||||
].forEach((routeFile) => {
|
||||
|
||||
+136
-100
@@ -1,7 +1,5 @@
|
||||
import { SideBarItem } from "./SidebarItem";
|
||||
import { EntitySimple } from "~/utils/db/entities/entities.db.server";
|
||||
import { TFunction, type i18n as I18n } from "i18next";
|
||||
import { EntityGroupWithDetails } from "~/utils/db/entities/entityGroups.db.server";
|
||||
import { AppConfiguration } from "~/utils/db/appConfiguration.db.server";
|
||||
import IconSettings from "~/components/layouts/icons/IconSettings";
|
||||
import IconDashboard from "~/components/layouts/icons/IconDashboard";
|
||||
@@ -10,46 +8,88 @@ import IconNotifications from "~/components/layouts/icons/IconNotifications";
|
||||
import IconEmails from "~/components/layouts/icons/IconEmails";
|
||||
import IconKeys from "~/components/layouts/icons/IconKeys";
|
||||
import IconWorkflows from "~/components/layouts/icons/IconWorkflows";
|
||||
import CreditsIcon from "~/components/ui/icons/CreditsIcon";
|
||||
import AddressBookIcon from "~/components/ui/icons/crm/AddressBookIcon";
|
||||
import IconDocs from "~/components/layouts/icons/IconDocs";
|
||||
import ViewListIcon from "~/components/ui/icons/ViewListIcon";
|
||||
import { UI_ID_PATTERNS, UI_NAV_IDS, uiIdSegment } from "~/application/ui/uiRegistry";
|
||||
import CalendarIcon from "~/components/ui/icons/CalendarIcon";
|
||||
import { UI_NAV_IDS } from "~/application/ui/uiRegistry";
|
||||
import { appPath } from "~/utils/app/CanonicalUrlUtils";
|
||||
import { absoluteAdminPath, type PublicDomainRoutingConfig } from "~/utils/app/CrossHostUrls";
|
||||
import { getEntityPermission } from "~/utils/helpers/PermissionsHelper";
|
||||
import { translateLabel } from "~/utils/i18n/translateLabel";
|
||||
import { resolveConnectorNavState } from "~/utils/connector/connectorNavState";
|
||||
import { WALKING_SKELETON_MODULE_KEY } from "~/modules/walkingSkeleton/constants";
|
||||
import { SearchIcon } from "~/components/ui/icons/vendor";
|
||||
|
||||
type Props = {
|
||||
t: TFunction;
|
||||
i18n: I18n;
|
||||
tenantId: string;
|
||||
entities: EntitySimple[];
|
||||
entityGroups: EntityGroupWithDetails[];
|
||||
appConfiguration: AppConfiguration | null;
|
||||
routing?: PublicDomainRoutingConfig;
|
||||
productAccess?: Record<string, { allowed: boolean; reason?: string }>;
|
||||
};
|
||||
|
||||
export const AppSidebar = ({ t, i18n, tenantId, entities, entityGroups, routing, productAccess }: Props): SideBarItem[] => {
|
||||
export const AppSidebar = ({ t, tenantId, routing, productAccess }: Props): SideBarItem[] => {
|
||||
const tenantPath = (path?: string) => appPath({ tenantSlug: tenantId, path, mode: "host-aware" });
|
||||
const hasFeatureAccess = (featureKey: string) => productAccess?.[featureKey]?.allowed === true;
|
||||
const hasDashboardAccess = productAccess ? hasFeatureAccess("dashboard") : true;
|
||||
// R-P1c Konnektor-Demo: Walking-Skeleton-Eintrag zeigt die drei Gate-Zustaende (aktiv/gesperrt/ausgeblendet).
|
||||
const walkingSkeletonDecision = productAccess?.[WALKING_SKELETON_MODULE_KEY];
|
||||
const walkingSkeletonState = walkingSkeletonDecision ? resolveConnectorNavState(walkingSkeletonDecision) : "hidden";
|
||||
|
||||
const sectionItems: SideBarItem[] = [];
|
||||
const entitiesItems: SideBarItem[] = [];
|
||||
const productCoreItems: SideBarItem[] = [
|
||||
...(hasFeatureAccess("search")
|
||||
? [
|
||||
{
|
||||
id: UI_NAV_IDS.appSearch,
|
||||
title: t("search.nav.title"),
|
||||
path: tenantPath("search"),
|
||||
icon: <SearchIcon />,
|
||||
permission: "search.use" as const,
|
||||
},
|
||||
]
|
||||
: []),
|
||||
...(hasFeatureAccess("automation")
|
||||
? [
|
||||
{
|
||||
id: UI_NAV_IDS.appAutomation,
|
||||
title: t("automation.nav.title"),
|
||||
path: tenantPath("automations"),
|
||||
icon: <IconWorkflows />,
|
||||
permission: "automation.read" as const,
|
||||
},
|
||||
]
|
||||
: []),
|
||||
...(hasFeatureAccess("crm-basic")
|
||||
? [
|
||||
{
|
||||
id: UI_NAV_IDS.appCrm,
|
||||
title: t("crm:title"),
|
||||
path: tenantPath("crm"),
|
||||
// R-P6: typed CRM contacts replace the entity-builder CRM (/crm → /contacts).
|
||||
path: tenantPath("contacts"),
|
||||
icon: <AddressBookIcon />,
|
||||
permission: "crm.read_own" as const,
|
||||
},
|
||||
]
|
||||
: []),
|
||||
...(hasFeatureAccess("leads")
|
||||
? [
|
||||
{
|
||||
id: UI_NAV_IDS.appLeads,
|
||||
title: t("leads.nav.title"),
|
||||
path: tenantPath("leads"),
|
||||
icon: <ViewListIcon />,
|
||||
permission: "leads.read_own" as const,
|
||||
},
|
||||
]
|
||||
: []),
|
||||
...(hasFeatureAccess("projects")
|
||||
? [
|
||||
{
|
||||
id: UI_NAV_IDS.appProjects,
|
||||
title: t("projects.nav.title"),
|
||||
path: tenantPath("projects"),
|
||||
icon: <ViewListIcon />,
|
||||
permission: "projects.read_own" as const,
|
||||
},
|
||||
]
|
||||
: []),
|
||||
@@ -75,6 +115,78 @@ export const AppSidebar = ({ t, i18n, tenantId, entities, entityGroups, routing,
|
||||
},
|
||||
]
|
||||
: []),
|
||||
...(hasFeatureAccess("hr")
|
||||
? [
|
||||
{
|
||||
id: "ui.nav.app.hr",
|
||||
title: t("hr.nav.title"),
|
||||
path: tenantPath("hr"),
|
||||
icon: <AddressBookIcon />,
|
||||
permission: "hr.read_own" as const,
|
||||
},
|
||||
]
|
||||
: []),
|
||||
...(hasFeatureAccess("integrations")
|
||||
? [
|
||||
{
|
||||
id: "ui.nav.app.integrations",
|
||||
title: t("integrations.nav.title"),
|
||||
path: tenantPath("integrations"),
|
||||
icon: <IconWorkflows />,
|
||||
permission: "integrations.read" as const,
|
||||
},
|
||||
]
|
||||
: []),
|
||||
...(hasFeatureAccess("integrations")
|
||||
? [
|
||||
{
|
||||
// AK-P16a · calendar reuses the integrations feature gate (it is an
|
||||
// Apps-Engine integration); the entry is gated by calendar.connect_own.
|
||||
id: UI_NAV_IDS.appCalendar,
|
||||
title: t("calendar.nav.title"),
|
||||
path: tenantPath("calendar"),
|
||||
icon: <CalendarIcon />,
|
||||
permission: "calendar.connect_own" as const,
|
||||
},
|
||||
]
|
||||
: []),
|
||||
...(hasFeatureAccess("email-inbox")
|
||||
? [
|
||||
{
|
||||
// VA-P23 · mailbox sync inbox — own `email-inbox` feature gate; the
|
||||
// entry is gated by email.read_own (own-mailbox visibility, M09 I).
|
||||
id: UI_NAV_IDS.appEmails,
|
||||
title: t("emailInbox.nav.title"),
|
||||
path: tenantPath("emails"),
|
||||
icon: <IconEmails className="h-5 w-5" />,
|
||||
permission: "email.read_own" as const,
|
||||
},
|
||||
]
|
||||
: []),
|
||||
...(hasFeatureAccess("booking")
|
||||
? [
|
||||
{
|
||||
// AK-P16b · Booking module — own `booking` feature gate; the entry is
|
||||
// gated by bookings.read_own (every provider can see their own bookings).
|
||||
id: UI_NAV_IDS.appBookings,
|
||||
title: t("bookings.nav.title"),
|
||||
path: tenantPath("bookings"),
|
||||
icon: <CalendarIcon />,
|
||||
permission: "bookings.read_own" as const,
|
||||
},
|
||||
]
|
||||
: []),
|
||||
...(hasFeatureAccess("forms")
|
||||
? [
|
||||
{
|
||||
id: UI_NAV_IDS.appForms,
|
||||
title: t("settings.forms.admin.title"),
|
||||
path: tenantPath("forms"),
|
||||
icon: <ViewListIcon />,
|
||||
permission: "forms.basic" as const,
|
||||
},
|
||||
]
|
||||
: []),
|
||||
...(hasFeatureAccess("email-marketing")
|
||||
? [
|
||||
{
|
||||
@@ -105,16 +217,6 @@ export const AppSidebar = ({ t, i18n, tenantId, entities, entityGroups, routing,
|
||||
},
|
||||
]
|
||||
: []),
|
||||
...(hasFeatureAccess("ai-credits")
|
||||
? [
|
||||
{
|
||||
id: UI_NAV_IDS.appCredits,
|
||||
title: t("models.credit.plural"),
|
||||
path: tenantPath("settings/credits"),
|
||||
icon: <CreditsIcon />,
|
||||
},
|
||||
]
|
||||
: []),
|
||||
...(walkingSkeletonState !== "hidden"
|
||||
? [
|
||||
{
|
||||
@@ -128,87 +230,23 @@ export const AppSidebar = ({ t, i18n, tenantId, entities, entityGroups, routing,
|
||||
: []),
|
||||
];
|
||||
|
||||
entityGroups.forEach((group) => {
|
||||
const item: SideBarItem = {
|
||||
id: `ui.nav.app.entityGroup.${uiIdSegment(group.slug)}`,
|
||||
uiIdPattern: UI_ID_PATTERNS.appEntityGroup,
|
||||
uiIdParams: { groupSlug: group.slug },
|
||||
title: translateLabel(t, i18n, group.title),
|
||||
// icon: group.icon,
|
||||
path: tenantPath(`g/${group.slug}`),
|
||||
icon: group.icon,
|
||||
// isActive: true,
|
||||
};
|
||||
if (group.collapsible) {
|
||||
item.isCollapsible = true;
|
||||
item.items = [
|
||||
{
|
||||
id: `ui.nav.app.entityGroup.${uiIdSegment(group.slug)}.overview`,
|
||||
title: t("shared.overview"),
|
||||
path: tenantPath(`g/${group.slug}`),
|
||||
},
|
||||
...group.entities.map(({ entity }) => {
|
||||
return {
|
||||
id: `ui.nav.app.entityGroup.${uiIdSegment(group.slug)}.entity.${uiIdSegment(entity.slug)}`,
|
||||
uiIdPattern: UI_ID_PATTERNS.appEntityGroupEntity,
|
||||
uiIdParams: { groupSlug: group.slug, entityName: entity.name ?? entity.slug },
|
||||
title: translateLabel(t, i18n, entity.titlePlural),
|
||||
// icon: entity.icon,
|
||||
path: tenantPath(`g/${group.slug}/${entity.slug}`),
|
||||
permission: getEntityPermission(entity, "view"),
|
||||
// entityIcon: entity.icon,
|
||||
};
|
||||
}),
|
||||
];
|
||||
}
|
||||
if (group.section) {
|
||||
const sectionTitle = translateLabel(t, i18n, group.section);
|
||||
const section = sectionItems.find((f) => f.title === sectionTitle);
|
||||
if (section) {
|
||||
section.items = [...(section.items ?? []), item];
|
||||
} else {
|
||||
sectionItems.push({
|
||||
id: `ui.nav.app.section.${uiIdSegment(group.section)}`,
|
||||
uiIdPattern: UI_ID_PATTERNS.appSection,
|
||||
uiIdParams: { sectionName: group.section },
|
||||
title: sectionTitle,
|
||||
path: ``,
|
||||
items: [item],
|
||||
});
|
||||
}
|
||||
} else {
|
||||
entitiesItems.push(item);
|
||||
}
|
||||
});
|
||||
|
||||
entities
|
||||
.filter((f) => f.showInSidebar)
|
||||
.forEach((entity) => {
|
||||
entitiesItems.push({
|
||||
id: `ui.nav.app.entity.${uiIdSegment(entity.slug)}`,
|
||||
uiIdPattern: UI_ID_PATTERNS.appEntity,
|
||||
uiIdParams: { entityName: entity.name ?? entity.slug, entitySlug: entity.slug },
|
||||
title: translateLabel(t, i18n, entity.titlePlural),
|
||||
icon: entity.icon,
|
||||
// tenantUserTypes: [TenantUserType.OWNER, TenantUserType.ADMIN],
|
||||
path: tenantPath(entity.slug),
|
||||
permission: getEntityPermission(entity, "view"),
|
||||
// side: isDebugMode && SideText({ text: modelProperties.length > 0 ? "DB Model" : "Custom" }),
|
||||
});
|
||||
});
|
||||
|
||||
const appItem: SideBarItem = {
|
||||
id: "ui.nav.app.primary",
|
||||
title: "",
|
||||
path: "",
|
||||
items: [
|
||||
{
|
||||
id: UI_NAV_IDS.appDashboard,
|
||||
title: t("app.sidebar.dashboard"),
|
||||
path: tenantPath("dashboard"),
|
||||
icon: <IconDashboard />,
|
||||
// tenantUserTypes: [TenantUserType.OWNER, TenantUserType.ADMIN, TenantUserType.MEMBER],
|
||||
},
|
||||
...(hasDashboardAccess
|
||||
? [
|
||||
{
|
||||
id: UI_NAV_IDS.appDashboard,
|
||||
title: t("app.sidebar.dashboard"),
|
||||
path: tenantPath("dashboard"),
|
||||
icon: <IconDashboard />,
|
||||
permission: "dashboard.read" as const,
|
||||
// tenantUserTypes: [TenantUserType.OWNER, TenantUserType.ADMIN, TenantUserType.MEMBER],
|
||||
},
|
||||
]
|
||||
: []),
|
||||
{
|
||||
id: UI_NAV_IDS.appNotifications,
|
||||
title: t("app.sidebar.notifications"),
|
||||
@@ -216,7 +254,6 @@ export const AppSidebar = ({ t, i18n, tenantId, entities, entityGroups, routing,
|
||||
icon: <IconNotifications />,
|
||||
},
|
||||
...productCoreItems,
|
||||
...entitiesItems,
|
||||
// {
|
||||
// title: t("models.email.plural"),
|
||||
// path: `${currentTenantUrl}/emails`,
|
||||
@@ -227,7 +264,6 @@ export const AppSidebar = ({ t, i18n, tenantId, entities, entityGroups, routing,
|
||||
|
||||
return [
|
||||
appItem,
|
||||
...sectionItems,
|
||||
{
|
||||
id: "ui.nav.app.secondary",
|
||||
title: "",
|
||||
|
||||
+8
-31
@@ -3,8 +3,7 @@ import { AdminSidebar } from "./AdminSidebar";
|
||||
import { AppSidebar } from "./AppSidebar";
|
||||
import { DocsSidebar } from "./DocsSidebar";
|
||||
import type { SideBarItem } from "./SidebarItem";
|
||||
import type { EntitySimple } from "~/utils/db/entities/entities.db.server";
|
||||
import { UI_ID_PATTERNS, UI_NAV_IDS, UI_SURFACE_IDS } from "~/application/ui/uiRegistry";
|
||||
import { UI_NAV_IDS, UI_SURFACE_IDS } from "~/application/ui/uiRegistry";
|
||||
|
||||
function flattenSidebarItems(items: SideBarItem[]): SideBarItem[] {
|
||||
return items.flatMap((item) => [item, ...flattenSidebarItems(item.items ?? [])]);
|
||||
@@ -48,44 +47,22 @@ describe("sidebar UI IDs", () => {
|
||||
expectStaticItemsHaveIds(sidebar);
|
||||
expect(ids).toContain(UI_NAV_IDS.adminDashboard);
|
||||
expect(ids).toContain(UI_NAV_IDS.adminSettings);
|
||||
expect(ids).toContain(UI_NAV_IDS.adminEntities);
|
||||
});
|
||||
|
||||
it("assigns unique IDs to app sidebar static and dynamic items", () => {
|
||||
const entities = [
|
||||
{ id: "1", order: 1, name: "contacts", slug: "contacts", title: "Contact", titlePlural: "Contacts", active: true, type: "custom", hasApi: true, showInSidebar: true, icon: "", onEdit: null },
|
||||
{ id: "2", order: 2, name: "hidden", slug: "hidden", title: "Hidden", titlePlural: "Hidden", active: true, type: "custom", hasApi: true, showInSidebar: false, icon: "", onEdit: null },
|
||||
] as EntitySimple[];
|
||||
const sidebar = AppSidebar({
|
||||
t,
|
||||
i18n,
|
||||
tenantId: "acme",
|
||||
entities,
|
||||
entityGroups: [
|
||||
{
|
||||
slug: "sales",
|
||||
title: "Sales",
|
||||
icon: "",
|
||||
collapsible: true,
|
||||
section: "Operations",
|
||||
entities: [{ entity: entities[0] }],
|
||||
},
|
||||
] as any,
|
||||
appConfiguration: null,
|
||||
});
|
||||
it("assigns unique IDs to app sidebar static items", () => {
|
||||
// R-P6B-β (AD-2): the generic entity-builder is gone, so AppSidebar no longer
|
||||
// renders dynamic per-entity / entity-group items.
|
||||
const sidebar = AppSidebar({ t, i18n, tenantId: "acme", appConfiguration: null });
|
||||
const ids = flattenSidebarItems(sidebar).map((item) => item.id);
|
||||
const dynamicEntity = flattenSidebarItems(sidebar).find((item) => item.id === "ui.nav.app.entity.contacts");
|
||||
|
||||
expectCompleteUniqueIds(sidebar);
|
||||
expectStaticItemsHaveIds(sidebar);
|
||||
expectDynamicItemsHavePatternMetadata(sidebar);
|
||||
expect(ids).toContain(UI_NAV_IDS.appDashboard);
|
||||
expect(ids).toContain(UI_NAV_IDS.appSettings);
|
||||
expect(ids).toContain("ui.nav.app.entity.contacts");
|
||||
expect(ids).toContain("ui.nav.app.entityGroup.sales");
|
||||
expect(ids).toContain("ui.nav.app.section.operations");
|
||||
expect(dynamicEntity?.uiIdPattern).toBe(UI_ID_PATTERNS.appEntity);
|
||||
expect(dynamicEntity?.uiIdParams).toMatchObject({ entityName: "contacts", entitySlug: "contacts" });
|
||||
expect(ids).not.toContain("ui.nav.app.entity.contacts");
|
||||
expect(ids.some((id) => id?.startsWith("ui.nav.app.entity."))).toBe(false);
|
||||
expect(ids.some((id) => id?.startsWith("ui.nav.app.entityGroup."))).toBe(false);
|
||||
});
|
||||
|
||||
it("assigns unique IDs to docs sidebar items", () => {
|
||||
|
||||
+58
@@ -0,0 +1,58 @@
|
||||
import { readFileSync } from "node:fs";
|
||||
import { resolve } from "node:path";
|
||||
import { describe, expect, test } from "vitest";
|
||||
import { featureKeys, type FeatureKey } from "@hivegrid/entitlements";
|
||||
|
||||
// Registry gate for a recurring footgun: AppSidebar gates entries via
|
||||
// hasFeatureAccess("<key>"), but productAccess is only resolved for the keys in
|
||||
// appData.ts tenantNavigationFeatureKeys. A key used in the sidebar but missing
|
||||
// from that list silently hides the entry for ALL tenants/plans (happened to
|
||||
// files+tasks → fixed in 1017cf58b, then again to dashboard/automation/leads/
|
||||
// projects/hr/integrations/email-inbox/booking/forms → fixed 2026-07-07 after
|
||||
// the R-P5 verification). This static contract makes the drift a test failure.
|
||||
|
||||
const sidebarSource = readFileSync(resolve(__dirname, "AppSidebar.tsx"), "utf8");
|
||||
const appDataSource = readFileSync(resolve(__dirname, "../../utils/data/.server/appData.ts"), "utf8");
|
||||
|
||||
function usedSidebarFeatureKeys(): string[] {
|
||||
const keys = new Set<string>();
|
||||
for (const match of sidebarSource.matchAll(/hasFeatureAccess\("([^"]+)"\)/g)) {
|
||||
keys.add(match[1]);
|
||||
}
|
||||
return [...keys].sort();
|
||||
}
|
||||
|
||||
function resolvedNavigationFeatureKeys(): string[] {
|
||||
const listMatch = appDataSource.match(/const tenantNavigationFeatureKeys = \[([\s\S]*?)\]/);
|
||||
if (!listMatch) {
|
||||
throw new Error("tenantNavigationFeatureKeys list not found in appData.ts");
|
||||
}
|
||||
const keys = new Set<string>();
|
||||
for (const match of listMatch[1].matchAll(/featureKeys\.(\w+)/g)) {
|
||||
const value = featureKeys[match[1] as keyof typeof featureKeys];
|
||||
if (!value) {
|
||||
throw new Error(`Unknown featureKeys entry in tenantNavigationFeatureKeys: ${match[1]}`);
|
||||
}
|
||||
keys.add(value);
|
||||
}
|
||||
return [...keys].sort();
|
||||
}
|
||||
|
||||
describe("sidebar feature-access registry contract", () => {
|
||||
test("every hasFeatureAccess key used by AppSidebar is resolved in appData", () => {
|
||||
const used = usedSidebarFeatureKeys();
|
||||
const resolved = resolvedNavigationFeatureKeys();
|
||||
expect(used.length).toBeGreaterThan(0);
|
||||
const missing = used.filter((key) => !resolved.includes(key));
|
||||
expect(
|
||||
missing,
|
||||
`AppSidebar gates on feature keys that appData.ts tenantNavigationFeatureKeys does not resolve — those sidebar entries are invisible for every tenant. Add them to the list: ${missing.join(", ")}`
|
||||
).toEqual([]);
|
||||
});
|
||||
|
||||
test("all sidebar gate keys are valid entitlement feature keys", () => {
|
||||
const validValues = new Set<string>(Object.values(featureKeys));
|
||||
const invalid = usedSidebarFeatureKeys().filter((key) => !validValues.has(key as FeatureKey));
|
||||
expect(invalid, `AppSidebar uses gate keys that are no entitlement feature keys: ${invalid.join(", ")}`).toEqual([]);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user