chore: stubs out fields e2e
This commit is contained in:
5
test/credentials.ts
Normal file
5
test/credentials.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
export const devUser = {
|
||||
email: 'dev@payloadcms.com',
|
||||
password: 'test',
|
||||
roles: ['admin'],
|
||||
};
|
||||
37
test/e2e/fields/config.ts
Normal file
37
test/e2e/fields/config.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
import { buildConfig } from '../buildConfig';
|
||||
import { devUser } from '../../credentials';
|
||||
import { seededDoc } from './shared';
|
||||
|
||||
export const slug = 'docs';
|
||||
|
||||
export default buildConfig({
|
||||
collections: [
|
||||
{
|
||||
slug,
|
||||
admin: {
|
||||
useAsTitle: 'text',
|
||||
},
|
||||
fields: [
|
||||
{
|
||||
name: 'text',
|
||||
type: 'text',
|
||||
required: true,
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
onInit: async (payload) => {
|
||||
await payload.create({
|
||||
collection: 'users',
|
||||
data: {
|
||||
email: devUser.email,
|
||||
password: devUser.password,
|
||||
},
|
||||
});
|
||||
|
||||
await payload.create({
|
||||
collection: slug,
|
||||
data: seededDoc,
|
||||
});
|
||||
},
|
||||
});
|
||||
38
test/e2e/fields/index.spec.ts
Normal file
38
test/e2e/fields/index.spec.ts
Normal file
@@ -0,0 +1,38 @@
|
||||
import type { Page } from '@playwright/test';
|
||||
import { expect, test } from '@playwright/test';
|
||||
import { AdminUrlUtil } from '../../helpers/adminUrlUtil';
|
||||
import { initPayloadTest } from '../../helpers/configHelpers';
|
||||
import { login } from '../helpers';
|
||||
import { slug } from './config';
|
||||
import { seededDoc } from './shared';
|
||||
|
||||
const { beforeAll, describe } = test;
|
||||
|
||||
let page: Page;
|
||||
let url: AdminUrlUtil;
|
||||
|
||||
describe('fields', () => {
|
||||
beforeAll(async ({ browser }) => {
|
||||
const { serverURL } = await initPayloadTest({
|
||||
__dirname,
|
||||
init: {
|
||||
local: false,
|
||||
},
|
||||
});
|
||||
|
||||
url = new AdminUrlUtil(serverURL, slug);
|
||||
|
||||
const context = await browser.newContext();
|
||||
page = await context.newPage();
|
||||
|
||||
await login({ page, serverURL });
|
||||
});
|
||||
|
||||
describe('text', () => {
|
||||
test('should display field in list view', async () => {
|
||||
await page.goto(url.collection);
|
||||
const textCell = await page.locator('table tr:first-child td:first-child a');
|
||||
await expect(textCell).toHaveText(seededDoc.text);
|
||||
});
|
||||
});
|
||||
});
|
||||
3
test/e2e/fields/shared.ts
Normal file
3
test/e2e/fields/shared.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
export const seededDoc = {
|
||||
text: 'Seeded document',
|
||||
};
|
||||
@@ -1,13 +1,7 @@
|
||||
import type { Page } from '@playwright/test';
|
||||
import { expect } from '@playwright/test';
|
||||
import wait from '../../src/utilities/wait';
|
||||
|
||||
|
||||
export const credentials = {
|
||||
email: 'dev@payloadcms.com',
|
||||
password: 'test',
|
||||
roles: ['admin'],
|
||||
};
|
||||
import { devUser } from '../credentials';
|
||||
|
||||
type FirstRegisterArgs = {
|
||||
page: Page,
|
||||
@@ -23,9 +17,9 @@ export async function firstRegister(args: FirstRegisterArgs): Promise<void> {
|
||||
const { page, serverURL } = args;
|
||||
|
||||
await page.goto(`${serverURL}/admin`);
|
||||
await page.fill('#email', credentials.email);
|
||||
await page.fill('#password', credentials.password);
|
||||
await page.fill('#confirm-password', credentials.password);
|
||||
await page.fill('#email', devUser.email);
|
||||
await page.fill('#password', devUser.password);
|
||||
await page.fill('#confirm-password', devUser.password);
|
||||
await wait(500);
|
||||
await page.click('[type=submit]');
|
||||
await page.waitForURL(`${serverURL}/admin`);
|
||||
@@ -35,8 +29,8 @@ export async function login(args: LoginArgs): Promise<void> {
|
||||
const { page, serverURL } = args;
|
||||
|
||||
await page.goto(`${serverURL}/admin`);
|
||||
await page.fill('#email', credentials.email);
|
||||
await page.fill('#password', credentials.password);
|
||||
await page.fill('#email', devUser.email);
|
||||
await page.fill('#password', devUser.password);
|
||||
await wait(500);
|
||||
await page.click('[type=submit]');
|
||||
await page.waitForURL(`${serverURL}/admin`);
|
||||
|
||||
Reference in New Issue
Block a user