All checks were successful
CI (PR) / checks (pull_request) Successful in 15m47s
PR Ready + auto-merge / ready-automerge (pull_request) Successful in 16m1s
Promote plan-issue Related on main merge / plan-issue-ready (pull_request) Has been skipped
Main merge flips claimed issues to done + in-prod / issue-done (pull_request) Successful in 21s
e2e: stub hermético de connect.facebook.net no guard compartilhado (specs paralelos renderizam a home com o pixel); advisory lock no Postgres serializando o login do usuário de teste (Payload perde sessão em login concorrente read-modify-write — classe documentada no webauthn); seedTestUser vira create-if-missing (sem janela de usuário ausente nem reset de senha); Lead do form protegido do catch de erro (tracking nunca falha uma captura commitada); descrição do campo compartilhada; unidade nova campaignNewsletterLead cobre exatamente um Lead no sucesso.
54 lines
1.5 KiB
TypeScript
54 lines
1.5 KiB
TypeScript
import { getPayload } from 'payload'
|
|
import config from '../../src/payload.config.js'
|
|
|
|
import { assertTestDatabase } from './assertTestDatabase'
|
|
|
|
export const testUser = {
|
|
email: 'dev@payloadcms.com',
|
|
password: 'test',
|
|
}
|
|
|
|
/**
|
|
* Seeds a test user for e2e admin tests.
|
|
*
|
|
* Create-if-missing on purpose: specs run fully parallel across workers and
|
|
* share this one user, so a delete-then-create left a window where (a) a
|
|
* concurrent `create` hit the unique email, and (b) the user — and every
|
|
* already-minted admin token — briefly vanished. The credentials are constant
|
|
* (testUser), so a row created by any worker is identical to the one another
|
|
* would create: the unique-conflict loser simply proceeds, and no password
|
|
* reset ever invalidates a live session.
|
|
*/
|
|
export async function seedTestUser(): Promise<void> {
|
|
assertTestDatabase(process.env.DATABASE_URL)
|
|
const payload = await getPayload({ config })
|
|
|
|
try {
|
|
await payload.create({
|
|
collection: 'users',
|
|
data: {
|
|
...testUser,
|
|
roles: ['admin'],
|
|
},
|
|
})
|
|
} catch {
|
|
// A parallel worker already seeded the shared user; nothing to reset.
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Cleans up test user after tests
|
|
*/
|
|
export async function cleanupTestUser(): Promise<void> {
|
|
assertTestDatabase(process.env.DATABASE_URL)
|
|
const payload = await getPayload({ config })
|
|
|
|
await payload.delete({
|
|
collection: 'users',
|
|
where: {
|
|
email: {
|
|
equals: testUser.email,
|
|
},
|
|
},
|
|
})
|
|
}
|