chore: stubs out fields e2e

This commit is contained in:
James
2022-07-13 12:40:29 -07:00
parent 90ba15f9bd
commit de43e21ebc
9 changed files with 109 additions and 13 deletions

View File

@@ -0,0 +1,14 @@
import React from 'react';
import { Props } from './types';
import './index.scss';
const baseClass = 'collapsible';
export const Collapsible: React.FC<Props> = ({ children }) => {
return (
<div className={baseClass}>
{children}
</div>
);
};

View File

@@ -0,0 +1,5 @@
import React from 'react';
export type Props = {
children: React.ReactNode
}

View File

@@ -11,9 +11,9 @@ import FieldTypeGutter from '../FieldTypeGutter';
import RenderFields from '../RenderFields';
import { Props } from './types';
import HiddenInput from '../field-types/HiddenInput';
import { fieldAffectsData } from '../../../../fields/config/types';
import './index.scss';
import { fieldAffectsData } from '../../../../fields/config/types';
const baseClass = 'draggable-section';

5
test/credentials.ts Normal file
View File

@@ -0,0 +1,5 @@
export const devUser = {
email: 'dev@payloadcms.com',
password: 'test',
roles: ['admin'],
};

37
test/e2e/fields/config.ts Normal file
View 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,
});
},
});

View 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);
});
});
});

View File

@@ -0,0 +1,3 @@
export const seededDoc = {
text: 'Seeded document',
};

View File

@@ -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`);