Compare commits

...

1 Commits

Author SHA1 Message Date
Sasha
3722308c3d write test 2025-05-27 17:48:33 +03:00
3 changed files with 92 additions and 0 deletions

View File

@@ -397,6 +397,37 @@ export default buildConfigWithDefaults({
],
},
LocalizedWithinLocalized,
{
slug: 'tabs-and-nested-group',
fields: [
{
name: 'title',
type: 'text',
},
{
type: 'tabs',
tabs: [
{
name: 'hero',
label: 'Hero',
localized: true,
fields: [
{
type: 'group',
name: 'group',
fields: [
{
name: 'heading',
type: 'text',
},
],
},
],
},
],
},
],
},
],
globals: [
{

View File

@@ -1894,6 +1894,28 @@ describe('Localization', () => {
expect(docEs.deep.array[0].title).toBe('hello es')
expect(docEs.deep.blocks[0].title).toBe('hello es')
})
it('should properly create/updated/read when localized tab has a group field', async () => {
const res = await payload.create({
collection: 'tabs-and-nested-group',
locale: 'en',
data: { hero: { group: { heading: 'EN' } } },
})
expect(res.hero?.group?.heading).toBe('EN')
const resES = await payload.update({
collection: 'tabs-and-nested-group',
locale: 'es',
id: res.id,
data: { hero: { group: { heading: 'ES' } } },
})
expect(resES.hero?.group?.heading).toBe('ES')
const resEN = await payload.findByID({
collection: 'tabs-and-nested-group',
locale: 'en',
id: res.id,
})
expect(resEN.hero?.group?.heading).toBe('EN')
})
})
// Nested localized fields do no longer have their localized property stripped in

View File

@@ -87,6 +87,7 @@ export interface Config {
'localized-sort': LocalizedSort;
'blocks-same-name': BlocksSameName;
'localized-within-localized': LocalizedWithinLocalized;
'tabs-and-nested-group': TabsAndNestedGroup;
'payload-locked-documents': PayloadLockedDocument;
'payload-preferences': PayloadPreference;
'payload-migrations': PayloadMigration;
@@ -113,6 +114,7 @@ export interface Config {
'localized-sort': LocalizedSortSelect<false> | LocalizedSortSelect<true>;
'blocks-same-name': BlocksSameNameSelect<false> | BlocksSameNameSelect<true>;
'localized-within-localized': LocalizedWithinLocalizedSelect<false> | LocalizedWithinLocalizedSelect<true>;
'tabs-and-nested-group': TabsAndNestedGroupSelect<false> | TabsAndNestedGroupSelect<true>;
'payload-locked-documents': PayloadLockedDocumentsSelect<false> | PayloadLockedDocumentsSelect<true>;
'payload-preferences': PayloadPreferencesSelect<false> | PayloadPreferencesSelect<true>;
'payload-migrations': PayloadMigrationsSelect<false> | PayloadMigrationsSelect<true>;
@@ -700,6 +702,21 @@ export interface LocalizedWithinLocalized {
updatedAt: string;
createdAt: string;
}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "tabs-and-nested-group".
*/
export interface TabsAndNestedGroup {
id: string;
title?: string | null;
hero?: {
group?: {
heading?: string | null;
};
};
updatedAt: string;
createdAt: string;
}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "payload-locked-documents".
@@ -786,6 +803,10 @@ export interface PayloadLockedDocument {
| ({
relationTo: 'localized-within-localized';
value: string | LocalizedWithinLocalized;
} | null)
| ({
relationTo: 'tabs-and-nested-group';
value: string | TabsAndNestedGroup;
} | null);
globalSlug?: string | null;
user: {
@@ -1346,6 +1367,24 @@ export interface LocalizedWithinLocalizedSelect<T extends boolean = true> {
updatedAt?: T;
createdAt?: T;
}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "tabs-and-nested-group_select".
*/
export interface TabsAndNestedGroupSelect<T extends boolean = true> {
title?: T;
hero?:
| T
| {
group?:
| T
| {
heading?: T;
};
};
updatedAt?: T;
createdAt?: T;
}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "payload-locked-documents_select".