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
+68
-17
@@ -16,7 +16,7 @@ const dbMock = {
|
||||
id: `tenant-${where.slug}`,
|
||||
slug: where.slug,
|
||||
name: where.slug,
|
||||
...(include ? { subscription: { id: `subscription-${where.slug}`, products: [] } } : {}),
|
||||
...(include ? { subscription: { id: `subscription-${where.slug}`, lastInvoiceExternalId: null, lastPaymentExternalId: null, products: [] } } : {}),
|
||||
})),
|
||||
create: vi.fn(),
|
||||
update: vi.fn(),
|
||||
@@ -34,7 +34,7 @@ const dbMock = {
|
||||
create: vi.fn(),
|
||||
},
|
||||
subscriptionProduct: {
|
||||
findFirst: vi.fn(async ({ where }: { where: { stripeId: string } }) => ({ id: `product-${where.stripeId}` })),
|
||||
findFirst: vi.fn(async ({ where }: { where: { billingProviderId: string } }) => ({ id: `product-${where.billingProviderId}` })),
|
||||
},
|
||||
tenantSubscriptionProduct: {
|
||||
create: vi.fn(),
|
||||
@@ -92,6 +92,9 @@ const dbMock = {
|
||||
supportTicket: {
|
||||
upsert: vi.fn(),
|
||||
},
|
||||
app: {
|
||||
upsert: vi.fn(),
|
||||
},
|
||||
};
|
||||
|
||||
const hashMock = vi.fn(async () => "hashed-password");
|
||||
@@ -109,12 +112,12 @@ vi.mock("~/utils/logger.server", () => ({
|
||||
}));
|
||||
|
||||
vi.mock("bcryptjs", () => ({ default: { genSalt: genSaltMock, hash: hashMock } }));
|
||||
vi.mock("@toolctrl/db/entitlements-seed.server", () => ({
|
||||
getEntitlementPlanStripeId: ({ id }: { id: string }) => `toolctrl_entitlement_plan_${id}`,
|
||||
vi.mock("@hivegrid/db/entitlements-seed.server", () => ({
|
||||
getEntitlementPlanBillingProviderId: ({ id }: { id: string }) => `hivegrid_entitlement_plan_${id}`,
|
||||
seedStandardEntitlements: seedStandardEntitlementsMock,
|
||||
}));
|
||||
vi.mock("@toolctrl/db/seed.server", async () => {
|
||||
const actual = await vi.importActual<typeof import("@toolctrl/db/seed.server")>("@toolctrl/db/seed.server");
|
||||
vi.mock("@hivegrid/db/seed.server", async () => {
|
||||
const actual = await vi.importActual<typeof import("@hivegrid/db/seed.server")>("@hivegrid/db/seed.server");
|
||||
return actual;
|
||||
});
|
||||
vi.mock("~/utils/services/emailService", () => ({ getAvailableTenantInboundAddress: vi.fn(async () => "seed@example.test") }));
|
||||
@@ -245,26 +248,23 @@ describe("SeedService", () => {
|
||||
expect(dbMock.tenant.findUnique).toHaveBeenCalledWith({ where: { slug: "demo-pro-crm" } });
|
||||
expect(dbMock.tenant.findUnique).toHaveBeenCalledWith({ where: { slug: "demo-business-crm" } });
|
||||
expect(dbMock.subscriptionProduct.findFirst).toHaveBeenCalledWith({
|
||||
where: { stripeId: "toolctrl_entitlement_plan_starter" },
|
||||
where: { billingProviderId: "hivegrid_entitlement_plan_starter" },
|
||||
select: { id: true },
|
||||
});
|
||||
expect(dbMock.subscriptionProduct.findFirst).toHaveBeenCalledWith({
|
||||
where: { stripeId: "toolctrl_entitlement_plan_pro" },
|
||||
where: { billingProviderId: "hivegrid_entitlement_plan_pro" },
|
||||
select: { id: true },
|
||||
});
|
||||
expect(dbMock.subscriptionProduct.findFirst).toHaveBeenCalledWith({
|
||||
where: { stripeId: "toolctrl_entitlement_plan_business" },
|
||||
where: { billingProviderId: "hivegrid_entitlement_plan_business" },
|
||||
select: { id: true },
|
||||
});
|
||||
expect(dbMock.tenantSubscriptionProduct.create).toHaveBeenCalledTimes(3);
|
||||
expect(dbMock.entity.findMany).toHaveBeenCalledWith({
|
||||
where: { name: { in: ["company", "contact", "opportunity"] } },
|
||||
select: { id: true, name: true, type: true },
|
||||
});
|
||||
expect(dbMock.entity.create).toHaveBeenCalledWith(expect.objectContaining({ data: expect.objectContaining({ name: "company", type: "all" }) }));
|
||||
expect(dbMock.entity.create).toHaveBeenCalledWith(expect.objectContaining({ data: expect.objectContaining({ name: "contact", type: "all" }) }));
|
||||
expect(dbMock.entity.create).toHaveBeenCalledWith(expect.objectContaining({ data: expect.objectContaining({ name: "opportunity", type: "all" }) }));
|
||||
expect(dbMock.entity.create).not.toHaveBeenCalledWith(expect.objectContaining({ data: expect.objectContaining({ name: "submission" }) }));
|
||||
// R-P6 (DoD 1 + 6): the legacy entity-builder CRM seed
|
||||
// (ensureProductCoreCrmEntities) was removed from the seed path; demo
|
||||
// tenants now receive the (currently empty) SHK custom-field template
|
||||
// instead, so no `company`/`contact`/`opportunity` Entity rows are created.
|
||||
expect(dbMock.entity.create).not.toHaveBeenCalled();
|
||||
expect(dbMock.tenantProductConfiguration.upsert).toHaveBeenCalledTimes(3);
|
||||
expect(dbMock.knowledgeBase.upsert).toHaveBeenCalledTimes(3);
|
||||
expect(dbMock.supportTicket.upsert).toHaveBeenCalledTimes(6);
|
||||
@@ -274,6 +274,41 @@ describe("SeedService", () => {
|
||||
);
|
||||
});
|
||||
|
||||
it("does not reassign a demo tenant plan after self-service checkout", async () => {
|
||||
process.env.SEED_DEMO_DATA = "true";
|
||||
dbMock.tenant.findUnique.mockImplementation(async ({ where, include }: { where: { slug: string }; include?: unknown }) => ({
|
||||
id: `tenant-${where.slug}`,
|
||||
slug: where.slug,
|
||||
name: where.slug,
|
||||
...(include
|
||||
? {
|
||||
subscription: {
|
||||
id: `subscription-${where.slug}`,
|
||||
lastInvoiceExternalId: where.slug === "demo-pro-crm" ? "hgco_paid_checkout" : null,
|
||||
lastPaymentExternalId: where.slug === "demo-pro-crm" ? "hgco_paid_checkout" : null,
|
||||
products: [],
|
||||
},
|
||||
}
|
||||
: {}),
|
||||
}));
|
||||
const SeedService = await loadSeedService();
|
||||
|
||||
await SeedService.seed();
|
||||
|
||||
expect(dbMock.subscriptionProduct.findFirst).toHaveBeenCalledWith({
|
||||
where: { billingProviderId: "hivegrid_entitlement_plan_starter" },
|
||||
select: { id: true },
|
||||
});
|
||||
expect(dbMock.subscriptionProduct.findFirst).not.toHaveBeenCalledWith({
|
||||
where: { billingProviderId: "hivegrid_entitlement_plan_pro" },
|
||||
select: { id: true },
|
||||
});
|
||||
expect(dbMock.subscriptionProduct.findFirst).toHaveBeenCalledWith({
|
||||
where: { billingProviderId: "hivegrid_entitlement_plan_business" },
|
||||
select: { id: true },
|
||||
});
|
||||
});
|
||||
|
||||
it("refuses demo data in production without the explicit staging override", async () => {
|
||||
process.env.NODE_ENV = "production";
|
||||
process.env.SEED_DEMO_DATA = "true";
|
||||
@@ -341,6 +376,22 @@ describe("SeedService", () => {
|
||||
expect(calls).toEqual(["roles", "entitlements"]);
|
||||
});
|
||||
|
||||
it("upserts the integration catalog into the global App table (R-P5)", async () => {
|
||||
const SeedService = await loadSeedService();
|
||||
const { INTEGRATION_CATALOG } = await import("@hivegrid/integrations");
|
||||
|
||||
await SeedService.seed();
|
||||
|
||||
expect(dbMock.app.upsert).toHaveBeenCalledTimes(INTEGRATION_CATALOG.length);
|
||||
expect(dbMock.app.upsert).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
where: { key: "sample-data-sync" },
|
||||
create: expect.objectContaining({ key: "sample-data-sync", title: "integrations.app.sampleDataSync.title", connectionType: "rest_api", isActive: true }),
|
||||
update: expect.objectContaining({ title: "integrations.app.sampleDataSync.title" }),
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
it("logs redacted DB seed failure diagnostics without raw secret errors", async () => {
|
||||
process.env.SEED_ADMIN_EMAIL = "owner@example.com";
|
||||
process.env.SEED_ADMIN_PASSWORD = "safe-secret-password";
|
||||
|
||||
Reference in new issue
Block a user