test: passing array fields test suite (#5383)

* test: array tests passing except bulk update

* test: passing array fields test suite
This commit is contained in:
Patrik
2024-03-20 12:00:56 -04:00
committed by GitHub
parent 0dd0f39250
commit cb5d005e68
62 changed files with 227 additions and 122 deletions

View File

@@ -1,8 +1,13 @@
'use client'
import type { RowLabelComponent } from 'payload/types'
import React from 'react'
export const ArrayRowLabel: RowLabelComponent = ({ data }) => {
import { useRowLabel } from '../../../../packages/ui/src/forms/RowLabel/Context/index.js'
export const ArrayRowLabel: RowLabelComponent = () => {
const { data } = useRowLabel<{ title: string }>()
return (
<div style={{ color: 'coral', textTransform: 'uppercase' }}>{data.title || 'Untitled'}</div>
)

View File

@@ -112,22 +112,6 @@ const ArrayFields: CollectionConfig = {
],
type: 'array',
},
{
name: 'rowLabelAsFunction',
admin: {
components: {
RowLabel: ({ data }) => data.title,
},
description: 'Row labels rendered from a function.',
},
fields: [
{
name: 'title',
type: 'text',
},
],
type: 'array',
},
{
name: 'rowLabelAsComponent',
admin: {

View File

@@ -1,7 +1,19 @@
import type { ArrayField } from '../../payload-types.js'
export const arrayDoc: Partial<ArrayField> = {
title: 'array doc 1',
arrayWithMinRows: [
{
text: 'first row',
},
{
text: 'second row',
},
],
collapsedArray: [
{
text: 'initialize collapsed',
},
],
items: [
{
text: 'first row',
@@ -22,11 +34,10 @@ export const arrayDoc: Partial<ArrayField> = {
text: 'sixth row',
},
],
collapsedArray: [
{
text: 'initialize collapsed',
},
],
title: 'array doc 1',
}
export const anotherArrayDoc: Partial<ArrayField> = {
arrayWithMinRows: [
{
text: 'first row',
@@ -35,10 +46,11 @@ export const arrayDoc: Partial<ArrayField> = {
text: 'second row',
},
],
}
export const anotherArrayDoc: Partial<ArrayField> = {
title: 'array doc 2',
collapsedArray: [
{
text: 'initialize collapsed',
},
],
items: [
{
text: 'first row',
@@ -50,17 +62,5 @@ export const anotherArrayDoc: Partial<ArrayField> = {
text: 'third row',
},
],
collapsedArray: [
{
text: 'initialize collapsed',
},
],
arrayWithMinRows: [
{
text: 'first row',
},
{
text: 'second row',
},
],
title: 'array doc 2',
}