chore(testing): pause test execution and prep deterministic e2e admin seed
This commit is contained in:
@@ -266,11 +266,15 @@ type BootstrapUserConfig = {
|
||||
password: string
|
||||
role: Role
|
||||
isHidden: boolean
|
||||
isSystem?: boolean
|
||||
isProtected?: boolean
|
||||
}
|
||||
|
||||
async function ensureCredentialUser(config: BootstrapUserConfig): Promise<void> {
|
||||
const ctx = await auth.$context
|
||||
const normalizedEmail = config.email.toLowerCase()
|
||||
const isSystem = config.isSystem ?? true
|
||||
const isProtected = config.isProtected ?? true
|
||||
const existing = await ctx.internalAdapter.findUserByEmail(normalizedEmail, {
|
||||
includeAccounts: true,
|
||||
})
|
||||
@@ -282,9 +286,9 @@ async function ensureCredentialUser(config: BootstrapUserConfig): Promise<void>
|
||||
name: config.name,
|
||||
role: config.role,
|
||||
isBanned: false,
|
||||
isSystem: true,
|
||||
isSystem,
|
||||
isHidden: config.isHidden,
|
||||
isProtected: true,
|
||||
isProtected,
|
||||
},
|
||||
})
|
||||
|
||||
@@ -321,9 +325,9 @@ async function ensureCredentialUser(config: BootstrapUserConfig): Promise<void>
|
||||
emailVerified: true,
|
||||
role: config.role,
|
||||
isBanned: false,
|
||||
isSystem: true,
|
||||
isSystem,
|
||||
isHidden: config.isHidden,
|
||||
isProtected: true,
|
||||
isProtected,
|
||||
})
|
||||
|
||||
await ctx.internalAdapter.linkAccount({
|
||||
@@ -371,6 +375,29 @@ export async function ensureSupportUserBootstrap(): Promise<void> {
|
||||
}
|
||||
}
|
||||
|
||||
const DEFAULT_E2E_ADMIN_EMAIL = "e2e-admin@cms.local"
|
||||
const DEFAULT_E2E_ADMIN_USERNAME = "e2e-admin"
|
||||
const DEFAULT_E2E_ADMIN_PASSWORD = "e2e-admin-password"
|
||||
const DEFAULT_E2E_ADMIN_NAME = "E2E Admin"
|
||||
|
||||
export async function ensureE2EAdminBootstrap(): Promise<void> {
|
||||
const email = resolveBootstrapValue("CMS_E2E_ADMIN_EMAIL", DEFAULT_E2E_ADMIN_EMAIL)
|
||||
const username = resolveBootstrapValue("CMS_E2E_ADMIN_USERNAME", DEFAULT_E2E_ADMIN_USERNAME)
|
||||
const password = resolveBootstrapValue("CMS_E2E_ADMIN_PASSWORD", DEFAULT_E2E_ADMIN_PASSWORD)
|
||||
const name = resolveBootstrapValue("CMS_E2E_ADMIN_NAME", DEFAULT_E2E_ADMIN_NAME)
|
||||
|
||||
await ensureCredentialUser({
|
||||
email,
|
||||
username,
|
||||
password,
|
||||
name,
|
||||
role: "admin",
|
||||
isHidden: false,
|
||||
isSystem: true,
|
||||
isProtected: false,
|
||||
})
|
||||
}
|
||||
|
||||
type OwnerInvariantState = {
|
||||
ownerId: string | null
|
||||
ownerCount: number
|
||||
|
||||
Reference in New Issue
Block a user