From dbc4ce71e69e79476b1638e4b6530606c84bf1a7 Mon Sep 17 00:00:00 2001 From: Jarrod Flesch <30633324+JarrodMFlesch@users.noreply.github.com> Date: Thu, 9 Nov 2023 12:30:19 -0500 Subject: [PATCH] chore: fixes test suites that use clearAndSeedEverything (#4080) --- test/fields/collections/Array/index.ts | 28 - test/fields/collections/Array/shared.ts | 37 + test/fields/collections/Blocks/index.ts | 45 +- test/fields/collections/Blocks/shared.ts | 55 ++ test/fields/collections/Code/index.tsx | 82 -- test/fields/collections/Code/shared.ts | 82 ++ test/fields/collections/Collapsible/index.ts | 15 - test/fields/collections/Collapsible/shared.ts | 16 + .../collections/ConditionalLogic/index.ts | 6 - .../collections/ConditionalLogic/shared.ts | 7 + test/fields/collections/Date/index.ts | 9 - test/fields/collections/Date/shared.ts | 10 + test/fields/collections/Group/index.ts | 14 - test/fields/collections/Group/shared.ts | 15 + test/fields/collections/Indexed/index.ts | 2 - test/fields/collections/JSON/index.tsx | 10 - test/fields/collections/JSON/shared.ts | 11 + .../collections/LexicalMigrate/index.ts | 6 - .../collections/LexicalMigrate/shared.ts | 6 + test/fields/collections/Number/index.ts | 13 - test/fields/collections/Number/shared.ts | 15 + test/fields/collections/Point/index.ts | 6 - test/fields/collections/Point/shared.ts | 7 + test/fields/collections/Radio/index.ts | 4 - test/fields/collections/Radio/shared.ts | 5 + test/fields/collections/Select/index.ts | 8 - test/fields/collections/Select/shared.ts | 9 + test/fields/collections/Tabs/index.ts | 56 +- test/fields/collections/Tabs/shared.ts | 55 ++ test/fields/collections/Text/shared.ts | 5 +- test/fields/collections/Upload/index.ts | 4 - test/fields/collections/Upload/shared.ts | 5 + test/fields/collections/Upload2/index.ts | 4 - test/fields/collections/Upload2/shared.ts | 5 + test/fields/collections/Uploads3/index.ts | 4 - test/fields/e2e.spec.ts | 4 +- test/fields/int.spec.ts | 14 +- test/fields/lexical.int.spec.ts | 2 +- test/fields/payload-types.ts | 807 +++++++++++------- test/fields/seed.ts | 32 +- 40 files changed, 897 insertions(+), 623 deletions(-) create mode 100644 test/fields/collections/Array/shared.ts create mode 100644 test/fields/collections/Blocks/shared.ts create mode 100644 test/fields/collections/Code/shared.ts create mode 100644 test/fields/collections/Collapsible/shared.ts create mode 100644 test/fields/collections/ConditionalLogic/shared.ts create mode 100644 test/fields/collections/Date/shared.ts create mode 100644 test/fields/collections/Group/shared.ts create mode 100644 test/fields/collections/JSON/shared.ts create mode 100644 test/fields/collections/LexicalMigrate/shared.ts create mode 100644 test/fields/collections/Number/shared.ts create mode 100644 test/fields/collections/Point/shared.ts create mode 100644 test/fields/collections/Radio/shared.ts create mode 100644 test/fields/collections/Select/shared.ts create mode 100644 test/fields/collections/Tabs/shared.ts create mode 100644 test/fields/collections/Upload/shared.ts create mode 100644 test/fields/collections/Upload2/shared.ts diff --git a/test/fields/collections/Array/index.ts b/test/fields/collections/Array/index.ts index 63092e07f5..f42aaf42eb 100644 --- a/test/fields/collections/Array/index.ts +++ b/test/fields/collections/Array/index.ts @@ -128,32 +128,4 @@ const ArrayFields: CollectionConfig = { ], } -export const arrayDoc = { - items: [ - { - text: 'first row', - }, - { - text: 'second row', - }, - { - text: 'third row', - }, - { - text: 'fourth row', - }, - { - text: 'fifth row', - }, - { - text: 'sixth row', - }, - ], - collapsedArray: [ - { - text: 'initialize collapsed', - }, - ], -} - export default ArrayFields diff --git a/test/fields/collections/Array/shared.ts b/test/fields/collections/Array/shared.ts new file mode 100644 index 0000000000..29fdf37672 --- /dev/null +++ b/test/fields/collections/Array/shared.ts @@ -0,0 +1,37 @@ +import type { ArrayField } from '../../payload-types' + +export const arrayDoc: Partial = { + items: [ + { + text: 'first row', + }, + { + text: 'second row', + }, + { + text: 'third row', + }, + { + text: 'fourth row', + }, + { + text: 'fifth row', + }, + { + text: 'sixth row', + }, + ], + collapsedArray: [ + { + text: 'initialize collapsed', + }, + ], + arrayWithMinRows: [ + { + text: 'first row', + }, + { + text: 'second row', + }, + ], +} diff --git a/test/fields/collections/Blocks/index.ts b/test/fields/collections/Blocks/index.ts index 377c72c09a..ec8e156652 100644 --- a/test/fields/collections/Blocks/index.ts +++ b/test/fields/collections/Blocks/index.ts @@ -3,45 +3,7 @@ import type { BlockField } from '../../../../packages/payload/src/fields/config/ import { blockFieldsSlug } from '../../slugs' import { AddCustomBlocks } from './components/AddCustomBlocks' - -export const getBlocksFieldSeedData = (prefix?: string): any => [ - { - blockName: 'First block', - blockType: prefix ? `${prefix}Content` : 'content', - text: 'first block', - richText: [ - { - children: [{ text: '' }], - }, - ], - }, - { - blockName: 'Second block', - blockType: prefix ? `${prefix}Number` : 'number', - number: 342, - }, - { - blockName: 'Sub-block demonstration', - blockType: prefix ? `${prefix}SubBlocks` : 'subBlocks', - subBlocks: [ - { - blockName: 'First sub block', - blockType: 'number', - number: 123, - }, - { - blockName: 'Second sub block', - blockType: 'text', - text: 'second sub block', - }, - ], - }, - { - blockName: 'I18n Block', - blockType: 'i18n-text', - text: 'first block', - }, -] +import { getBlocksFieldSeedData } from './shared' export const getBlocksField = (prefix?: string): BlockField => ({ name: 'blocks', @@ -282,9 +244,4 @@ const BlockFields: CollectionConfig = { ], } -export const blocksDoc = { - blocks: getBlocksFieldSeedData(), - localizedBlocks: getBlocksFieldSeedData('localized'), -} - export default BlockFields diff --git a/test/fields/collections/Blocks/shared.ts b/test/fields/collections/Blocks/shared.ts new file mode 100644 index 0000000000..820450e9ea --- /dev/null +++ b/test/fields/collections/Blocks/shared.ts @@ -0,0 +1,55 @@ +import type { BlockField } from '../../payload-types' + +export const getBlocksFieldSeedData = (prefix?: string): any => [ + { + blockName: 'First block', + blockType: prefix ? `${prefix}Content` : 'content', + text: 'first block', + richText: [ + { + children: [{ text: '' }], + }, + ], + }, + { + blockName: 'Second block', + blockType: prefix ? `${prefix}Number` : 'number', + number: 342, + }, + { + blockName: 'Sub-block demonstration', + blockType: prefix ? `${prefix}SubBlocks` : 'subBlocks', + subBlocks: [ + { + blockName: 'First sub block', + blockType: 'number', + number: 123, + }, + { + blockName: 'Second sub block', + blockType: 'text', + text: 'second sub block', + }, + ], + }, + { + blockName: 'I18n Block', + blockType: 'i18n-text', + text: 'first block', + }, +] + +export const blocksDoc: Partial = { + blocks: getBlocksFieldSeedData(), + localizedBlocks: getBlocksFieldSeedData('localized'), + blocksWithMinRows: [ + { + blockTitle: 'first row', + blockType: 'block', + }, + { + blockTitle: 'second row', + blockType: 'block', + }, + ], +} diff --git a/test/fields/collections/Code/index.tsx b/test/fields/collections/Code/index.tsx index 67562185ed..7b0892e4a5 100644 --- a/test/fields/collections/Code/index.tsx +++ b/test/fields/collections/Code/index.tsx @@ -1,5 +1,4 @@ import type { CollectionConfig } from '../../../../packages/payload/src/collections/config/types' -import type { CodeField } from '../../payload-types' import { codeFieldsSlug } from '../../slugs' @@ -44,85 +43,4 @@ const Code: CollectionConfig = { slug: codeFieldsSlug, } -export const codeDoc: Partial = { - css: `@import url(https://fonts.googleapis.com/css?family=Questrial); -@import url(https://fonts.googleapis.com/css?family=Arvo); - -@font-face { - src: url(https://lea.verou.me/logo.otf); - font-family: 'LeaVerou'; -} - -/* - Shared styles - */ - -section h1, -#features li strong, -header h2, -footer p { - font: 100% Rockwell, Arvo, serif; -} - -/* - Styles - */ - -* { - margin: 0; - padding: 0; -} - -body { - font: 100%/1.5 Questrial, sans-serif; - tab-size: 4; - hyphens: auto; -} - -a { - color: inherit; -} - -section h1 { - font-size: 250%; -}`, - html: ` - - - - - - -Prism - - - - - - - -`, - - javascript: "console.log('Hello');", - - json: JSON.stringify({ arr: ['val1', 'val2', 'val3'], property: 'value' }, null, 2), - - typescript: `class Greeter { - greeting: string; - - constructor(message: string) { - this.greeting = message; - } - - greet() { - return "Hello, " + this.greeting; - } -} - -let greeter = new Greeter("world");`, -} - export default Code diff --git a/test/fields/collections/Code/shared.ts b/test/fields/collections/Code/shared.ts new file mode 100644 index 0000000000..7781c2a45c --- /dev/null +++ b/test/fields/collections/Code/shared.ts @@ -0,0 +1,82 @@ +import type { CodeField } from '../../payload-types' + +export const codeDoc: Partial = { + css: `@import url(https://fonts.googleapis.com/css?family=Questrial); +@import url(https://fonts.googleapis.com/css?family=Arvo); + +@font-face { + src: url(https://lea.verou.me/logo.otf); + font-family: 'LeaVerou'; +} + +/* + Shared styles + */ + +section h1, +#features li strong, +header h2, +footer p { + font: 100% Rockwell, Arvo, serif; +} + +/* + Styles + */ + +* { + margin: 0; + padding: 0; +} + +body { + font: 100%/1.5 Questrial, sans-serif; + tab-size: 4; + hyphens: auto; +} + +a { + color: inherit; +} + +section h1 { + font-size: 250%; +}`, + html: ` + + + + + + +Prism + + + + + + + +`, + + javascript: "console.log('Hello');", + + json: JSON.stringify({ arr: ['val1', 'val2', 'val3'], property: 'value' }, null, 2), + + typescript: `class Greeter { + greeting: string; + + constructor(message: string) { + this.greeting = message; + } + + greet() { + return "Hello, " + this.greeting; + } +} + +let greeter = new Greeter("world");`, +} diff --git a/test/fields/collections/Collapsible/index.ts b/test/fields/collections/Collapsible/index.ts index bb4776c14d..3f565f9398 100644 --- a/test/fields/collections/Collapsible/index.ts +++ b/test/fields/collections/Collapsible/index.ts @@ -133,19 +133,4 @@ const CollapsibleFields: CollectionConfig = { ], } -export const collapsibleDoc = { - text: 'Seeded collapsible doc', - group: { - textWithinGroup: 'some text within a group', - subGroup: { - textWithinSubGroup: 'hello, get out', - }, - }, - arrayWithCollapsibles: [ - { - innerCollapsible: '', - }, - ], -} - export default CollapsibleFields diff --git a/test/fields/collections/Collapsible/shared.ts b/test/fields/collections/Collapsible/shared.ts new file mode 100644 index 0000000000..b3682461b4 --- /dev/null +++ b/test/fields/collections/Collapsible/shared.ts @@ -0,0 +1,16 @@ +import type { CollapsibleField } from '../../payload-types' + +export const collapsibleDoc: Partial = { + text: 'Seeded collapsible doc', + group: { + textWithinGroup: 'some text within a group', + subGroup: { + textWithinSubGroup: 'hello, get out', + }, + }, + arrayWithCollapsibles: [ + { + innerCollapsible: '', + }, + ], +} diff --git a/test/fields/collections/ConditionalLogic/index.ts b/test/fields/collections/ConditionalLogic/index.ts index 989786016e..40880f07b0 100644 --- a/test/fields/collections/ConditionalLogic/index.ts +++ b/test/fields/collections/ConditionalLogic/index.ts @@ -95,10 +95,4 @@ const ConditionalLogic: CollectionConfig = { ], } -export const conditionalLogicDoc = { - text: 'Seeded conditional logic document', - toggleField: true, - fieldToToggle: 'spiderman', -} - export default ConditionalLogic diff --git a/test/fields/collections/ConditionalLogic/shared.ts b/test/fields/collections/ConditionalLogic/shared.ts new file mode 100644 index 0000000000..1150c1afcb --- /dev/null +++ b/test/fields/collections/ConditionalLogic/shared.ts @@ -0,0 +1,7 @@ +import type { ConditionalLogic } from '../../payload-types' + +export const conditionalLogicDoc: Partial = { + text: 'Seeded conditional logic document', + toggleField: true, + fieldToToggle: 'spiderman', +} diff --git a/test/fields/collections/Date/index.ts b/test/fields/collections/Date/index.ts index 9be67b4864..1db214bbbf 100644 --- a/test/fields/collections/Date/index.ts +++ b/test/fields/collections/Date/index.ts @@ -64,13 +64,4 @@ const DateFields: CollectionConfig = { ], } -export const dateDoc = { - default: '2022-08-12T10:00:00.000+00:00', - timeOnly: '2022-08-12T10:00:00.157+00:00', - timeOnlyWithCustomFormat: '2022-08-12T10:00:00.157+00:00', - dayOnly: '2022-08-11T22:00:00.000+00:00', - dayAndTime: '2022-08-12T10:00:00.052+00:00', - monthOnly: '2022-07-31T22:00:00.000+00:00', -} - export default DateFields diff --git a/test/fields/collections/Date/shared.ts b/test/fields/collections/Date/shared.ts new file mode 100644 index 0000000000..77df1f85ac --- /dev/null +++ b/test/fields/collections/Date/shared.ts @@ -0,0 +1,10 @@ +import type { DateField } from '../../payload-types' + +export const dateDoc: Partial = { + default: '2022-08-12T10:00:00.000+00:00', + timeOnly: '2022-08-12T10:00:00.157+00:00', + timeOnlyWithCustomFormat: '2022-08-12T10:00:00.157+00:00', + dayOnly: '2022-08-11T22:00:00.000+00:00', + dayAndTime: '2022-08-12T10:00:00.052+00:00', + monthOnly: '2022-07-31T22:00:00.000+00:00', +} diff --git a/test/fields/collections/Group/index.ts b/test/fields/collections/Group/index.ts index 32f0a8db7c..3bd29ac111 100644 --- a/test/fields/collections/Group/index.ts +++ b/test/fields/collections/Group/index.ts @@ -169,18 +169,4 @@ const GroupFields: CollectionConfig = { ], } -export const groupDoc = { - group: { - text: 'some text within a group', - subGroup: { - textWithinGroup: 'please', - arrayWithinGroup: [ - { - textWithinArray: 'text in a group and array', - }, - ], - }, - }, -} - export default GroupFields diff --git a/test/fields/collections/Group/shared.ts b/test/fields/collections/Group/shared.ts new file mode 100644 index 0000000000..7585d7ba37 --- /dev/null +++ b/test/fields/collections/Group/shared.ts @@ -0,0 +1,15 @@ +import type { GroupField } from '../../payload-types' + +export const groupDoc: Partial = { + group: { + text: 'some text within a group', + subGroup: { + textWithinGroup: 'please', + arrayWithinGroup: [ + { + textWithinArray: 'text in a group and array', + }, + ], + }, + }, +} diff --git a/test/fields/collections/Indexed/index.ts b/test/fields/collections/Indexed/index.ts index 66949a2336..2b1bd28b06 100644 --- a/test/fields/collections/Indexed/index.ts +++ b/test/fields/collections/Indexed/index.ts @@ -17,8 +17,6 @@ const beforeDuplicate: BeforeDuplicate = ({ data }) => { ...(data.group || {}), localizedUnique: data.group?.localizedUnique ? `${data.group?.localizedUnique}-copy` : '', }, - partOne: data.partOne ? `${data.partOne}-copy` : '', - partTwo: data.partTwo ? `${data.partTwo}-copy` : '', uniqueText: data.uniqueText ? `${data.uniqueText}-copy` : '', } } diff --git a/test/fields/collections/JSON/index.tsx b/test/fields/collections/JSON/index.tsx index 4ab19dd0e9..840b10e5d7 100644 --- a/test/fields/collections/JSON/index.tsx +++ b/test/fields/collections/JSON/index.tsx @@ -25,14 +25,4 @@ const JSON: CollectionConfig = { }, } -export const jsonDoc: Partial = { - json: { - arr: ['val1', 'val2', 'val3'], - nested: { - value: 'nested value', - }, - property: 'value', - }, -} - export default JSON diff --git a/test/fields/collections/JSON/shared.ts b/test/fields/collections/JSON/shared.ts new file mode 100644 index 0000000000..6d43bd9ceb --- /dev/null +++ b/test/fields/collections/JSON/shared.ts @@ -0,0 +1,11 @@ +import type { JsonField } from '../../payload-types' + +export const jsonDoc: Partial = { + json: { + arr: ['val1', 'val2', 'val3'], + nested: { + value: 'nested value', + }, + property: 'value', + }, +} diff --git a/test/fields/collections/LexicalMigrate/index.ts b/test/fields/collections/LexicalMigrate/index.ts index 6f760181bc..f09158a85b 100644 --- a/test/fields/collections/LexicalMigrate/index.ts +++ b/test/fields/collections/LexicalMigrate/index.ts @@ -8,7 +8,6 @@ import { lexicalEditor, } from '../../../../packages/richtext-lexical/src' import { lexicalMigrateFieldsSlug } from '../../slugs' -import { payloadPluginLexicalData } from './generatePayloadPluginLexicalData' export const LexicalMigrateFields: CollectionConfig = { slug: lexicalMigrateFieldsSlug, @@ -66,8 +65,3 @@ export const LexicalMigrateFields: CollectionConfig = { }, ], } - -export const LexicalRichTextDoc = { - title: 'Rich Text', - lexicalWithLexicalPluginData: payloadPluginLexicalData, -} diff --git a/test/fields/collections/LexicalMigrate/shared.ts b/test/fields/collections/LexicalMigrate/shared.ts new file mode 100644 index 0000000000..78237f2b55 --- /dev/null +++ b/test/fields/collections/LexicalMigrate/shared.ts @@ -0,0 +1,6 @@ +import { payloadPluginLexicalData } from './generatePayloadPluginLexicalData' + +export const LexicalRichTextDoc = { + title: 'Rich Text', + richTextLexicalWithLexicalPluginData: payloadPluginLexicalData, +} diff --git a/test/fields/collections/Number/index.ts b/test/fields/collections/Number/index.ts index cbe7474eaa..e7a60d7b81 100644 --- a/test/fields/collections/Number/index.ts +++ b/test/fields/collections/Number/index.ts @@ -76,17 +76,4 @@ const NumberFields: CollectionConfig = { ], } -export const numberDoc = { - number: 5, - min: 15, - max: 5, - positiveNumber: 5, - negativeNumber: -5, - decimalMin: 1.25, - decimalMax: 0.25, - hasMany: [5, 10, 15], - validatesHasMany: [5], - localizedHasMany: [10], -} - export default NumberFields diff --git a/test/fields/collections/Number/shared.ts b/test/fields/collections/Number/shared.ts new file mode 100644 index 0000000000..690cf96eaa --- /dev/null +++ b/test/fields/collections/Number/shared.ts @@ -0,0 +1,15 @@ +import type { NumberField } from '../../payload-types' + +export const numberDoc: Partial = { + number: 5, + min: 15, + max: 5, + positiveNumber: 5, + negativeNumber: -5, + decimalMin: 1.25, + decimalMax: 0.25, + hasMany: [5, 10, 15], + validatesHasMany: [5], + localizedHasMany: [10], + withMinRows: [5, 10], +} diff --git a/test/fields/collections/Point/index.ts b/test/fields/collections/Point/index.ts index 8ebece236a..4ab0f2bc0b 100644 --- a/test/fields/collections/Point/index.ts +++ b/test/fields/collections/Point/index.ts @@ -35,10 +35,4 @@ const PointFields: CollectionConfig = { ], } -export const pointDoc = { - point: [7, -7], - localized: [15, -12], - group: { point: [1, 9] }, -} - export default PointFields diff --git a/test/fields/collections/Point/shared.ts b/test/fields/collections/Point/shared.ts new file mode 100644 index 0000000000..66fc5bfa85 --- /dev/null +++ b/test/fields/collections/Point/shared.ts @@ -0,0 +1,7 @@ +import type { PointField } from '../../payload-types' + +export const pointDoc: Partial = { + point: [7, -7], + localized: [15, -12], + group: { point: [1, 9] }, +} diff --git a/test/fields/collections/Radio/index.ts b/test/fields/collections/Radio/index.ts index 323b983669..7189e80365 100644 --- a/test/fields/collections/Radio/index.ts +++ b/test/fields/collections/Radio/index.ts @@ -30,8 +30,4 @@ const RadioFields: CollectionConfig = { ], } -export const radiosDoc = { - radio: 'one', -} - export default RadioFields diff --git a/test/fields/collections/Radio/shared.ts b/test/fields/collections/Radio/shared.ts new file mode 100644 index 0000000000..ac129a8a6d --- /dev/null +++ b/test/fields/collections/Radio/shared.ts @@ -0,0 +1,5 @@ +import type { RadioField } from '../../payload-types' + +export const radiosDoc: Partial = { + radio: 'one', +} diff --git a/test/fields/collections/Select/index.ts b/test/fields/collections/Select/index.ts index 4171997be4..42c18991f9 100644 --- a/test/fields/collections/Select/index.ts +++ b/test/fields/collections/Select/index.ts @@ -142,12 +142,4 @@ const SelectFields: CollectionConfig = { ], } -export const selectsDoc = { - select: 'one', - selectHasMany: ['two', 'four'], - settings: { - category: ['a'], - }, -} - export default SelectFields diff --git a/test/fields/collections/Select/shared.ts b/test/fields/collections/Select/shared.ts new file mode 100644 index 0000000000..beac1240c7 --- /dev/null +++ b/test/fields/collections/Select/shared.ts @@ -0,0 +1,9 @@ +import type { SelectField } from '../../payload-types' + +export const selectsDoc: Partial = { + select: 'one', + selectHasMany: ['two', 'four'], + settings: { + category: ['a'], + }, +} diff --git a/test/fields/collections/Tabs/index.ts b/test/fields/collections/Tabs/index.ts index 10f8ec607c..e49b0a0f9f 100644 --- a/test/fields/collections/Tabs/index.ts +++ b/test/fields/collections/Tabs/index.ts @@ -2,9 +2,9 @@ import type { CollectionConfig } from '../../../../packages/payload/src/collections/config/types' import { tabsFieldsSlug } from '../../slugs' -import { getBlocksField, getBlocksFieldSeedData } from '../Blocks' +import { getBlocksField } from '../Blocks' import { UIField } from './UIField' -import { localizedTextValue, namedTabDefaultValue, namedTabText } from './constants' +import { namedTabDefaultValue } from './constants' const TabsFields: CollectionConfig = { slug: tabsFieldsSlug, @@ -276,56 +276,4 @@ const TabsFields: CollectionConfig = { ], } -export const tabsDoc = { - array: [ - { - text: "Hello, I'm the first row", - }, - { - text: 'Second row here', - }, - { - text: 'Here is some data for the third row', - }, - ], - blocks: getBlocksFieldSeedData(), - group: { - number: 12, - }, - nestedTab: { - text: 'Some text in a nested, named tab', - }, - tab: { - array: [ - { - text: "Hello, I'm the first row, in a named tab", - }, - { - text: 'Second row here, in a named tab', - }, - { - text: 'Here is some data for the third row, in a named tab', - }, - ], - text: namedTabText, - }, - text: 'localized', - localizedTab: { - text: localizedTextValue, - }, - accessControlTab: { - text: 'cannot be read', - }, - hooksTab: { - beforeValidate: false, - beforeChange: false, - afterChange: false, - afterRead: false, - }, - textarea: 'Here is some text that goes in a textarea', - anotherText: 'Super tired of writing this text', - textInRow: 'hello', - numberInRow: 235, -} - export default TabsFields diff --git a/test/fields/collections/Tabs/shared.ts b/test/fields/collections/Tabs/shared.ts new file mode 100644 index 0000000000..98f983fa61 --- /dev/null +++ b/test/fields/collections/Tabs/shared.ts @@ -0,0 +1,55 @@ +import type { TabsField } from '../../payload-types' + +import { getBlocksFieldSeedData } from '../Blocks/shared' +import { localizedTextValue, namedTabText } from './constants' + +export const tabsDoc: Partial = { + array: [ + { + text: "Hello, I'm the first row", + }, + { + text: 'Second row here', + }, + { + text: 'Here is some data for the third row', + }, + ], + blocks: getBlocksFieldSeedData(), + group: { + number: 12, + }, + nestedTab: { + text: 'Some text in a nested, named tab', + }, + tab: { + array: [ + { + text: "Hello, I'm the first row, in a named tab", + }, + { + text: 'Second row here, in a named tab', + }, + { + text: 'Here is some data for the third row, in a named tab', + }, + ], + text: namedTabText, + }, + localizedTab: { + text: localizedTextValue, + }, + accessControlTab: { + text: 'cannot be read', + }, + hooksTab: { + beforeValidate: false, + beforeChange: false, + afterChange: false, + afterRead: false, + }, + textarea: 'Here is some text that goes in a textarea', + anotherText: 'Super tired of writing this text', + textInRow: 'hello', + numberInRow: 235, +} diff --git a/test/fields/collections/Text/shared.ts b/test/fields/collections/Text/shared.ts index bc2716a4e5..c7ed92011c 100644 --- a/test/fields/collections/Text/shared.ts +++ b/test/fields/collections/Text/shared.ts @@ -1,6 +1,9 @@ +import type { TextField } from '../../payload-types' + export const defaultText = 'default-text' export const textFieldsSlug = 'text-fields' -export const textDoc = { + +export const textDoc: Partial = { text: 'Seeded text document', localizedText: 'Localized text', } diff --git a/test/fields/collections/Upload/index.ts b/test/fields/collections/Upload/index.ts index ff48212080..2689275f0f 100644 --- a/test/fields/collections/Upload/index.ts +++ b/test/fields/collections/Upload/index.ts @@ -31,8 +31,4 @@ const Uploads: CollectionConfig = { ], } -export const uploadsDoc = { - text: 'An upload here', -} - export default Uploads diff --git a/test/fields/collections/Upload/shared.ts b/test/fields/collections/Upload/shared.ts new file mode 100644 index 0000000000..80789e936f --- /dev/null +++ b/test/fields/collections/Upload/shared.ts @@ -0,0 +1,5 @@ +import type { Upload } from '../../payload-types' + +export const uploadsDoc: Partial = { + text: 'An upload here', +} diff --git a/test/fields/collections/Upload2/index.ts b/test/fields/collections/Upload2/index.ts index e10ca95bfe..3ce779b5cc 100644 --- a/test/fields/collections/Upload2/index.ts +++ b/test/fields/collections/Upload2/index.ts @@ -26,8 +26,4 @@ const Uploads2: CollectionConfig = { ], } -export const uploadsDoc = { - text: 'An upload here', -} - export default Uploads2 diff --git a/test/fields/collections/Upload2/shared.ts b/test/fields/collections/Upload2/shared.ts new file mode 100644 index 0000000000..59b59f949f --- /dev/null +++ b/test/fields/collections/Upload2/shared.ts @@ -0,0 +1,5 @@ +import type { Uploads2 } from '../../payload-types' + +export const uploadsDoc: Partial = { + text: 'An upload here', +} diff --git a/test/fields/collections/Uploads3/index.ts b/test/fields/collections/Uploads3/index.ts index 5e080331d4..400a9fe66f 100644 --- a/test/fields/collections/Uploads3/index.ts +++ b/test/fields/collections/Uploads3/index.ts @@ -29,8 +29,4 @@ const Uploads3: CollectionConfig = { ], } -export const uploadsDoc = { - text: 'An upload here', -} - export default Uploads3 diff --git a/test/fields/e2e.spec.ts b/test/fields/e2e.spec.ts index be92ad95fa..544dd40456 100644 --- a/test/fields/e2e.spec.ts +++ b/test/fields/e2e.spec.ts @@ -10,8 +10,8 @@ import { exactText, saveDocAndAssert, saveDocHotkeyAndAssert } from '../helpers' import { AdminUrlUtil } from '../helpers/adminUrlUtil' import { initPayloadE2E } from '../helpers/configHelpers' import { RESTClient } from '../helpers/rest' -import { jsonDoc } from './collections/JSON' -import { numberDoc } from './collections/Number' +import { jsonDoc } from './collections/JSON/shared' +import { numberDoc } from './collections/Number/shared' import { textDoc } from './collections/Text/shared' import { clearAndSeedEverything } from './seed' import { diff --git a/test/fields/int.spec.ts b/test/fields/int.spec.ts index 6df6a78a41..aa0428f1d9 100644 --- a/test/fields/int.spec.ts +++ b/test/fields/int.spec.ts @@ -13,17 +13,19 @@ import { isMongoose } from '../helpers/isMongoose' import { RESTClient } from '../helpers/rest' import configPromise from '../uploads/config' import { arrayDefaultValue } from './collections/Array' -import { blocksDoc } from './collections/Blocks' -import { dateDoc } from './collections/Date' -import { groupDefaultChild, groupDefaultValue, groupDoc } from './collections/Group' -import { defaultNumber, numberDoc } from './collections/Number' -import { pointDoc } from './collections/Point' -import { tabsDoc } from './collections/Tabs' +import { blocksDoc } from './collections/Blocks/shared' +import { dateDoc } from './collections/Date/shared' +import { groupDefaultChild, groupDefaultValue } from './collections/Group' +import { groupDoc } from './collections/Group/shared' +import { defaultNumber } from './collections/Number' +import { numberDoc } from './collections/Number/shared' +import { pointDoc } from './collections/Point/shared' import { localizedTextValue, namedTabDefaultValue, namedTabText, } from './collections/Tabs/constants' +import { tabsDoc } from './collections/Tabs/shared' import { defaultText } from './collections/Text/shared' import { clearAndSeedEverything } from './seed' import { arrayFieldsSlug, groupFieldsSlug, relationshipFieldsSlug, tabsFieldsSlug } from './slugs' diff --git a/test/fields/lexical.int.spec.ts b/test/fields/lexical.int.spec.ts index 26c1875b48..6da5bd8f40 100644 --- a/test/fields/lexical.int.spec.ts +++ b/test/fields/lexical.int.spec.ts @@ -16,7 +16,7 @@ import payload from '../../packages/payload/src' import { initPayloadTest } from '../helpers/configHelpers' import { RESTClient } from '../helpers/rest' import configPromise from '../uploads/config' -import { arrayDoc } from './collections/Array' +import { arrayDoc } from './collections/Array/shared' import { lexicalDocData } from './collections/Lexical/data' import { richTextDocData } from './collections/RichText/data' import { generateLexicalRichText } from './collections/RichText/generateLexicalRichText' diff --git a/test/fields/payload-types.ts b/test/fields/payload-types.ts index 117020d338..aa929b1744 100644 --- a/test/fields/payload-types.ts +++ b/test/fields/payload-types.ts @@ -1,4 +1,5 @@ /* tslint:disable */ +/* eslint-disable */ /** * This file was automatically generated by Payload. * DO NOT MODIFY IT BY HAND. Instead, modify your source Payload config, @@ -7,9 +8,12 @@ export interface Config { collections: { + 'lexical-fields': LexicalField + 'lexical-migrate-fields': LexicalMigrateField users: User 'array-fields': ArrayField 'block-fields': BlockField + 'checkbox-fields': CheckboxField 'code-fields': CodeField 'collapsible-fields': CollapsibleField 'conditional-logic': ConditionalLogic @@ -29,53 +33,104 @@ export interface Config { uploads: Upload uploads2: Uploads2 uploads3: Uploads3 + 'payload-preferences': PayloadPreference + 'payload-migrations': PayloadMigration } globals: {} } +export interface LexicalField { + id: string + title: string + richTextLexicalSimple?: + | { + [k: string]: unknown + }[] + | null + richTextLexicalCustomFields: { + [k: string]: unknown + }[] + richTextLexicalWithLexicalPluginData?: + | { + [k: string]: unknown + }[] + | null + updatedAt: string + createdAt: string +} +export interface LexicalMigrateField { + id: string + title: string + richTextLexicalWithLexicalPluginData?: + | { + [k: string]: unknown + }[] + | null + updatedAt: string + createdAt: string +} export interface User { id: string - canViewConditionalField?: boolean + canViewConditionalField?: boolean | null updatedAt: string createdAt: string email: string - resetPasswordToken?: string - resetPasswordExpiration?: string - salt?: string - hash?: string - loginAttempts?: number - lockUntil?: string - password?: string + resetPasswordToken?: string | null + resetPasswordExpiration?: string | null + salt?: string | null + hash?: string | null + loginAttempts?: number | null + lockUntil?: string | null + password: string | null } export interface ArrayField { id: string items: { text: string - id?: string - }[] - collapsedArray?: { - text: string - id?: string + id?: string | null }[] + collapsedArray?: + | { + text: string + id?: string | null + }[] + | null localized: { text: string - id?: string - }[] - readOnly?: { - text?: string - id?: string - }[] - potentiallyEmptyArray?: { - text?: string - id?: string - }[] - rowLabelAsFunction?: { - title?: string - id?: string - }[] - rowLabelAsComponent?: { - title?: string - id?: string + id?: string | null }[] + readOnly?: + | { + text?: string | null + id?: string | null + }[] + | null + potentiallyEmptyArray?: + | { + text?: string | null + groupInRow?: { + textInGroupInRow?: string | null + } + id?: string | null + }[] + | null + rowLabelAsFunction?: + | { + title?: string | null + id?: string | null + }[] + | null + rowLabelAsComponent?: + | { + title?: string | null + id?: string | null + }[] + | null + arrayWithMinRows?: + | { + text?: string | null + id?: string | null + }[] + | null updatedAt: string createdAt: string } @@ -84,148 +139,218 @@ export interface BlockField { blocks: ( | { text: string - richText?: { - [k: string]: unknown - }[] - id?: string - blockName?: string - blockType: 'text' + richText?: + | { + [k: string]: unknown + }[] + | null + id?: string | null + blockName?: string | null + blockType: 'content' } | { number: number - id?: string - blockName?: string + id?: string | null + blockName?: string | null blockType: 'number' } | { - subBlocks?: ( - | { - text: string - id?: string - blockName?: string - blockType: 'text' - } - | { - number: number - id?: string - blockName?: string - blockType: 'number' - } - )[] - id?: string - blockName?: string + subBlocks?: + | ( + | { + text: string + id?: string | null + blockName?: string | null + blockType: 'text' + } + | { + number: number + id?: string | null + blockName?: string | null + blockType: 'number' + } + )[] + | null + id?: string | null + blockName?: string | null blockType: 'subBlocks' } | { - textInCollapsible?: string - textInRow?: string - id?: string - blockName?: string + textInCollapsible?: string | null + textInRow?: string | null + id?: string | null + blockName?: string | null blockType: 'tabs' } )[] collapsedByDefaultBlocks: ( | { text: string - richText?: { - [k: string]: unknown - }[] - id?: string - blockName?: string - blockType: 'text' + richText?: + | { + [k: string]: unknown + }[] + | null + id?: string | null + blockName?: string | null + blockType: 'localizedContent' } | { number: number - id?: string - blockName?: string - blockType: 'number' + id?: string | null + blockName?: string | null + blockType: 'localizedNumber' } | { - subBlocks?: ( - | { - text: string - id?: string - blockName?: string - blockType: 'text' - } - | { - number: number - id?: string - blockName?: string - blockType: 'number' - } - )[] - id?: string - blockName?: string - blockType: 'subBlocks' + subBlocks?: + | ( + | { + text: string + id?: string | null + blockName?: string | null + blockType: 'text' + } + | { + number: number + id?: string | null + blockName?: string | null + blockType: 'number' + } + )[] + | null + id?: string | null + blockName?: string | null + blockType: 'localizedSubBlocks' } | { - textInCollapsible?: string - textInRow?: string - id?: string - blockName?: string - blockType: 'tabs' + textInCollapsible?: string | null + textInRow?: string | null + id?: string | null + blockName?: string | null + blockType: 'localizedTabs' } )[] localizedBlocks: ( | { text: string - richText?: { - [k: string]: unknown - }[] - id?: string - blockName?: string - blockType: 'text' + richText?: + | { + [k: string]: unknown + }[] + | null + id?: string | null + blockName?: string | null + blockType: 'localizedContent' } | { number: number - id?: string - blockName?: string - blockType: 'number' + id?: string | null + blockName?: string | null + blockType: 'localizedNumber' } | { - subBlocks?: ( - | { - text: string - id?: string - blockName?: string - blockType: 'text' - } - | { - number: number - id?: string - blockName?: string - blockType: 'number' - } - )[] - id?: string - blockName?: string - blockType: 'subBlocks' + subBlocks?: + | ( + | { + text: string + id?: string | null + blockName?: string | null + blockType: 'text' + } + | { + number: number + id?: string | null + blockName?: string | null + blockType: 'number' + } + )[] + | null + id?: string | null + blockName?: string | null + blockType: 'localizedSubBlocks' } | { - textInCollapsible?: string - textInRow?: string - id?: string - blockName?: string - blockType: 'tabs' + textInCollapsible?: string | null + textInRow?: string | null + id?: string | null + blockName?: string | null + blockType: 'localizedTabs' } )[] - i18nBlocks?: { - text?: string - id?: string - blockName?: string - blockType: 'text' - }[] + i18nBlocks?: + | { + text?: string | null + id?: string | null + blockName?: string | null + blockType: 'text' + }[] + | null + blocksWithSimilarConfigs?: + | ( + | { + items?: + | { + title: string + id?: string | null + }[] + | null + id?: string | null + blockName?: string | null + blockType: 'block-a' + } + | { + items?: + | { + title2: string + id?: string | null + }[] + | null + id?: string | null + blockName?: string | null + blockType: 'block-b' + } + )[] + | null + blocksWithMinRows?: + | { + blockTitle?: string | null + id?: string | null + blockName?: string | null + blockType: 'block' + }[] + | null + customBlocks?: + | ( + | { + block1Title?: string | null + id?: string | null + blockName?: string | null + blockType: 'block-1' + } + | { + block2Title?: string | null + id?: string | null + blockName?: string | null + blockType: 'block-2' + } + )[] + | null + updatedAt: string + createdAt: string +} +export interface CheckboxField { + id: string + checkbox: boolean updatedAt: string createdAt: string } export interface CodeField { id: string - javascript?: string - typescript?: string - json?: string - html?: string - css?: string + javascript?: string | null + typescript?: string | null + json?: string | null + html?: string | null + css?: string | null updatedAt: string createdAt: string } @@ -233,44 +358,59 @@ export interface CollapsibleField { id: string text: string group?: { - textWithinGroup?: string + textWithinGroup?: string | null subGroup?: { - textWithinSubGroup?: string + textWithinSubGroup?: string | null } } - someText?: string - functionTitleField?: string - componentTitleField?: string - nestedTitle?: string - arrayWithCollapsibles?: { - innerCollapsible?: string - id?: string - }[] + someText?: string | null + functionTitleField?: string | null + componentTitleField?: string | null + nestedTitle?: string | null + arrayWithCollapsibles?: + | { + innerCollapsible?: string | null + id?: string | null + }[] + | null updatedAt: string createdAt: string } export interface ConditionalLogic { id: string text: string - toggleField?: boolean - fieldToToggle: string - userConditional?: string + toggleField?: boolean | null + fieldToToggle?: string | null + userConditional?: string | null + parentGroup?: { + enableParentGroupFields?: boolean | null + siblingField?: string | null + } + reliesOnParentGroup?: string | null + groupSelection?: ('group1' | 'group2') | null + group1?: { + group1Field?: string | null + } + group2?: { + group2Field?: string | null + } updatedAt: string createdAt: string } export interface DateField { id: string default: string - timeOnly?: string - dayOnly?: string - dayAndTime?: string - monthOnly?: string + timeOnly?: string | null + timeOnlyWithCustomFormat?: string | null + dayOnly?: string | null + dayAndTime?: string | null + monthOnly?: string | null updatedAt: string createdAt: string } export interface RadioField { id: string - radio?: 'one' | 'two' | 'three' + radio?: ('one' | 'two' | 'three') | null updatedAt: string createdAt: string } @@ -278,40 +418,42 @@ export interface GroupField { id: string group: { text: string - defaultParent?: string - defaultChild?: string + defaultParent?: string | null + defaultChild?: string | null subGroup?: { - textWithinGroup?: string - arrayWithinGroup?: { - textWithinArray?: string - id?: string - }[] + textWithinGroup?: string | null + arrayWithinGroup?: + | { + textWithinArray?: string | null + id?: string | null + }[] + | null } } potentiallyEmptyGroup?: { - text?: string + text?: string | null } groupInRow?: { - field?: string - secondField?: string - thirdField?: string + field?: string | null + secondField?: string | null + thirdField?: string | null } secondGroupInRow?: { - field?: string + field?: string | null nestedGroup?: { - nestedField?: string + nestedField?: string | null } } groups: { groupInRow?: { - field?: string - secondField?: string - thirdField?: string + field?: string | null + secondField?: string | null + thirdField?: string | null } secondGroupInRow?: { - field?: string + field?: string | null nestedGroup?: { - nestedField?: string + nestedField?: string | null } } } @@ -321,30 +463,33 @@ export interface GroupField { export interface RowField { id: string title: string + field_with_width_a?: string | null + field_with_width_b?: string | null + field_within_collapsible_a?: string | null + field_within_collapsible_b?: string | null updatedAt: string createdAt: string } export interface IndexedField { id: string text: string - uniqueText?: string + uniqueText?: string | null /** * @minItems 2 * @maxItems 2 */ - point?: [number, number] + point?: [number, number] | null group?: { - localizedUnique?: string + localizedUnique?: string | null + unique?: string | null /** * @minItems 2 * @maxItems 2 */ - point?: [number, number] + point?: [number, number] | null } - collapsibleLocalizedUnique?: string - collapsibleTextUnique?: string - partOne?: string - partTwo?: string + collapsibleLocalizedUnique?: string | null + collapsibleTextUnique?: string | null updatedAt: string createdAt: string } @@ -364,17 +509,18 @@ export interface JsonField { } export interface NumberField { id: string - number?: number - min?: number - max?: number - positiveNumber?: number - negativeNumber?: number - decimalMin?: number - decimalMax?: number - defaultNumber?: number - hasMany?: number[] - validatesHasMany?: number[] - localizedHasMany?: number[] + number?: number | null + min?: number | null + max?: number | null + positiveNumber?: number | null + negativeNumber?: number | null + decimalMin?: number | null + decimalMax?: number | null + defaultNumber?: number | null + hasMany?: number[] | null + validatesHasMany?: number[] | null + localizedHasMany?: number[] | null + withMinRows?: number[] | null updatedAt: string createdAt: string } @@ -389,124 +535,181 @@ export interface PointField { * @minItems 2 * @maxItems 2 */ - localized?: [number, number] + localized?: [number, number] | null group?: { /** * @minItems 2 * @maxItems 2 */ - point?: [number, number] + point?: [number, number] | null } updatedAt: string createdAt: string } export interface RelationshipField { id: string + text?: string | null relationship: | { - value: string | TextField relationTo: 'text-fields' + value: string | TextField } | { - value: string | ArrayField relationTo: 'array-fields' + value: string | ArrayField } - relationToSelf?: string | RelationshipField - relationToSelfSelectOnly?: string | RelationshipField - relationWithDynamicDefault?: string | User + relationToSelf?: (string | null) | RelationshipField + relationToSelfSelectOnly?: (string | null) | RelationshipField + relationWithDynamicDefault?: (string | null) | User relationHasManyWithDynamicDefault?: { - value: string | User relationTo: 'users' - } - relationshipWithMin?: string[] | TextField[] - relationshipWithMax?: string[] | TextField[] + value: string | User + } | null + relationshipWithMin?: (string | TextField)[] | null + relationshipWithMax?: (string | TextField)[] | null + relationshipHasMany?: (string | TextField)[] | null + array?: + | { + relationship?: (string | null) | TextField + id?: string | null + }[] + | null + relationshipWithMinRows?: + | { + relationTo: 'text-fields' + value: string | TextField + }[] + | null updatedAt: string createdAt: string } export interface TextField { id: string text: string - localizedText?: string - i18nText?: string - defaultFunction?: string - defaultAsync?: string - overrideLength?: string + localizedText?: string | null + i18nText?: string | null + defaultFunction?: string | null + defaultAsync?: string | null + overrideLength?: string | null + fieldWithDefaultValue?: string | null + dependentOnFieldWithDefaultValue?: string | null updatedAt: string createdAt: string } export interface RichTextField { id: string title: string - selectHasMany?: ('one' | 'two' | 'three' | 'four' | 'five' | 'six')[] + richTextLexicalCustomFields: { + [k: string]: unknown + }[] + richTextLexicalCustomFields_htmll?: string | null + richTextLexical?: + | { + [k: string]: unknown + }[] + | null + selectHasMany?: ('one' | 'two' | 'three' | 'four' | 'five' | 'six')[] | null richText: { [k: string]: unknown }[] - richTextCustomFields?: { - [k: string]: unknown - }[] - richTextReadOnly?: { - [k: string]: unknown - }[] + richTextCustomFields?: + | { + [k: string]: unknown + }[] + | null + richTextReadOnly?: + | { + [k: string]: unknown + }[] + | null + blocks?: + | ( + | { + text?: string | null + id?: string | null + blockName?: string | null + blockType: 'textBlock' + } + | { + text?: + | { + [k: string]: unknown + }[] + | null + id?: string | null + blockName?: string | null + blockType: 'richTextBlock' + } + )[] + | null updatedAt: string createdAt: string } export interface SelectField { id: string - select?: 'one' | 'two' | 'three' - selectReadOnly?: 'one' | 'two' | 'three' - selectHasMany?: ('one' | 'two' | 'three' | 'four' | 'five' | 'six')[] - selectHasManyLocalized?: ('one' | 'two')[] - selectI18n?: 'one' | 'two' | 'three' - simple?: 'One' | 'Two' | 'Three' + select?: ('one' | 'two' | 'three') | null + selectReadOnly?: ('one' | 'two' | 'three') | null + selectHasMany?: ('one' | 'two' | 'three' | 'four' | 'five' | 'six')[] | null + selectHasManyLocalized?: ('one' | 'two')[] | null + selectI18n?: ('one' | 'two' | 'three') | null + simple?: ('One' | 'Two' | 'Three') | null + settings?: { + category?: ('a' | 'b')[] | null + } updatedAt: string createdAt: string } export interface TabsField { id: string + sidebarField?: string | null array: { text: string - id?: string + id?: string | null }[] blocks: ( | { text: string - richText?: { - [k: string]: unknown - }[] - id?: string - blockName?: string - blockType: 'text' + richText?: + | { + [k: string]: unknown + }[] + | null + id?: string | null + blockName?: string | null + blockType: 'content' } | { number: number - id?: string - blockName?: string + id?: string | null + blockName?: string | null blockType: 'number' } | { - subBlocks?: ( - | { - text: string - id?: string - blockName?: string - blockType: 'text' - } - | { - number: number - id?: string - blockName?: string - blockType: 'number' - } - )[] - id?: string - blockName?: string + subBlocks?: + | ( + | { + text: string + id?: string | null + blockName?: string | null + blockType: 'text' + } + | { + number: number + id?: string | null + blockName?: string | null + blockType: 'number' + } + )[] + | null + id?: string | null + blockName?: string | null blockType: 'subBlocks' } | { - textInCollapsible?: string - textInRow?: string - id?: string - blockName?: string + textInCollapsible?: string | null + textInRow?: string | null + id?: string | null + blockName?: string | null blockType: 'tabs' } )[] @@ -518,75 +721,109 @@ export interface TabsField { tab: { array: { text: string - id?: string + id?: string | null }[] - text?: string - defaultValue?: string + text?: string | null + defaultValue?: string | null } namedTabWithDefaultValue: { - defaultValue?: string + defaultValue?: string | null } localizedTab: { - text?: string + text?: string | null } accessControlTab: { - text?: string + text?: string | null } hooksTab: { - beforeValidate?: boolean - beforeChange?: boolean - afterChange?: boolean - afterRead?: boolean + beforeValidate?: boolean | null + beforeChange?: boolean | null + afterChange?: boolean | null + afterRead?: boolean | null } - textarea?: string + textarea?: string | null anotherText: string nestedTab: { - text?: string + text?: string | null } updatedAt: string createdAt: string } export interface Upload { id: string - text?: string - media?: string | Upload - richText?: { - [k: string]: unknown - }[] + text?: string | null + media?: string | Upload | null + richText?: + | { + [k: string]: unknown + }[] + | null updatedAt: string createdAt: string - url?: string - filename?: string - mimeType?: string - filesize?: number - width?: number - height?: number + url?: string | null + filename?: string | null + mimeType?: string | null + filesize?: number | null + width?: number | null + height?: number | null } export interface Uploads2 { id: string - text?: string - media?: string | Uploads2 + text?: string | null + media?: string | Uploads2 | null updatedAt: string createdAt: string - url?: string - filename?: string - mimeType?: string - filesize?: number - width?: number - height?: number + url?: string | null + filename?: string | null + mimeType?: string | null + filesize?: number | null + width?: number | null + height?: number | null } export interface Uploads3 { id: string - media?: string | Uploads3 - richText?: { - [k: string]: unknown - }[] + media?: string | Uploads3 | null + richText?: + | { + [k: string]: unknown + }[] + | null updatedAt: string createdAt: string - url?: string - filename?: string - mimeType?: string - filesize?: number - width?: number - height?: number + url?: string | null + filename?: string | null + mimeType?: string | null + filesize?: number | null + width?: number | null + height?: number | null +} +export interface PayloadPreference { + id: string + user: { + relationTo: 'users' + value: string | User + } + key?: string | null + value?: + | { + [k: string]: unknown + } + | unknown[] + | string + | number + | boolean + | null + updatedAt: string + createdAt: string +} +export interface PayloadMigration { + id: string + name?: string | null + batch?: number | null + updatedAt: string + createdAt: string +} + +declare module 'payload' { + export interface GeneratedTypes extends Config {} } diff --git a/test/fields/seed.ts b/test/fields/seed.ts index 2242327ed0..85a4a5c7a5 100644 --- a/test/fields/seed.ts +++ b/test/fields/seed.ts @@ -4,24 +4,24 @@ import { type Payload } from '../../packages/payload/src' import getFileByPath from '../../packages/payload/src/uploads/getFileByPath' import { devUser } from '../credentials' import { seedDB } from '../helpers/seed' -import { arrayDoc } from './collections/Array' -import { blocksDoc } from './collections/Blocks' -import { codeDoc } from './collections/Code' -import { collapsibleDoc } from './collections/Collapsible' -import { conditionalLogicDoc } from './collections/ConditionalLogic' -import { dateDoc } from './collections/Date' -import { groupDoc } from './collections/Group' -import { jsonDoc } from './collections/JSON' +import { arrayDoc } from './collections/Array/shared' +import { blocksDoc } from './collections/Blocks/shared' +import { codeDoc } from './collections/Code/shared' +import { collapsibleDoc } from './collections/Collapsible/shared' +import { conditionalLogicDoc } from './collections/ConditionalLogic/shared' +import { dateDoc } from './collections/Date/shared' +import { groupDoc } from './collections/Group/shared' +import { jsonDoc } from './collections/JSON/shared' import { lexicalDocData } from './collections/Lexical/data' import { lexicalMigrateDocData } from './collections/LexicalMigrate/data' -import { numberDoc } from './collections/Number' -import { pointDoc } from './collections/Point' -import { radiosDoc } from './collections/Radio' +import { numberDoc } from './collections/Number/shared' +import { pointDoc } from './collections/Point/shared' +import { radiosDoc } from './collections/Radio/shared' import { richTextBulletsDocData, richTextDocData } from './collections/RichText/data' -import { selectsDoc } from './collections/Select' -import { tabsDoc } from './collections/Tabs' +import { selectsDoc } from './collections/Select/shared' +import { tabsDoc } from './collections/Tabs/shared' import { textDoc } from './collections/Text/shared' -import { uploadsDoc } from './collections/Upload' +import { uploadsDoc } from './collections/Upload/shared' import { arrayFieldsSlug, blockFieldsSlug, @@ -95,7 +95,9 @@ export async function clearAndSeedEverything(_payload: Payload) { const richTextDocWithRelationship = { ...richTextDocWithRelId } - const blocksDocWithRichText = { ...blocksDoc } + const blocksDocWithRichText = { + ...(blocksDoc as any), + } blocksDocWithRichText.blocks[0].richText = richTextDocWithRelationship.richText blocksDocWithRichText.localizedBlocks[0].richText = richTextDocWithRelationship.richText