fix: properly sets tabs key in fieldSchemaToJSON (#4317)
This commit is contained in:
@@ -74,7 +74,7 @@ export const fieldSchemaToJSON = (fields: Field[]): FieldSchemaJSON => {
|
||||
tabFields.push({
|
||||
name: tab.name,
|
||||
fields: fieldSchemaToJSON(tab.fields),
|
||||
type: 'tab',
|
||||
type: field.type,
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
@@ -121,6 +121,23 @@ export const Pages: CollectionConfig = {
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
label: 'Named Tabs',
|
||||
type: 'tabs',
|
||||
tabs: [
|
||||
{
|
||||
name: 'tab',
|
||||
label: 'Tab',
|
||||
fields: [
|
||||
{
|
||||
name: 'relationshipInTab',
|
||||
type: 'relationship',
|
||||
relationTo: 'posts',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
|
||||
@@ -307,6 +307,27 @@ describe('Collections - Live Preview', () => {
|
||||
expect(merge2.relationshipPolyHasMany).toEqual([])
|
||||
})
|
||||
|
||||
it('— relationships - populates within tabs', async () => {
|
||||
const initialData: Partial<Page> = {
|
||||
title: 'Test Page',
|
||||
}
|
||||
|
||||
const merge1 = await mergeData({
|
||||
depth: 1,
|
||||
fieldSchema: schemaJSON,
|
||||
incomingData: {
|
||||
...initialData,
|
||||
tab: {
|
||||
relationshipInTab: testPost.id,
|
||||
},
|
||||
},
|
||||
initialData,
|
||||
serverURL,
|
||||
})
|
||||
|
||||
expect(merge1.tab.relationshipInTab).toMatchObject(testPost)
|
||||
})
|
||||
|
||||
it('— relationships - populates within arrays', async () => {
|
||||
const initialData: Partial<Page> = {
|
||||
title: 'Test Page',
|
||||
|
||||
@@ -152,11 +152,6 @@ export interface Page {
|
||||
}
|
||||
)[]
|
||||
| null
|
||||
meta?: {
|
||||
title?: string | null
|
||||
description?: string | null
|
||||
image?: string | Media | null
|
||||
}
|
||||
relationshipInRichText?:
|
||||
| {
|
||||
[k: string]: unknown
|
||||
@@ -198,6 +193,14 @@ export interface Page {
|
||||
id?: string | null
|
||||
}[]
|
||||
| null
|
||||
tab: {
|
||||
relationshipInTab?: (string | null) | Post
|
||||
}
|
||||
meta?: {
|
||||
title?: string | null
|
||||
description?: string | null
|
||||
image?: string | Media | null
|
||||
}
|
||||
updatedAt: string
|
||||
createdAt: string
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user