chore: migrate to payload / nextjs

This commit is contained in:
syntaxbullet
2026-06-16 13:02:47 +02:00
parent aff090b693
commit 6b395e5735
257 changed files with 33616 additions and 1451 deletions

31
tests/helpers/login.ts Normal file
View File

@@ -0,0 +1,31 @@
import type { Page } from '@playwright/test'
import { expect } from '@playwright/test'
export interface LoginOptions {
page: Page
serverURL?: string
user: {
email: string
password: string
}
}
/**
* Logs the user into the admin panel via the login page.
*/
export async function login({
page,
serverURL = 'http://localhost:3000',
user,
}: LoginOptions): Promise<void> {
await page.goto(`${serverURL}/admin/login`)
await page.fill('#field-email', user.email)
await page.fill('#field-password', user.password)
await page.click('button[type="submit"]')
await page.waitForURL(`${serverURL}/admin`)
const dashboardArtifact = page.locator('span[title="Dashboard"]')
await expect(dashboardArtifact).toBeVisible()
}

46
tests/helpers/seedUser.ts Normal file
View File

@@ -0,0 +1,46 @@
import { getPayload } from 'payload'
import config from '../../src/payload.config.js'
export const testUser = {
email: 'dev@payloadcms.com',
password: 'test',
}
/**
* Seeds a test user for e2e admin tests.
*/
export async function seedTestUser(): Promise<void> {
const payload = await getPayload({ config })
// Delete existing test user if any
await payload.delete({
collection: 'users',
where: {
email: {
equals: testUser.email,
},
},
})
// Create fresh test user
await payload.create({
collection: 'users',
data: testUser,
})
}
/**
* Cleans up test user after tests
*/
export async function cleanupTestUser(): Promise<void> {
const payload = await getPayload({ config })
await payload.delete({
collection: 'users',
where: {
email: {
equals: testUser.email,
},
},
})
}