chore: reduce getParentLabel logic and update test
This commit is contained in:
@@ -18,12 +18,7 @@ export function getParentLabels(
|
||||
break
|
||||
}
|
||||
|
||||
let fieldLabel = field.label ?? field.name
|
||||
if (field.labels && typeof field.labels === 'object' && field.labels.singular) {
|
||||
fieldLabel = field.labels.singular
|
||||
}
|
||||
|
||||
labels.push(fieldLabel)
|
||||
labels.push(field.label ?? segment)
|
||||
|
||||
// Loop the nested fields if they exist
|
||||
if (field.fields) {
|
||||
|
||||
@@ -158,7 +158,7 @@ describe('Array', () => {
|
||||
|
||||
await page.click('#action-save')
|
||||
await expect(page.locator('.payload-toast-container')).toContainText(
|
||||
'The following field is invalid: Nested Array With Labels 1 > First Child Array 1 > Second Child Array 1 > Child Without Label 1 > Custom Text Label',
|
||||
'The following field is invalid: Parent Array Label 1 > First Child Array Label 1 > Second Child Array Label 1 > Child Without Label 1 > Custom Text Label',
|
||||
)
|
||||
})
|
||||
|
||||
|
||||
@@ -263,10 +263,7 @@ const ArrayFields: CollectionConfig = {
|
||||
{
|
||||
name: 'nestedArrayWithLabels',
|
||||
type: 'array',
|
||||
labels: {
|
||||
singular: 'Nested Array With Labels',
|
||||
plural: 'Nested Arrays With Labels',
|
||||
},
|
||||
label: 'Parent Array Label',
|
||||
fields: [
|
||||
{
|
||||
name: 'firstChildArray',
|
||||
|
||||
Reference in New Issue
Block a user