fix(drizzle): row / collapsible inside of localized fields (#8539)
Fixes https://github.com/payloadcms/payload/issues/8405
This commit is contained in:
@@ -1,10 +1,26 @@
|
||||
import type { CollectionConfig } from 'payload/types'
|
||||
import type { CollectionConfig } from 'payload'
|
||||
|
||||
export const groupSlug = 'groups'
|
||||
|
||||
export const Group: CollectionConfig = {
|
||||
slug: groupSlug,
|
||||
fields: [
|
||||
{
|
||||
name: 'groupLocalizedRow',
|
||||
type: 'group',
|
||||
localized: true,
|
||||
fields: [
|
||||
{
|
||||
type: 'row',
|
||||
fields: [
|
||||
{
|
||||
name: 'text',
|
||||
type: 'text',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'groupLocalized',
|
||||
type: 'group',
|
||||
@@ -16,6 +32,7 @@ export const Group: CollectionConfig = {
|
||||
],
|
||||
localized: true,
|
||||
},
|
||||
|
||||
{
|
||||
name: 'group',
|
||||
type: 'group',
|
||||
|
||||
@@ -1452,6 +1452,42 @@ describe('Localization', () => {
|
||||
expect(docEs.deep.blocks[0].title).toBe('hello es')
|
||||
})
|
||||
|
||||
it('should create/updated/read localized group with row field', async () => {
|
||||
const doc = await payload.create({
|
||||
collection: 'groups',
|
||||
data: {
|
||||
groupLocalizedRow: {
|
||||
text: 'hello world',
|
||||
},
|
||||
},
|
||||
locale: 'en',
|
||||
})
|
||||
|
||||
expect(doc.groupLocalizedRow.text).toBe('hello world')
|
||||
|
||||
const docES = await payload.update({
|
||||
collection: 'groups',
|
||||
data: {
|
||||
groupLocalizedRow: {
|
||||
text: 'hola world or something',
|
||||
},
|
||||
},
|
||||
locale: 'es',
|
||||
id: doc.id,
|
||||
})
|
||||
|
||||
expect(docES.groupLocalizedRow.text).toBe('hola world or something')
|
||||
|
||||
// check if docES didnt break EN
|
||||
const docEN = await payload.findByID({ collection: 'groups', id: doc.id, locale: 'en' })
|
||||
expect(docEN.groupLocalizedRow.text).toBe('hello world')
|
||||
|
||||
const all = await payload.findByID({ collection: 'groups', id: doc.id, locale: 'all' })
|
||||
|
||||
expect(all.groupLocalizedRow.en.text).toBe('hello world')
|
||||
expect(all.groupLocalizedRow.es.text).toBe('hola world or something')
|
||||
})
|
||||
|
||||
it('should properly create/update/read localized tab field', async () => {
|
||||
const result = await payload.create({
|
||||
collection: tabSlug,
|
||||
|
||||
@@ -402,6 +402,9 @@ export interface Group {
|
||||
groupLocalized?: {
|
||||
title?: string | null;
|
||||
};
|
||||
groupLocalizedRow?: {
|
||||
text?: string | null;
|
||||
};
|
||||
group?: {
|
||||
title?: string | null;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user