chore: stubs out fields e2e
This commit is contained in:
14
src/admin/components/elements/Collapsible/index.tsx
Normal file
14
src/admin/components/elements/Collapsible/index.tsx
Normal 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>
|
||||||
|
);
|
||||||
|
};
|
||||||
5
src/admin/components/elements/Collapsible/types.ts
Normal file
5
src/admin/components/elements/Collapsible/types.ts
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
import React from 'react';
|
||||||
|
|
||||||
|
export type Props = {
|
||||||
|
children: React.ReactNode
|
||||||
|
}
|
||||||
@@ -11,9 +11,9 @@ import FieldTypeGutter from '../FieldTypeGutter';
|
|||||||
import RenderFields from '../RenderFields';
|
import RenderFields from '../RenderFields';
|
||||||
import { Props } from './types';
|
import { Props } from './types';
|
||||||
import HiddenInput from '../field-types/HiddenInput';
|
import HiddenInput from '../field-types/HiddenInput';
|
||||||
|
import { fieldAffectsData } from '../../../../fields/config/types';
|
||||||
|
|
||||||
import './index.scss';
|
import './index.scss';
|
||||||
import { fieldAffectsData } from '../../../../fields/config/types';
|
|
||||||
|
|
||||||
const baseClass = 'draggable-section';
|
const baseClass = 'draggable-section';
|
||||||
|
|
||||||
|
|||||||
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 type { Page } from '@playwright/test';
|
||||||
import { expect } from '@playwright/test';
|
import { expect } from '@playwright/test';
|
||||||
import wait from '../../src/utilities/wait';
|
import wait from '../../src/utilities/wait';
|
||||||
|
import { devUser } from '../credentials';
|
||||||
|
|
||||||
export const credentials = {
|
|
||||||
email: 'dev@payloadcms.com',
|
|
||||||
password: 'test',
|
|
||||||
roles: ['admin'],
|
|
||||||
};
|
|
||||||
|
|
||||||
type FirstRegisterArgs = {
|
type FirstRegisterArgs = {
|
||||||
page: Page,
|
page: Page,
|
||||||
@@ -23,9 +17,9 @@ export async function firstRegister(args: FirstRegisterArgs): Promise<void> {
|
|||||||
const { page, serverURL } = args;
|
const { page, serverURL } = args;
|
||||||
|
|
||||||
await page.goto(`${serverURL}/admin`);
|
await page.goto(`${serverURL}/admin`);
|
||||||
await page.fill('#email', credentials.email);
|
await page.fill('#email', devUser.email);
|
||||||
await page.fill('#password', credentials.password);
|
await page.fill('#password', devUser.password);
|
||||||
await page.fill('#confirm-password', credentials.password);
|
await page.fill('#confirm-password', devUser.password);
|
||||||
await wait(500);
|
await wait(500);
|
||||||
await page.click('[type=submit]');
|
await page.click('[type=submit]');
|
||||||
await page.waitForURL(`${serverURL}/admin`);
|
await page.waitForURL(`${serverURL}/admin`);
|
||||||
@@ -35,8 +29,8 @@ export async function login(args: LoginArgs): Promise<void> {
|
|||||||
const { page, serverURL } = args;
|
const { page, serverURL } = args;
|
||||||
|
|
||||||
await page.goto(`${serverURL}/admin`);
|
await page.goto(`${serverURL}/admin`);
|
||||||
await page.fill('#email', credentials.email);
|
await page.fill('#email', devUser.email);
|
||||||
await page.fill('#password', credentials.password);
|
await page.fill('#password', devUser.password);
|
||||||
await wait(500);
|
await wait(500);
|
||||||
await page.click('[type=submit]');
|
await page.click('[type=submit]');
|
||||||
await page.waitForURL(`${serverURL}/admin`);
|
await page.waitForURL(`${serverURL}/admin`);
|
||||||
|
|||||||
Reference in New Issue
Block a user