Update hivegrid-cloud reference to latest main

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
davidandClaude Fable 5 committed 2026-07-08 16:15:37 +02:00
1 parent e98d38e716
commit 7b21524c86
3781 files changed
+373484 -225607

No files matched your search

@@ -6,11 +6,14 @@ const dbMock = vi.hoisted(() => ({
rolePermission: { findFirst: vi.fn(), create: vi.fn() },
}));
vi.mock("~/utils/db.server", () => ({ db: dbMock, dbRead: dbMock }));
const configMock = vi.hoisted(() => ({ nodeEnv: "test" }));
vi.mock("@hivegrid/config", () => ({ loadWebConfig: () => ({ config: { nodeEnv: configMock.nodeEnv } }) }));
import { SHK_ROLE_NAMES, SHK_ROLE_SEEDS, seedShkRolesForTenant } from "./shkRoles.server";
import { SHK_ROLE_NAMES, SHK_ROLE_SEEDS, seedShkRolesForTenant, shouldSeedShkRoles } from "./shkRoles.server";
beforeEach(() => {
vi.clearAllMocks();
configMock.nodeEnv = "test";
});
describe("SHK role definitions", () => {
@@ -26,6 +29,36 @@ describe("SHK role definitions", () => {
});
});
describe("shouldSeedShkRoles (production seeds admin-only)", () => {
it("skips the SHK seeds on production by default (David's D-P2 decision)", () => {
configMock.nodeEnv = "production";
expect(shouldSeedShkRoles({})).toBe(false);
});
it("seeds on staging (SENTRY_ENVIRONMENT wins over NODE_ENV=production) and local dev", () => {
// Staging containers run NODE_ENV=production — the deploy-scoped env var decides.
configMock.nodeEnv = "production";
expect(shouldSeedShkRoles({ SENTRY_ENVIRONMENT: "staging" })).toBe(true);
configMock.nodeEnv = "development";
expect(shouldSeedShkRoles({})).toBe(true);
});
it("lets SEED_SHK_ROLES override in both directions", () => {
configMock.nodeEnv = "production";
expect(shouldSeedShkRoles({ SEED_SHK_ROLES: "true" })).toBe(true);
configMock.nodeEnv = "test";
expect(shouldSeedShkRoles({ SEED_SHK_ROLES: "false" })).toBe(false);
});
it("makes seedShkRolesForTenant a no-op on production", async () => {
configMock.nodeEnv = "production";
const result = await seedShkRolesForTenant("t1");
expect(result).toEqual({ createdRoles: 0 });
expect(dbMock.permission.findMany).not.toHaveBeenCalled();
expect(dbMock.role.create).not.toHaveBeenCalled();
});
});
describe("seedShkRolesForTenant", () => {
it("creates the missing roles as tenant-scoped app roles and links resolvable permissions", async () => {
dbMock.permission.findMany.mockResolvedValue([{ id: "perm_dash", name: "app.dashboard.view" }]);