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
+75
-3
@@ -15,6 +15,8 @@ import { getTenantIdFromUrl } from "~/utils/services/.server/urlService";
|
||||
import { loadAppData } from "~/utils/data/.server/appData";
|
||||
import { evaluateDashboardModuleGates, type DashboardModuleGateDecision } from "~/services/dashboard-registry/gating.server";
|
||||
import { getDashboardModuleDefinitions, type DashboardModuleDefinition, type DashboardModuleId } from "~/services/dashboard-registry/registry.server";
|
||||
import { loadDashboardVM } from "~/services/dashboard/dashboard.server";
|
||||
import { getFirstStepsChecklist } from "~/utils/services/.server/akP20OnboardingService";
|
||||
|
||||
const translatedT = vi.fn((key: string) => `translated:${key}`);
|
||||
const computedGte = new Date("2026-02-03T04:05:06.000Z");
|
||||
@@ -22,6 +24,47 @@ const tenant = { id: "tenant_1", slug: "acme" };
|
||||
const appData = { mySubscription: { products: [], trial: { active: false, period: "trial-ended" } } };
|
||||
const stats = [{ name: "Contacts", stat: "7", previousStat: "3" }];
|
||||
const dashboardData = { users: 4 };
|
||||
const firstStepsChecklist = {
|
||||
id: "checklist_1",
|
||||
status: "active",
|
||||
dismissed: false,
|
||||
completedCount: 2,
|
||||
totalCount: 4,
|
||||
percentComplete: 50,
|
||||
items: [],
|
||||
};
|
||||
const dashboardVm = {
|
||||
activeRole: "office",
|
||||
generatedAt: "2026-07-01T00:00:00.000Z",
|
||||
streamUrl: "/acme/dashboard.stream?role=office",
|
||||
liveUpdatesEnabled: true,
|
||||
canCustomize: true,
|
||||
roles: [
|
||||
{
|
||||
role: "office",
|
||||
nameKey: "app.dashboard.roles.office.name",
|
||||
descriptionKey: "app.dashboard.roles.office.description",
|
||||
mobileFirst: false,
|
||||
isDefault: true,
|
||||
widgets: [
|
||||
{
|
||||
key: "projects.kpis",
|
||||
titleKey: "app.dashboard.widgets.projectKpis.title",
|
||||
descriptionKey: "app.dashboard.widgets.projectKpis.description",
|
||||
domain: "projects",
|
||||
kind: "kpi",
|
||||
period: "30d",
|
||||
visible: true,
|
||||
loadingMode: "lazy",
|
||||
metrics: [{ labelKey: "app.dashboard.metrics.activeProjects", value: "3" }],
|
||||
items: [],
|
||||
position: { x: 0, y: 1 },
|
||||
size: { w: 4, h: 2 },
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
};
|
||||
const registryModules = getDashboardModuleDefinitions();
|
||||
const getRegistryModule = (moduleId: DashboardModuleId): DashboardModuleDefinition => {
|
||||
const module = registryModules.find((definition) => definition.id === moduleId);
|
||||
@@ -82,6 +125,10 @@ vi.mock("~/utils/data/.server/appData", () => ({
|
||||
loadAppData: vi.fn(),
|
||||
}));
|
||||
|
||||
vi.mock("~/utils/services/.server/akP20OnboardingService", () => ({
|
||||
getFirstStepsChecklist: vi.fn(),
|
||||
}));
|
||||
|
||||
vi.mock("react-router", async () => {
|
||||
const actual = await vi.importActual<typeof import("react-router")>("react-router");
|
||||
return {
|
||||
@@ -98,6 +145,14 @@ vi.mock("~/services/dashboard-registry/gating.server", async (importOriginal) =>
|
||||
};
|
||||
});
|
||||
|
||||
vi.mock("~/services/dashboard/dashboard.server", async (importOriginal) => {
|
||||
const actual = await importOriginal<typeof import("~/services/dashboard/dashboard.server")>();
|
||||
return {
|
||||
...actual,
|
||||
loadDashboardVM: vi.fn(),
|
||||
};
|
||||
});
|
||||
|
||||
vi.mock("~/modules/metrics/utils/defaultHeaders", () => ({
|
||||
serverTimingHeaders: vi.fn(),
|
||||
}));
|
||||
@@ -128,7 +183,7 @@ vi.mock("~/components/ui/errors/ServerError", () => ({
|
||||
}));
|
||||
|
||||
vi.mock("~/utils/data/useAppData", () => ({
|
||||
useAppData: vi.fn(() => ({ user: {}, permissions: ["app.dashboard.view"] })),
|
||||
useAppData: vi.fn(() => ({ user: {}, permissions: ["app.dashboard.view", "dashboard.read", "dashboard.customize"] })),
|
||||
}));
|
||||
|
||||
vi.mock("~/utils/helpers/PermissionsHelper", () => ({
|
||||
@@ -146,15 +201,18 @@ vi.mock("react-i18next", () => ({
|
||||
describe("app tenant dashboard route contract", () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
process.env.APP_NAME = "ToolCTRL";
|
||||
process.env.APP_NAME = "HiveGrid";
|
||||
vi.mocked(getTranslations).mockResolvedValue({ t: translatedT } as never);
|
||||
vi.mocked(getTenantIdFromUrl).mockResolvedValue("tenant_1");
|
||||
vi.mocked(getTenant).mockResolvedValue(tenant as never);
|
||||
vi.mocked(requireAuth).mockResolvedValue({ userId: "user_1" } as never);
|
||||
routeLoaderData = {
|
||||
...dashboardData,
|
||||
dashboard: dashboardVm,
|
||||
stats,
|
||||
modules: [summaryModule],
|
||||
moduleDiagnostics: [],
|
||||
firstStepsChecklist,
|
||||
};
|
||||
moduleDecisions = [
|
||||
{ module: summaryModule, allowed: true },
|
||||
@@ -166,6 +224,8 @@ describe("app tenant dashboard route contract", () => {
|
||||
];
|
||||
vi.mocked(loadAppData).mockResolvedValue(appData as never);
|
||||
vi.mocked(evaluateDashboardModuleGates).mockResolvedValue(moduleDecisions as never);
|
||||
vi.mocked(loadDashboardVM).mockResolvedValue(dashboardVm as never);
|
||||
vi.mocked(getFirstStepsChecklist).mockResolvedValue(firstStepsChecklist as never);
|
||||
vi.mocked(getAppDashboardStats).mockResolvedValue(stats as never);
|
||||
vi.mocked(loadDashboardData).mockResolvedValue(dashboardData as never);
|
||||
vi.mocked(PeriodHelper.getGreaterThanOrEqualsFromRequest).mockReturnValue(computedGte);
|
||||
@@ -190,6 +250,8 @@ describe("app tenant dashboard route contract", () => {
|
||||
expect(PeriodHelper.getGreaterThanOrEqualsFromRequest).toHaveBeenCalledWith({ request });
|
||||
expect(getAppDashboardStats).toHaveBeenCalledWith({ t: translatedT, tenant, gte: computedGte });
|
||||
expect(loadDashboardData).toHaveBeenCalledWith({ request, params });
|
||||
expect(loadDashboardVM).toHaveBeenCalledWith({ request, params });
|
||||
expect(getFirstStepsChecklist).toHaveBeenCalledWith({ tenantId: "tenant_1", userId: "user_1" });
|
||||
expect(evaluateDashboardModuleGates).toHaveBeenCalledWith({
|
||||
request,
|
||||
params,
|
||||
@@ -201,11 +263,13 @@ describe("app tenant dashboard route contract", () => {
|
||||
});
|
||||
expect(vi.mocked(evaluateDashboardModuleGates).mock.calls[0]?.[0].redirectPaths?.plan).toBe("/plan-required/acme");
|
||||
expect(body).toMatchObject({
|
||||
title: "translated:app.sidebar.dashboard | ToolCTRL",
|
||||
title: "translated:app.sidebar.dashboard | HiveGrid",
|
||||
users: 4,
|
||||
dashboard: dashboardVm,
|
||||
stats,
|
||||
modules: [summaryModule],
|
||||
moduleDiagnostics: [moduleDecisions[1].diagnostic],
|
||||
firstStepsChecklist,
|
||||
});
|
||||
expect(body.modules.map((module: DashboardModuleDefinition) => module.id)).toEqual(["summary-stats"]);
|
||||
expect(body.moduleDiagnostics.map((diagnostic: { moduleId: DashboardModuleId }) => diagnostic.moduleId)).toEqual(["priority-insights"]);
|
||||
@@ -237,15 +301,19 @@ describe("app tenant dashboard route contract", () => {
|
||||
expect(screen.getByRole("heading", { name: "app.dashboard.summary" })).toBeInTheDocument();
|
||||
expect(screen.getByText("Contacts")).toBeInTheDocument();
|
||||
expect(screen.getByText("7")).toBeInTheDocument();
|
||||
expect(screen.getByText("onboarding.firstSteps.dashboardTitle")).toBeInTheDocument();
|
||||
expect(screen.getByRole("link", { name: "onboarding.firstSteps.open" })).toHaveAttribute("href", "/onboarding/checklist");
|
||||
expect(screen.queryByText("app.dashboard.moduleDiagnostics.unavailableTitle")).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("omits gated summary content when the summary module is feature-disabled", () => {
|
||||
routeLoaderData = {
|
||||
...dashboardData,
|
||||
dashboard: dashboardVm,
|
||||
stats,
|
||||
modules: [],
|
||||
moduleDiagnostics: [{ moduleId: "summary-stats", source: "feature-flag", reason: "feature-disabled", redirectPath: "/feature-disabled?tenant=acme" }],
|
||||
firstStepsChecklist,
|
||||
};
|
||||
|
||||
render(
|
||||
@@ -264,9 +332,11 @@ describe("app tenant dashboard route contract", () => {
|
||||
it("renders plan-required diagnostics with the safe tenant-aware plan link and no gated module content", () => {
|
||||
routeLoaderData = {
|
||||
...dashboardData,
|
||||
dashboard: dashboardVm,
|
||||
stats,
|
||||
modules: [summaryModule],
|
||||
moduleDiagnostics: [{ moduleId: "priority-insights", source: "plan", reason: "plan-required", redirectPath: "/plan-required/acme" }],
|
||||
firstStepsChecklist,
|
||||
};
|
||||
|
||||
render(
|
||||
@@ -284,11 +354,13 @@ describe("app tenant dashboard route contract", () => {
|
||||
it("renders feature-disabled diagnostics with only the safe fallback link and no gated module content", () => {
|
||||
routeLoaderData = {
|
||||
...dashboardData,
|
||||
dashboard: dashboardVm,
|
||||
stats,
|
||||
modules: [summaryModule],
|
||||
moduleDiagnostics: [
|
||||
{ moduleId: "subscription-health", source: "feature-flag", reason: "feature-disabled", redirectPath: "https://unsafe.example.com/feature" },
|
||||
],
|
||||
firstStepsChecklist,
|
||||
};
|
||||
|
||||
render(
|
||||
|
||||
Reference in new issue
Block a user