feat: revises e2e field testing

This commit is contained in:
James
2022-07-14 16:35:35 -07:00
parent 4bb0d3994f
commit 31ca363982
24 changed files with 386 additions and 174 deletions

View File

@@ -0,0 +1,44 @@
import type { CollectionConfig } from '../../../../../src/collections/config/types';
const ArrayFields: CollectionConfig = {
slug: 'array-fields',
fields: [
{
name: 'items',
type: 'array',
required: true,
fields: [
{
name: 'text',
type: 'text',
required: true,
},
],
},
],
};
export const arrayDoc = {
items: [
{
text: 'first row',
},
{
text: 'second row',
},
{
text: 'third row',
},
{
text: 'fourth row',
},
{
text: 'fifth row',
},
{
text: 'sixth row',
},
],
};
export default ArrayFields;

View File

@@ -0,0 +1,98 @@
import type { CollectionConfig } from '../../../../../src/collections/config/types';
const BlockFields: CollectionConfig = {
slug: 'block-fields',
fields: [
{
name: 'blocks',
type: 'blocks',
required: true,
blocks: [
{
slug: 'text',
fields: [
{
name: 'text',
type: 'text',
required: true,
},
],
},
{
slug: 'number',
fields: [
{
name: 'number',
type: 'number',
required: true,
},
],
},
{
slug: 'subBlocks',
fields: [
{
name: 'subBlocks',
type: 'blocks',
blocks: [
{
slug: 'text',
fields: [
{
name: 'text',
type: 'text',
required: true,
},
],
},
{
slug: 'number',
fields: [
{
name: 'number',
type: 'number',
required: true,
},
],
},
],
},
],
},
],
},
],
};
export const blocksDoc = {
blocks: [
{
blockName: 'First block',
blockType: 'text',
text: 'first block',
},
{
blockName: 'Second block',
blockType: 'number',
number: 342,
},
{
blockName: 'Sub-block demonstration',
blockType: 'subBlocks',
subBlocks: [
{
blockName: 'First sub block',
blockType: 'number',
number: 123,
},
{
blockName: 'Second sub block',
blockType: 'text',
text: 'second sub block',
},
],
},
],
};
export default BlockFields;

View File

@@ -0,0 +1,27 @@
import type { CollectionConfig } from '../../../../../src/collections/config/types';
const CollapsibleFields: CollectionConfig = {
slug: 'collapsible-fields',
fields: [
{
label: 'Collapsible Field',
type: 'collapsible',
admin: {
description: 'This is a collapsible field.',
},
fields: [
{
name: 'text',
type: 'text',
required: true,
},
],
},
],
};
export const collapsibleDoc = {
text: 'Seeded collapsible doc',
};
export default CollapsibleFields;

View File

@@ -1,45 +1,16 @@
export const arrayDoc = {
items: [
import type { CollectionConfig } from '../../../../../src/collections/config/types';
const RichTextFields: CollectionConfig = {
slug: 'rich-text-fields',
fields: [
{
text: 'first row',
},
{
text: 'second row',
},
{
text: 'third row',
},
{
text: 'fourth row',
},
{
text: 'fifth row',
},
{
text: 'sixth row',
name: 'richText',
type: 'richText',
required: true,
},
],
};
export const blocksDoc = {
blocks: [
{
blockName: 'First block',
blockType: 'text',
text: 'first block',
},
{
blockName: 'Second block',
blockType: 'number',
number: 342,
},
],
};
export const collapsibleDoc = {
text: 'Seeded collapsible doc',
};
export const richTextDoc = {
richText: [
{
@@ -53,7 +24,20 @@ export const richTextDoc = {
{
children: [
{
text: 'I can do all kinds of fun stuff like render links and store nested relationship fields:',
text: 'I can do all kinds of fun stuff like ',
},
{
type: 'link',
url: 'test.com',
newTab: true,
children: [
{
text: 'render links',
},
],
},
{
text: ' and store nested relationship fields:',
},
],
},
@@ -64,7 +48,9 @@ export const richTextDoc = {
},
],
type: 'relationship',
value: { id: '' },
value: {
id: '',
},
relationTo: 'text-fields',
},
{
@@ -113,6 +99,5 @@ export const richTextDoc = {
],
};
export const textDoc = {
text: 'Seeded text document',
};
export default RichTextFields;

View File

@@ -0,0 +1,63 @@
import type { CollectionConfig } from '../../../../../src/collections/config/types';
const SelectFields: CollectionConfig = {
slug: 'select-fields',
fields: [
{
name: 'select',
type: 'select',
options: [
{
label: 'Value One',
value: 'one',
},
{
label: 'Value Two',
value: 'two',
},
{
label: 'Value Three',
value: 'three',
},
],
},
{
name: 'selectHasMany',
hasMany: true,
type: 'select',
options: [
{
label: 'Value One',
value: 'one',
},
{
label: 'Value Two',
value: 'two',
},
{
label: 'Value Three',
value: 'three',
},
{
label: 'Value Four',
value: 'four',
},
{
label: 'Value Five',
value: 'five',
},
{
label: 'Value Six',
value: 'six',
},
],
},
],
};
export const selectsDoc = {
select: 'one',
selectHasMany: ['two', 'four'],
};
export default SelectFields;

View File

@@ -0,0 +1,22 @@
import type { CollectionConfig } from '../../../../../src/collections/config/types';
const TextFields: CollectionConfig = {
slug: 'text-fields',
admin: {
useAsTitle: 'text',
},
fields: [
{
name: 'text',
type: 'text',
required: true,
},
],
};
export const textDoc = {
text: 'Seeded text document',
};
export default TextFields;

View File

@@ -1,100 +1,20 @@
import { buildConfig } from '../buildConfig';
import { devUser } from '../../credentials';
import { arrayDoc, blocksDoc, collapsibleDoc, richTextDoc, textDoc } from './shared';
import ArrayFields, { arrayDoc } from './collections/Array';
import BlockFields, { blocksDoc } from './collections/Blocks';
import CollapsibleFields, { collapsibleDoc } from './collections/Collapsible';
import RichTextFields, { richTextDoc } from './collections/RichText';
import SelectFields, { selectsDoc } from './collections/Select';
import TextFields, { textDoc } from './collections/Text';
export default buildConfig({
collections: [
{
slug: 'array-fields',
fields: [
{
name: 'items',
type: 'array',
required: true,
fields: [
{
name: 'text',
type: 'text',
required: true,
},
],
},
],
},
{
slug: 'block-fields',
fields: [
{
name: 'blocks',
type: 'blocks',
required: true,
blocks: [
{
slug: 'text',
fields: [
{
name: 'text',
type: 'text',
required: true,
},
],
},
{
slug: 'number',
fields: [
{
name: 'number',
type: 'number',
required: true,
},
],
},
],
},
],
},
{
slug: 'collapsible-fields',
fields: [
{
label: 'Collapsible Field',
type: 'collapsible',
admin: {
description: 'This is a collapsible field.',
},
fields: [
{
name: 'text',
type: 'text',
required: true,
},
],
},
],
},
{
slug: 'rich-text-fields',
fields: [
{
name: 'richText',
type: 'richText',
required: true,
},
],
},
{
slug: 'text-fields',
admin: {
useAsTitle: 'text',
},
fields: [
{
name: 'text',
type: 'text',
required: true,
},
],
},
ArrayFields,
BlockFields,
CollapsibleFields,
RichTextFields,
SelectFields,
TextFields,
],
onInit: async (payload) => {
await payload.create({
@@ -120,6 +40,11 @@ export default buildConfig({
data: collapsibleDoc,
});
await payload.create({
collection: 'select-fields',
data: selectsDoc,
});
const createdTextDoc = await payload.create({
collection: 'text-fields',
data: textDoc,