diff --git a/tests/e2e/admin.e2e.spec.ts b/tests/e2e/admin.e2e.spec.ts deleted file mode 100644 index 67fc921..0000000 --- a/tests/e2e/admin.e2e.spec.ts +++ /dev/null @@ -1,41 +0,0 @@ -import { test, expect, Page } from '@playwright/test' -import { login } from '../helpers/login' -import { seedTestUser, cleanupTestUser, testUser } from '../helpers/seedUser' - -test.describe('Admin Panel', () => { - let page: Page - - test.beforeAll(async ({ browser }, testInfo) => { - await seedTestUser() - - const context = await browser.newContext() - page = await context.newPage() - - await login({ page, user: testUser }) - }) - - test.afterAll(async () => { - await cleanupTestUser() - }) - - test('can navigate to dashboard', async () => { - await page.goto('http://localhost:3000/admin') - await expect(page).toHaveURL('http://localhost:3000/admin') - const dashboardArtifact = page.locator('span[title="Dashboard"]').first() - await expect(dashboardArtifact).toBeVisible() - }) - - test('can navigate to list view', async () => { - await page.goto('http://localhost:3000/admin/collections/users') - await expect(page).toHaveURL('http://localhost:3000/admin/collections/users') - const listViewArtifact = page.locator('h1', { hasText: 'Users' }).first() - await expect(listViewArtifact).toBeVisible() - }) - - test('can navigate to edit view', async () => { - await page.goto('http://localhost:3000/admin/collections/users/create') - await expect(page).toHaveURL(/\/admin\/collections\/users\/[a-zA-Z0-9-_]+/) - const editViewArtifact = page.locator('input[name="email"]') - await expect(editViewArtifact).toBeVisible() - }) -}) diff --git a/tests/e2e/frontend.e2e.spec.ts b/tests/e2e/frontend.e2e.spec.ts deleted file mode 100644 index 65c31fd..0000000 --- a/tests/e2e/frontend.e2e.spec.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { test, expect, Page } from '@playwright/test' - -test.describe('Frontend', () => { - let page: Page - - test.beforeAll(async ({ browser }, testInfo) => { - const context = await browser.newContext() - page = await context.newPage() - }) - - test('can go on homepage', async ({ page }) => { - await page.goto('http://localhost:3000') - - await expect(page).toHaveTitle(/Payload Blank Template/) - - const heading = page.locator('h1').first() - - await expect(heading).toHaveText('Welcome to your new project.') - }) -}) diff --git a/tests/helpers/login.ts b/tests/helpers/login.ts deleted file mode 100644 index deef8c2..0000000 --- a/tests/helpers/login.ts +++ /dev/null @@ -1,31 +0,0 @@ -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 { - 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() -} diff --git a/tests/helpers/seedUser.ts b/tests/helpers/seedUser.ts deleted file mode 100644 index f0f5c86..0000000 --- a/tests/helpers/seedUser.ts +++ /dev/null @@ -1,46 +0,0 @@ -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 { - 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 { - const payload = await getPayload({ config }) - - await payload.delete({ - collection: 'users', - where: { - email: { - equals: testUser.email, - }, - }, - }) -}