chore: writes e2e test for row fields as table columns

This commit is contained in:
Jacob Fletcher
2023-03-07 10:25:01 -05:00
parent b10e842e89
commit b92ad4a2d6
4 changed files with 60 additions and 0 deletions

View File

@@ -0,0 +1,26 @@
import type { CollectionConfig } from '../../../../src/collections/config/types';
export const rowFieldsSlug = 'row-fields';
const RowFields: CollectionConfig = {
slug: rowFieldsSlug,
versions: true,
admin: {
defaultColumns: ['title', 'id'],
},
fields: [
{
type: 'row',
fields: [
{
name: 'title',
label: 'Title within a row',
type: 'text',
required: true,
},
],
},
],
};
export default RowFields;

View File

@@ -6,6 +6,10 @@ const Uploads2: CollectionConfig = {
upload: {
staticDir: path.resolve(__dirname, './uploads2'),
},
labels: {
singular: 'Upload 2',
plural: 'Uploads 2',
},
fields: [
{
type: 'text',

View File

@@ -24,6 +24,7 @@ import RelationshipFields from './collections/Relationship';
import RadioFields, { radiosDoc } from './collections/Radio';
import Uploads2 from './collections/Upload2';
import Uploads3 from './collections/Uploads3';
import RowFields from './collections/Row';
export default buildConfig({
admin: {
@@ -47,6 +48,7 @@ export default buildConfig({
DateFields,
RadioFields,
GroupFields,
RowFields,
IndexedFields,
JSONFields,
NumberFields,

View File

@@ -731,4 +731,32 @@ describe('fields', () => {
await expect(page.locator('.list-drawer__header-text')).toContainText('Uploads 3');
});
});
describe('row', () => {
let url: AdminUrlUtil;
beforeAll(() => {
url = new AdminUrlUtil(serverURL, 'row-fields');
});
test('should show row fields as table columns', async () => {
await page.goto(url.create);
// fill the required fields, including the row field
const titleInput = page.locator('input#field-title');
await titleInput.fill('Test Row');
await page.locator('#action-save').click();
await wait(200);
await expect(page.locator('.Toastify')).toContainText('successfully');
// ensure the 'title' field is visible in the table header
await page.goto(url.list);
const titleHeading = page.locator('th#heading-title');
await expect(titleHeading).toBeVisible();
// ensure the 'title' field shows the correct value in the table cell
const titleCell = page.locator('.row-1 td.cell-title');
await expect(titleCell).toBeVisible();
await expect(titleCell).toContainText('Test Row');
});
});
});