Refresh HiveGrid Cloud reference snapshot
This commit is contained in:
1 parent
5e99e14772
commit
7f88026f79
5955 files changed
+1177325
-188362
No files matched your search
@@ -9,27 +9,44 @@ import { entitlementPlanIds } from "@hivegrid/entitlements";
|
||||
import { syncDefaultRolesAndPermissions } from "@hivegrid/db/permissions-seed.server";
|
||||
import { getDbClient, type DbClient } from "@hivegrid/db/client.server";
|
||||
import { deriveLegacyApiKeyHashMetadata } from "@hivegrid/db/api-keys.server";
|
||||
import { syncAdminRoleCatalog } from "@hivegrid/db/admin-rbac.server";
|
||||
import type { PluginManifest } from "@hivegrid/plugin-runtime";
|
||||
import type { SequenceStep } from "@hivegrid/email-sequences";
|
||||
|
||||
export const E2E_READINESS_USER_EMAIL = "e2e.readiness@example.test";
|
||||
export const E2E_READINESS_USER_PASSWORD = "ReadinessPass123!";
|
||||
export const E2E_READINESS_USER_PASSWORD = "password";
|
||||
export const E2E_READINESS_NO_TENANT_EMAIL = "e2e.no-tenant@example.test";
|
||||
export const E2E_READINESS_NO_TENANT_PASSWORD = "NoTenantPass123!";
|
||||
export const E2E_READINESS_NO_TENANT_PASSWORD = "password";
|
||||
export const E2E_READINESS_PLUGIN_READONLY_EMAIL = "e2e.plugin-readonly@example.test";
|
||||
export const E2E_READINESS_PLUGIN_READONLY_PASSWORD = "PluginReadOnlyPass123!";
|
||||
export const E2E_READINESS_PLUGIN_READONLY_PASSWORD = "password";
|
||||
export const E2E_READINESS_PLUGIN_READONLY_ROLE_NAME = "User";
|
||||
// Dedicated operator-admin user for admin-host pages (email sequences, etc.).
|
||||
// The shared tenant user must NOT be an operator admin (it would redirect to the
|
||||
// admin host on login and break every tenant-app login flow), so admin-host
|
||||
// tests log in as this separate user instead. It gets an AdminUser row (so the
|
||||
// admin layout's `user.admin` gate passes) plus the global SuperAdmin role (which
|
||||
// grants `admin.marketing.leads.view`). No TOTP is enrolled, so admin MFA
|
||||
// enforcement allows it straight through.
|
||||
export const E2E_READINESS_ADMIN_EMAIL = "e2e.admin@example.test";
|
||||
export const E2E_READINESS_ADMIN_PASSWORD = E2E_READINESS_USER_PASSWORD;
|
||||
// Local admin-host flows must use the canonical disposable operator identity
|
||||
// from AGENTS.md. The shared tenant user remains separate so tenant logins never
|
||||
// redirect to the admin host.
|
||||
export const E2E_READINESS_ADMIN_EMAIL = "admin@email.com";
|
||||
export const E2E_READINESS_ADMIN_PASSWORD = "password";
|
||||
export const E2E_READINESS_TENANT_SLUG = "e2e-readiness";
|
||||
export const E2E_READINESS_TENANT_NAME = "E2E Readiness";
|
||||
export const E2E_READINESS_CHAT_ID = "chat_e2e_readiness";
|
||||
export const E2E_READINESS_CHAT_NAME = "E2E Readiness Team Chat";
|
||||
export const E2E_READINESS_CHAT_EVENT_STREAM_ID = "chat_stream_e2e_readiness";
|
||||
export const E2E_READINESS_CHAT_MEMBER_ID = "chat_member_e2e_readiness";
|
||||
export const E2E_READINESS_CHAT_PEER_MEMBER_ID = "chat_peer_member_e2e_readiness";
|
||||
export const E2E_READINESS_PIPELINE_ID = "pipeline_e2e_readiness";
|
||||
export const E2E_READINESS_PIPELINE_NAME = "E2E Readiness Projects";
|
||||
export const E2E_READINESS_PIPELINE_STAGES = [
|
||||
{ id: "pipeline_stage_e2e_readiness_open", name: "Open", stageKind: "offen", winProbability: 20, color: "#64748b" },
|
||||
{ id: "pipeline_stage_e2e_readiness_won", name: "Won", stageKind: "gewonnen", winProbability: 100, color: "#16a34a" },
|
||||
{ id: "pipeline_stage_e2e_readiness_lost", name: "Lost", stageKind: "verloren", winProbability: 0, color: "#dc2626" },
|
||||
] as const;
|
||||
export const E2E_READINESS_ONBOARDING_ID = "shk-first-steps-v1";
|
||||
export const E2E_READINESS_ONBOARDING_CODE = "shk-first-steps";
|
||||
export const E2E_READINESS_ONBOARDING_STEPS = [
|
||||
{ id: "shk-first-steps-profile-v1", order: 10, block: "profile" },
|
||||
{ id: "shk-first-steps-contacts-v1", order: 20, block: "contacts" },
|
||||
{ id: "shk-first-steps-projects-v1", order: 30, block: "projects" },
|
||||
{ id: "shk-first-steps-billing-v1", order: 40, block: "billing" },
|
||||
] as const;
|
||||
export const E2E_READINESS_WORKFLOW_ID = "wf_123";
|
||||
export const E2E_READINESS_WORKFLOW_NAME = "E2E Readiness Manual Workflow";
|
||||
export const E2E_READINESS_WORKFLOW_EXECUTION_ID = "wfe_123";
|
||||
@@ -46,11 +63,12 @@ export const E2E_READINESS_LIFECYCLE_PLUGIN_ID = "com.hivegrid.e2e-lifecycle";
|
||||
export const E2E_READINESS_LIFECYCLE_PLUGIN_VERSION = "1.0.0";
|
||||
// Must match WORKSPACE_ROLES_FEATURE_FLAG in workspaceRoles.server.ts.
|
||||
export const E2E_READINESS_WORKSPACE_ROLES_FLAG = "workspace-roles";
|
||||
export const E2E_READINESS_PLATFORM_LEAD_SOURCE_ID = "admin_lead_source_e2e_readiness";
|
||||
export const E2E_READINESS_PLATFORM_LEAD_SOURCE_KEY = "e2e-readiness";
|
||||
export const E2E_READINESS_PLATFORM_LEAD_SOURCE_NAME = "E2E Readiness Platform Leads";
|
||||
export const E2E_READINESS_API_KEY_ALIAS = "E2E Readiness API Key";
|
||||
export const E2E_READINESS_API_LOG_ENDPOINT = "/v1/e2e-readiness";
|
||||
export const E2E_READINESS_API_LOG_METHOD = "GET";
|
||||
export const E2E_READINESS_PORTAL_SUBDOMAIN = "e2e-readiness";
|
||||
export const E2E_READINESS_PORTAL_TITLE = "E2E Readiness Portal";
|
||||
export const E2E_READINESS_SUBSCRIPTION_PLAN_BILLING_PROVIDER_ID = "e2e_readiness_plan";
|
||||
export const E2E_READINESS_SUBSCRIPTION_PRICE_BILLING_PROVIDER_ID = "e2e_readiness_price_monthly";
|
||||
export const E2E_READINESS_UPGRADE_PLAN_BILLING_PROVIDER_ID = "e2e_readiness_upgrade_plan";
|
||||
@@ -73,6 +91,7 @@ type EnvRecord = Record<string, string | undefined>;
|
||||
|
||||
type ReadinessFixture = {
|
||||
tenantSlug: string;
|
||||
chatId: string;
|
||||
workflowId: string;
|
||||
webhookWorkflowId: string;
|
||||
waitingWorkflowId: string;
|
||||
@@ -223,33 +242,33 @@ export function buildE2eReadinessEnv(fixture: ReadinessFixture): Record<string,
|
||||
E2E_PLUGIN_READONLY_PASSWORD: E2E_READINESS_PLUGIN_READONLY_PASSWORD,
|
||||
E2E_ADMIN_EMAIL: E2E_READINESS_ADMIN_EMAIL,
|
||||
E2E_ADMIN_PASSWORD: E2E_READINESS_ADMIN_PASSWORD,
|
||||
E2E_ADMIN_PLATFORM_LEADS_PATH: "/leads",
|
||||
E2E_ADMIN_PLATFORM_LEAD_SOURCE_NAME: E2E_READINESS_PLATFORM_LEAD_SOURCE_NAME,
|
||||
E2E_TENANT_ACCOUNT_NAME: E2E_READINESS_TENANT_NAME,
|
||||
E2E_TENANT_ACCOUNT_SLUG: fixture.tenantSlug,
|
||||
E2E_REGISTRATION_EXPECTS_EMAIL_VERIFICATION: "0",
|
||||
E2E_TENANT_DASHBOARD_PATH: appFixturePath(fixture.tenantSlug, "dashboard"),
|
||||
E2E_TENANT_SETTINGS_ACCOUNT_PATH: appFixturePath(fixture.tenantSlug, "settings/account"),
|
||||
E2E_TENANT_CHAT_PATH: appFixturePath(fixture.tenantSlug, `chat/${fixture.chatId}`),
|
||||
E2E_TENANT_SETTINGS_ACCOUNT_PATH: appFixturePath(fixture.tenantSlug, "settings/workspace"),
|
||||
E2E_TENANT_SETTINGS_PROFILE_PATH: appFixturePath(fixture.tenantSlug, "settings/profile"),
|
||||
E2E_TENANT_SUBSCRIPTION_PATH: appFixturePath(fixture.tenantSlug, "settings/subscription"),
|
||||
E2E_TENANT_MEMBERS_PATH: appFixturePath(fixture.tenantSlug, "settings/members"),
|
||||
E2E_TENANT_ROLES_AND_PERMISSIONS_PATH: appFixturePath(fixture.tenantSlug, "settings/roles-and-permissions"),
|
||||
E2E_TENANT_NOTIFICATIONS_PATH: appFixturePath(fixture.tenantSlug, "settings/notifications"),
|
||||
E2E_TENANT_LOGS_PATH: appFixturePath(fixture.tenantSlug, "settings/logs"),
|
||||
E2E_TENANT_LOG_EVENTS_PATH: appFixturePath(fixture.tenantSlug, "settings/logs/events"),
|
||||
E2E_TENANT_AUDIT_EXPORT_PATH: appFixturePath(fixture.tenantSlug, "settings/audit-export"),
|
||||
E2E_TENANT_PRIVACY_PATH: appFixturePath(fixture.tenantSlug, "settings/privacy"),
|
||||
E2E_TENANT_API_PATH: appFixturePath(fixture.tenantSlug, "settings/api"),
|
||||
E2E_TENANT_API_KEYS_PATH: appFixturePath(fixture.tenantSlug, "settings/api/keys"),
|
||||
E2E_TENANT_API_DOCS_PATH: appFixturePath(fixture.tenantSlug, "settings/api/docs"),
|
||||
E2E_TENANT_API_LOGS_PATH: appFixturePath(fixture.tenantSlug, "settings/api/logs"),
|
||||
E2E_TENANT_POLICIES_PATH: appFixturePath(fixture.tenantSlug, "settings/policies"),
|
||||
E2E_TENANT_PORTAL_ANALYTICS_PATH: appFixturePath(fixture.tenantSlug, `portals/${E2E_READINESS_PORTAL_SUBDOMAIN}/analytics`),
|
||||
E2E_TENANT_PORTAL_SETTINGS_PATH: appFixturePath(fixture.tenantSlug, `portals/${E2E_READINESS_PORTAL_SUBDOMAIN}/settings`),
|
||||
E2E_TENANT_SUBSCRIPTION_PATH: appFixturePath(fixture.tenantSlug, "settings/billing"),
|
||||
E2E_TENANT_MEMBERS_PATH: appFixturePath(fixture.tenantSlug, "settings/team"),
|
||||
E2E_TENANT_ROLES_AND_PERMISSIONS_PATH: appFixturePath(fixture.tenantSlug, "settings/team/roles"),
|
||||
E2E_TENANT_NOTIFICATIONS_PATH: appFixturePath(fixture.tenantSlug, "settings/profile/notifications"),
|
||||
E2E_TENANT_LOGS_PATH: appFixturePath(fixture.tenantSlug, "settings/compliance"),
|
||||
E2E_TENANT_LOG_EVENTS_PATH: appFixturePath(fixture.tenantSlug, "settings/compliance/events"),
|
||||
E2E_TENANT_AUDIT_EXPORT_PATH: appFixturePath(fixture.tenantSlug, "settings/compliance/audit-export"),
|
||||
E2E_TENANT_PRIVACY_PATH: appFixturePath(fixture.tenantSlug, "settings/profile/data"),
|
||||
E2E_TENANT_API_PATH: appFixturePath(fixture.tenantSlug, "settings/integrations/api"),
|
||||
E2E_TENANT_API_KEYS_PATH: appFixturePath(fixture.tenantSlug, "settings/integrations/api/keys"),
|
||||
E2E_TENANT_API_LOGS_PATH: appFixturePath(fixture.tenantSlug, "settings/integrations/api/logs"),
|
||||
E2E_TENANT_POLICIES_PATH: appFixturePath(fixture.tenantSlug, "settings/workspace/policies"),
|
||||
// Host-aware deployments serve admin pages on the admin host without the
|
||||
// `/admin` prefix; the app host 308-redirects `/email-sequences` to the admin
|
||||
// host, which page.goto follows (the readiness session cookie spans the
|
||||
// app-base domain). The literal `/admin/email-sequences` is a 404 on the app host.
|
||||
E2E_ADMIN_EMAIL_SEQUENCES_PATH: "/email-sequences",
|
||||
E2E_PLUGIN_SETTINGS_PATH: appFixturePath(fixture.tenantSlug, "settings/plugins"),
|
||||
E2E_PLUGIN_SETTINGS_PATH: appFixturePath(fixture.tenantSlug, "settings/integrations/plugins"),
|
||||
E2E_WORKFLOW_ENGINE_PATH: appFixturePath(fixture.tenantSlug, "workflow-engine/workflows"),
|
||||
E2E_WORKFLOW_BUILDER_PATH: workflowBase,
|
||||
E2E_WORKFLOW_RUN_API_PATH: `${workflowBase}/run/api`,
|
||||
@@ -261,6 +280,9 @@ export function buildE2eReadinessEnv(fixture: ReadinessFixture): Record<string,
|
||||
E2E_WORKFLOW_WAITING_RUN_API_PATH: `${waitingWorkflowBase}/run/api`,
|
||||
E2E_WORKFLOW_WAITING_EXECUTIONS_PATH: `${waitingWorkflowBase}/executions`,
|
||||
E2E_WORKFLOW_WAITING_EXECUTION_ID: fixture.waitingExecutionId,
|
||||
// Message sends mutate the readiness database and need the explicit local
|
||||
// mutating wrapper. Sourcing this file alone must stay non-mutating.
|
||||
E2E_ALLOW_CHAT_SEND: "0",
|
||||
E2E_ALLOW_WORKFLOW_RUN: "1",
|
||||
E2E_ALLOW_WORKFLOW_WEBHOOK_RUN: "0",
|
||||
E2E_WORKFLOW_WEBHOOK_TARGET_URL: "",
|
||||
@@ -445,7 +467,7 @@ export function buildE2eReadinessEmailSequenceDefinitions(tenantId: string | nul
|
||||
headline: "Trial reminder",
|
||||
bodyParagraphs: ["This fixture exercises the trial-expiring sequence path without live provider secrets."],
|
||||
ctaLabel: "Review subscription",
|
||||
ctaUrl: "/e2e-readiness/settings/subscription",
|
||||
ctaUrl: "/e2e-readiness/settings/billing",
|
||||
},
|
||||
},
|
||||
],
|
||||
@@ -491,7 +513,7 @@ export function buildE2eReadinessEmailSequenceDefinitions(tenantId: string | nul
|
||||
headline: "Customer setup",
|
||||
bodyParagraphs: ["This fixture gives the admin sequence dashboard stable conversion-sequence data."],
|
||||
ctaLabel: "Open account",
|
||||
ctaUrl: "/e2e-readiness/settings/account",
|
||||
ctaUrl: "/e2e-readiness/settings/workspace",
|
||||
},
|
||||
},
|
||||
],
|
||||
@@ -510,6 +532,13 @@ async function upsertReadinessUser(db: DbClient, input: { email: string; passwor
|
||||
lastName: input.lastName,
|
||||
active: true,
|
||||
locale: "en",
|
||||
totpSecretEncrypted: null,
|
||||
totpPendingSecretEncrypted: null,
|
||||
totpEnabledAt: null,
|
||||
totpPendingCreatedAt: null,
|
||||
mfaRecoveryCodeHashes: [],
|
||||
mfaRecoveryCodesGeneratedAt: null,
|
||||
mfaRecoveryCodeLastUsedAt: null,
|
||||
},
|
||||
update: {
|
||||
passwordHash,
|
||||
@@ -517,6 +546,16 @@ async function upsertReadinessUser(db: DbClient, input: { email: string; passwor
|
||||
lastName: input.lastName,
|
||||
active: true,
|
||||
locale: "en",
|
||||
// Readiness users are disposable fixtures. Reset MFA state so a failed
|
||||
// browser run cannot leave the next deterministic seed behind a TOTP
|
||||
// challenge whose temporary secret only existed in the previous run.
|
||||
totpSecretEncrypted: null,
|
||||
totpPendingSecretEncrypted: null,
|
||||
totpEnabledAt: null,
|
||||
totpPendingCreatedAt: null,
|
||||
mfaRecoveryCodeHashes: [],
|
||||
mfaRecoveryCodesGeneratedAt: null,
|
||||
mfaRecoveryCodeLastUsedAt: null,
|
||||
},
|
||||
});
|
||||
}
|
||||
@@ -549,8 +588,8 @@ async function seedUserAndTenant(db: DbClient) {
|
||||
// registration) and adds admin-only chrome (a low-contrast "Switch to admin" row) to
|
||||
// the roles page. A prior seed iteration granted it AdminUser + the global SuperAdmin
|
||||
// role, so actively REMOVE both here (stopping the grant is not enough — the rows
|
||||
// persist). Admin-host pages need a separate dedicated admin user.
|
||||
await db.adminUser.deleteMany({ where: { userId: user.id } });
|
||||
// persist). Admin-host pages use the canonical local platform admin instead.
|
||||
await db.adminUser.deleteMany({ where: { email: E2E_READINESS_USER_EMAIL } });
|
||||
const globalSuperAdminRole = await db.role.findFirst({ where: { tenantId: null, name: "SuperAdmin" }, select: { id: true } });
|
||||
if (globalSuperAdminRole) {
|
||||
await db.userRole.deleteMany({ where: { userId: user.id, tenantId: null, roleId: globalSuperAdminRole.id } });
|
||||
@@ -612,9 +651,10 @@ async function seedNoTenantUser(db: DbClient) {
|
||||
}
|
||||
|
||||
async function seedAdminUser(db: DbClient) {
|
||||
// Roles/permissions must exist before we can resolve + grant the global
|
||||
// SuperAdmin role; syncDefaultRolesAndPermissions is idempotent.
|
||||
// Both catalogs must exist before the tenant-app user and the independent
|
||||
// operator identity can receive their respective roles.
|
||||
await syncDefaultRolesAndPermissions({ client: db });
|
||||
await syncAdminRoleCatalog(db);
|
||||
const user = await upsertReadinessUser(db, {
|
||||
email: E2E_READINESS_ADMIN_EMAIL,
|
||||
password: E2E_READINESS_ADMIN_PASSWORD,
|
||||
@@ -626,29 +666,77 @@ async function seedAdminUser(db: DbClient) {
|
||||
// not accumulate the multi-account picker or interfere with the tenant fixtures.
|
||||
await db.user.update({ where: { id: user.id }, data: { defaultTenantId: null } });
|
||||
await db.tenantUser.deleteMany({ where: { userId: user.id } });
|
||||
await db.userRole.deleteMany({ where: { userId: user.id } });
|
||||
|
||||
// AdminUser row makes the admin layout's `user.admin` gate pass.
|
||||
await db.adminUser.upsert({
|
||||
where: { userId: user.id },
|
||||
create: { userId: user.id },
|
||||
update: {},
|
||||
});
|
||||
|
||||
// Global SuperAdmin role grants admin permissions (e.g. admin.marketing.leads.view
|
||||
// for the email-sequences pages).
|
||||
const superAdminRole = await db.role.findFirst({ where: { tenantId: null, name: "SuperAdmin" }, select: { id: true } });
|
||||
if (!superAdminRole) {
|
||||
throw new Error("Global SuperAdmin role is required for the E2E admin fixture.");
|
||||
}
|
||||
const existing = await db.userRole.findFirst({
|
||||
where: { userId: user.id, tenantId: null, roleId: superAdminRole.id },
|
||||
// AdminUser is an independent operator identity. Local password auth bridges
|
||||
// it to the disposable User fixture by normalized email.
|
||||
const adminIdentity = await db.adminUser.upsert({
|
||||
where: { email: E2E_READINESS_ADMIN_EMAIL },
|
||||
create: {
|
||||
id: user.id,
|
||||
email: E2E_READINESS_ADMIN_EMAIL,
|
||||
firstName: "E2E",
|
||||
lastName: "Admin",
|
||||
status: "active",
|
||||
authentikGroups: [],
|
||||
},
|
||||
update: {
|
||||
firstName: "E2E",
|
||||
lastName: "Admin",
|
||||
status: "active",
|
||||
disabledAt: null,
|
||||
disabledReason: null,
|
||||
},
|
||||
select: { id: true },
|
||||
});
|
||||
if (!existing) {
|
||||
await db.userRole.create({ data: { userId: user.id, tenantId: null, roleId: superAdminRole.id } });
|
||||
}
|
||||
|
||||
return user;
|
||||
// The operator SuperAdmin role grants admin permissions (e.g.
|
||||
// admin.marketing.leads.view for the email-sequences pages).
|
||||
const superAdminRole = await db.adminRole.findUnique({ where: { systemKey: "super_admin" }, select: { id: true } });
|
||||
if (!superAdminRole) {
|
||||
throw new Error("Operator SuperAdmin role is required for the E2E admin fixture.");
|
||||
}
|
||||
await db.adminUserRole.deleteMany({
|
||||
where: { adminUserId: adminIdentity.id },
|
||||
});
|
||||
await db.adminUserRole.create({
|
||||
data: {
|
||||
adminUserId: adminIdentity.id,
|
||||
adminRoleId: superAdminRole.id,
|
||||
grantedByAdminUserId: adminIdentity.id,
|
||||
},
|
||||
});
|
||||
|
||||
return adminIdentity;
|
||||
}
|
||||
|
||||
export function buildE2eReadinessPlatformLeadSource(adminUserId: string) {
|
||||
return {
|
||||
id: E2E_READINESS_PLATFORM_LEAD_SOURCE_ID,
|
||||
key: E2E_READINESS_PLATFORM_LEAD_SOURCE_KEY,
|
||||
displayName: E2E_READINESS_PLATFORM_LEAD_SOURCE_NAME,
|
||||
enabled: true,
|
||||
defaultAssigneeAdminUserId: adminUserId,
|
||||
notifyAdminUserIds: [adminUserId],
|
||||
rateLimitPerMinute: 60,
|
||||
metadata: { fixture: "e2e-readiness" },
|
||||
};
|
||||
}
|
||||
|
||||
async function seedPlatformLeadReadiness(db: DbClient, adminUserId: string): Promise<void> {
|
||||
const source = buildE2eReadinessPlatformLeadSource(adminUserId);
|
||||
await db.adminLeadSource.upsert({
|
||||
where: { key: source.key },
|
||||
create: source,
|
||||
update: {
|
||||
displayName: source.displayName,
|
||||
enabled: source.enabled,
|
||||
defaultAssigneeAdminUserId: source.defaultAssigneeAdminUserId,
|
||||
notifyAdminUserIds: source.notifyAdminUserIds,
|
||||
rateLimitPerMinute: source.rateLimitPerMinute,
|
||||
metadata: source.metadata,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
async function ensureTenantMembership(db: DbClient, userId: string, tenantId: string) {
|
||||
@@ -693,27 +781,105 @@ async function seedRoles(db: DbClient, userId: string, tenantId: string) {
|
||||
// dedicated admin user instead.
|
||||
}
|
||||
|
||||
async function seedChatReadiness(db: DbClient, tenantId: string, userId: string, peerUserId: string) {
|
||||
const chat = await db.teamChat.upsert({
|
||||
where: { id: E2E_READINESS_CHAT_ID },
|
||||
create: {
|
||||
id: E2E_READINESS_CHAT_ID,
|
||||
tenantId,
|
||||
createdByUserId: userId,
|
||||
kind: "group",
|
||||
name: E2E_READINESS_CHAT_NAME,
|
||||
description: "Dedicated channel for the mutating chat E2E readiness smoke.",
|
||||
isPrivate: true,
|
||||
eventStreamId: E2E_READINESS_CHAT_EVENT_STREAM_ID,
|
||||
isDemoData: true,
|
||||
},
|
||||
update: {
|
||||
tenantId,
|
||||
createdByUserId: userId,
|
||||
kind: "group",
|
||||
name: E2E_READINESS_CHAT_NAME,
|
||||
description: "Dedicated channel for the mutating chat E2E readiness smoke.",
|
||||
isPrivate: true,
|
||||
archivedAt: null,
|
||||
archivedReason: null,
|
||||
isDemoData: true,
|
||||
},
|
||||
});
|
||||
|
||||
await db.teamChatMember.upsert({
|
||||
where: { chatId_userId: { chatId: chat.id, userId } },
|
||||
create: {
|
||||
id: E2E_READINESS_CHAT_MEMBER_ID,
|
||||
tenantId,
|
||||
chatId: chat.id,
|
||||
userId,
|
||||
joinedViaUserId: userId,
|
||||
roleInChat: "admin",
|
||||
notificationPref: "all_messages",
|
||||
},
|
||||
update: {
|
||||
tenantId,
|
||||
joinedViaUserId: userId,
|
||||
roleInChat: "admin",
|
||||
notificationPref: "all_messages",
|
||||
leftAt: null,
|
||||
},
|
||||
});
|
||||
|
||||
await db.teamChatMember.upsert({
|
||||
where: { chatId_userId: { chatId: chat.id, userId: peerUserId } },
|
||||
create: {
|
||||
id: E2E_READINESS_CHAT_PEER_MEMBER_ID,
|
||||
tenantId,
|
||||
chatId: chat.id,
|
||||
userId: peerUserId,
|
||||
joinedViaUserId: userId,
|
||||
roleInChat: "member",
|
||||
notificationPref: "all_messages",
|
||||
},
|
||||
update: {
|
||||
tenantId,
|
||||
joinedViaUserId: userId,
|
||||
roleInChat: "member",
|
||||
notificationPref: "all_messages",
|
||||
leftAt: null,
|
||||
},
|
||||
});
|
||||
|
||||
return chat;
|
||||
}
|
||||
|
||||
async function seedFeatureFlags(db: DbClient) {
|
||||
// The workspace roles builder (/settings/roles-and-permissions/roles) is gated
|
||||
// behind the "workspace-roles" feature flag (see workspaceRoles.server.ts);
|
||||
// without an enabled global flag the roles sub-route throws a 404. Seed it
|
||||
// enabled so the e2e tenant can reach the roles tab.
|
||||
const existing = await db.featureFlag.findFirst({ where: { name: E2E_READINESS_WORKSPACE_ROLES_FLAG } });
|
||||
if (existing) {
|
||||
if (!existing.enabled) {
|
||||
await db.featureFlag.update({ where: { id: existing.id }, data: { enabled: true } });
|
||||
}
|
||||
return;
|
||||
}
|
||||
await db.featureFlag.create({
|
||||
data: {
|
||||
const flags = [
|
||||
{
|
||||
name: E2E_READINESS_WORKSPACE_ROLES_FLAG,
|
||||
key: E2E_READINESS_WORKSPACE_ROLES_FLAG,
|
||||
description: "E2E readiness: enable the workspace roles builder.",
|
||||
scope: "global",
|
||||
enabled: true,
|
||||
},
|
||||
});
|
||||
] as const;
|
||||
for (const flag of flags) {
|
||||
const existing = await db.featureFlag.findFirst({ where: { name: flag.name } });
|
||||
if (existing) {
|
||||
if (!existing.enabled) {
|
||||
await db.featureFlag.update({ where: { id: existing.id }, data: { enabled: true } });
|
||||
}
|
||||
continue;
|
||||
}
|
||||
await db.featureFlag.create({
|
||||
data: {
|
||||
name: flag.name,
|
||||
key: flag.name,
|
||||
description: flag.description,
|
||||
scope: "global",
|
||||
enabled: true,
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
async function seedPluginReadonlyUser(db: DbClient, tenantId: string) {
|
||||
@@ -777,7 +943,9 @@ async function seedSubscription(db: DbClient, tenantId: string) {
|
||||
}
|
||||
|
||||
const price =
|
||||
(await db.subscriptionPrice.findFirst({ where: { subscriptionProductId: product.id, billingProviderId: E2E_READINESS_SUBSCRIPTION_PRICE_BILLING_PROVIDER_ID } })) ??
|
||||
(await db.subscriptionPrice.findFirst({
|
||||
where: { subscriptionProductId: product.id, billingProviderId: E2E_READINESS_SUBSCRIPTION_PRICE_BILLING_PROVIDER_ID },
|
||||
})) ??
|
||||
(await db.subscriptionPrice.create({
|
||||
data: {
|
||||
subscriptionProductId: product.id,
|
||||
@@ -1008,7 +1176,10 @@ async function seedLifecyclePlugin(db: DbClient, tenantId: string, userId: strin
|
||||
// no missing capabilities. A disabled plugin with any missing capability hides its
|
||||
// enable form (review-before-enable), which would trap the deactivate→re-enable
|
||||
// lifecycle tests with "lifecycle controls unavailable".
|
||||
const lifecycleCapabilityNames = [...manifest.capabilities.map((capability) => capability.name), ...(manifest.hooks ?? []).map((hook) => `hook:${hook.name}`)];
|
||||
const lifecycleCapabilityNames = [
|
||||
...manifest.capabilities.map((capability) => capability.name),
|
||||
...(manifest.hooks ?? []).map((hook) => `hook:${hook.name}`),
|
||||
];
|
||||
for (const capabilityName of lifecycleCapabilityNames) {
|
||||
await db.tenantPluginCapabilityGrant.upsert({
|
||||
where: { tenantId_pluginId_capabilityName: { tenantId, pluginId: manifest.id, capabilityName } },
|
||||
@@ -1020,30 +1191,6 @@ async function seedLifecyclePlugin(db: DbClient, tenantId: string, userId: strin
|
||||
return plugin;
|
||||
}
|
||||
|
||||
async function seedPortal(db: DbClient, tenantId: string, userId: string) {
|
||||
// The portals feature ships gated off (PORTALS_ENABLED) with its routes always
|
||||
// mounted; this fixture lets the readiness lane exercise the tenant portal
|
||||
// management surfaces (analytics + settings) once the env opt-in is set. A
|
||||
// minimal published portal is enough — the pages render their empty-state /
|
||||
// form without any Mollie/analytics data.
|
||||
await db.portal.upsert({
|
||||
where: { subdomain: E2E_READINESS_PORTAL_SUBDOMAIN },
|
||||
create: {
|
||||
tenantId,
|
||||
createdByUserId: userId,
|
||||
subdomain: E2E_READINESS_PORTAL_SUBDOMAIN,
|
||||
title: E2E_READINESS_PORTAL_TITLE,
|
||||
isPublished: true,
|
||||
},
|
||||
update: {
|
||||
tenantId,
|
||||
createdByUserId: userId,
|
||||
title: E2E_READINESS_PORTAL_TITLE,
|
||||
isPublished: true,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
async function seedWorkflowFromDefinition(db: DbClient, tenantId: string, userId: string, definition: E2eWorkflowDefinition) {
|
||||
await db.workflow.deleteMany({ where: { tenantId, OR: [{ id: definition.id }, { name: definition.name }] } });
|
||||
const workflow = await db.workflow.create({
|
||||
@@ -1206,6 +1353,113 @@ async function seedEmailSequences(db: DbClient, tenantId: string) {
|
||||
}
|
||||
}
|
||||
|
||||
async function seedProjectPipeline(db: DbClient, tenantId: string, userId: string) {
|
||||
await db.pipeline.upsert({
|
||||
where: { id: E2E_READINESS_PIPELINE_ID },
|
||||
create: {
|
||||
id: E2E_READINESS_PIPELINE_ID,
|
||||
tenantId,
|
||||
createdByUserId: userId,
|
||||
name: E2E_READINESS_PIPELINE_NAME,
|
||||
typHint: "sales",
|
||||
position: 0,
|
||||
isDefault: true,
|
||||
isDemoData: false,
|
||||
},
|
||||
update: {
|
||||
tenantId,
|
||||
createdByUserId: userId,
|
||||
name: E2E_READINESS_PIPELINE_NAME,
|
||||
typHint: "sales",
|
||||
position: 0,
|
||||
isDefault: true,
|
||||
isDemoData: false,
|
||||
archivedAt: null,
|
||||
},
|
||||
});
|
||||
|
||||
for (const [position, stage] of E2E_READINESS_PIPELINE_STAGES.entries()) {
|
||||
await db.pipelineStage.upsert({
|
||||
where: { id: stage.id },
|
||||
create: {
|
||||
...stage,
|
||||
tenantId,
|
||||
pipelineId: E2E_READINESS_PIPELINE_ID,
|
||||
position,
|
||||
isDemoData: false,
|
||||
},
|
||||
update: {
|
||||
tenantId,
|
||||
pipelineId: E2E_READINESS_PIPELINE_ID,
|
||||
name: stage.name,
|
||||
stageKind: stage.stageKind,
|
||||
winProbability: stage.winProbability,
|
||||
color: stage.color,
|
||||
position,
|
||||
isDemoData: false,
|
||||
archivedAt: null,
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
async function seedOnboardingChecklist(db: DbClient, tenantId: string, userId: string) {
|
||||
await db.onboarding.upsert({
|
||||
where: { id: E2E_READINESS_ONBOARDING_ID },
|
||||
create: {
|
||||
id: E2E_READINESS_ONBOARDING_ID,
|
||||
title: E2E_READINESS_ONBOARDING_CODE,
|
||||
type: "page",
|
||||
realtime: false,
|
||||
active: true,
|
||||
canBeDismissed: true,
|
||||
},
|
||||
update: {
|
||||
title: E2E_READINESS_ONBOARDING_CODE,
|
||||
type: "page",
|
||||
realtime: false,
|
||||
active: true,
|
||||
canBeDismissed: true,
|
||||
height: null,
|
||||
},
|
||||
});
|
||||
for (const step of E2E_READINESS_ONBOARDING_STEPS) {
|
||||
await db.onboardingStep.upsert({
|
||||
where: { id: step.id },
|
||||
create: { ...step, onboardingId: E2E_READINESS_ONBOARDING_ID },
|
||||
update: { order: step.order, block: step.block, onboardingId: E2E_READINESS_ONBOARDING_ID },
|
||||
});
|
||||
}
|
||||
const session = await db.onboardingSession.upsert({
|
||||
where: {
|
||||
onboardingId_userId_tenantId: {
|
||||
onboardingId: E2E_READINESS_ONBOARDING_ID,
|
||||
userId,
|
||||
tenantId,
|
||||
},
|
||||
},
|
||||
create: {
|
||||
onboardingId: E2E_READINESS_ONBOARDING_ID,
|
||||
userId,
|
||||
tenantId,
|
||||
status: "active",
|
||||
startedAt: new Date(),
|
||||
},
|
||||
update: {
|
||||
status: "active",
|
||||
completedAt: null,
|
||||
dismissedAt: null,
|
||||
},
|
||||
});
|
||||
await db.onboardingSessionStep.deleteMany({ where: { onboardingSessionId: session.id } });
|
||||
await db.onboardingSessionStep.createMany({
|
||||
data: E2E_READINESS_ONBOARDING_STEPS.map((step) => ({
|
||||
onboardingSessionId: session.id,
|
||||
stepId: step.id,
|
||||
})),
|
||||
});
|
||||
}
|
||||
|
||||
export async function seedE2eReadiness(env: EnvRecord = process.env) {
|
||||
assertCanRunE2eReadinessSeed(env);
|
||||
const repoRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
|
||||
@@ -1215,16 +1469,19 @@ export async function seedE2eReadiness(env: EnvRecord = process.env) {
|
||||
const { user, tenant } = await seedUserAndTenant(db);
|
||||
await pruneLeakedE2eAccounts(db, user.id, tenant.id);
|
||||
await seedRoles(db, user.id, tenant.id);
|
||||
await seedProjectPipeline(db, tenant.id, user.id);
|
||||
await seedOnboardingChecklist(db, tenant.id, user.id);
|
||||
await seedFeatureFlags(db);
|
||||
await seedNoTenantUser(db);
|
||||
await seedAdminUser(db);
|
||||
await seedPluginReadonlyUser(db, tenant.id);
|
||||
const adminUser = await seedAdminUser(db);
|
||||
await seedPlatformLeadReadiness(db, adminUser.id);
|
||||
const chatPeer = await seedPluginReadonlyUser(db, tenant.id);
|
||||
await seedSubscription(db, tenant.id);
|
||||
const chat = await seedChatReadiness(db, tenant.id, user.id, chatPeer.id);
|
||||
await seedEmailSequences(db, tenant.id);
|
||||
await seedApiReadiness(db, tenant.id, user.id);
|
||||
await seedPlugin(db, tenant.id, user.id, pluginBasePath);
|
||||
await seedLifecyclePlugin(db, tenant.id, user.id);
|
||||
await seedPortal(db, tenant.id, user.id);
|
||||
const manualWorkflow = await seedWorkflow(db, tenant.id, user.id);
|
||||
const webhookWorkflow = await seedWebhookWorkflow(db, tenant.id, user.id);
|
||||
const waitingWorkflow = await seedWaitingWorkflow(db, tenant.id, user.id);
|
||||
@@ -1242,6 +1499,7 @@ export async function seedE2eReadiness(env: EnvRecord = process.env) {
|
||||
|
||||
const values = buildE2eReadinessEnv({
|
||||
tenantSlug: tenant.slug,
|
||||
chatId: chat.id,
|
||||
workflowId: manualWorkflow.workflow.id,
|
||||
webhookWorkflowId: webhookWorkflow.workflow.id,
|
||||
waitingWorkflowId: waitingWorkflow.workflow.id,
|
||||
|
||||
Reference in new issue
Block a user