diff --git a/src/admin/components/elements/Collapsible/index.scss b/src/admin/components/elements/Collapsible/index.scss new file mode 100644 index 000000000..e69de29bb diff --git a/src/admin/components/elements/Collapsible/index.tsx b/src/admin/components/elements/Collapsible/index.tsx new file mode 100644 index 000000000..d69a3bf2d --- /dev/null +++ b/src/admin/components/elements/Collapsible/index.tsx @@ -0,0 +1,14 @@ +import React from 'react'; +import { Props } from './types'; + +import './index.scss'; + +const baseClass = 'collapsible'; + +export const Collapsible: React.FC = ({ children }) => { + return ( +
+ {children} +
+ ); +}; diff --git a/src/admin/components/elements/Collapsible/types.ts b/src/admin/components/elements/Collapsible/types.ts new file mode 100644 index 000000000..2b19c46e5 --- /dev/null +++ b/src/admin/components/elements/Collapsible/types.ts @@ -0,0 +1,5 @@ +import React from 'react'; + +export type Props = { + children: React.ReactNode +} diff --git a/src/admin/components/forms/DraggableSection/index.tsx b/src/admin/components/forms/DraggableSection/index.tsx index 0728562c0..568ccb9a5 100644 --- a/src/admin/components/forms/DraggableSection/index.tsx +++ b/src/admin/components/forms/DraggableSection/index.tsx @@ -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'; diff --git a/test/credentials.ts b/test/credentials.ts new file mode 100644 index 000000000..c68708538 --- /dev/null +++ b/test/credentials.ts @@ -0,0 +1,5 @@ +export const devUser = { + email: 'dev@payloadcms.com', + password: 'test', + roles: ['admin'], +}; diff --git a/test/e2e/fields/config.ts b/test/e2e/fields/config.ts new file mode 100644 index 000000000..94d98e7f1 --- /dev/null +++ b/test/e2e/fields/config.ts @@ -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, + }); + }, +}); diff --git a/test/e2e/fields/index.spec.ts b/test/e2e/fields/index.spec.ts new file mode 100644 index 000000000..bb4b2374a --- /dev/null +++ b/test/e2e/fields/index.spec.ts @@ -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); + }); + }); +}); diff --git a/test/e2e/fields/shared.ts b/test/e2e/fields/shared.ts new file mode 100644 index 000000000..8e464822f --- /dev/null +++ b/test/e2e/fields/shared.ts @@ -0,0 +1,3 @@ +export const seededDoc = { + text: 'Seeded document', +}; diff --git a/test/e2e/helpers.ts b/test/e2e/helpers.ts index ebb90c7ea..d63390209 100644 --- a/test/e2e/helpers.ts +++ b/test/e2e/helpers.ts @@ -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 { 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 { 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`);