fix: #3541
This commit is contained in:
2
.vscode/launch.json
vendored
2
.vscode/launch.json
vendored
@@ -17,7 +17,7 @@
|
||||
"type": "node-terminal"
|
||||
},
|
||||
{
|
||||
"command": "pnpm run dev:postgres collections-graphql",
|
||||
"command": "pnpm run dev:postgres fields",
|
||||
"cwd": "${workspaceFolder}",
|
||||
"name": "Run Dev Postgres",
|
||||
"request": "launch",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* eslint-disable no-param-reassign */
|
||||
import type { Field } from 'payload/types'
|
||||
|
||||
import { fieldAffectsData } from 'payload/types'
|
||||
import { fieldAffectsData, tabHasName } from 'payload/types'
|
||||
import toSnakeCase from 'to-snake-case'
|
||||
|
||||
import type { PostgresAdapter } from '../types'
|
||||
@@ -31,6 +31,42 @@ export const traverseFields = ({
|
||||
topLevelTableName,
|
||||
}: TraverseFieldArgs) => {
|
||||
fields.forEach((field) => {
|
||||
if (field.type === 'collapsible' || field.type === 'row') {
|
||||
traverseFields({
|
||||
_locales,
|
||||
adapter,
|
||||
currentArgs,
|
||||
currentTableName,
|
||||
depth,
|
||||
fields: field.fields,
|
||||
path,
|
||||
topLevelArgs,
|
||||
topLevelTableName,
|
||||
})
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
if (field.type === 'tabs') {
|
||||
field.tabs.forEach((tab) => {
|
||||
const tabPath = tabHasName(tab) ? `${path}${tab.name}_` : path
|
||||
|
||||
traverseFields({
|
||||
_locales,
|
||||
adapter,
|
||||
currentArgs,
|
||||
currentTableName,
|
||||
depth,
|
||||
fields: tab.fields,
|
||||
path: tabPath,
|
||||
topLevelArgs,
|
||||
topLevelTableName,
|
||||
})
|
||||
})
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
if (fieldAffectsData(field)) {
|
||||
switch (field.type) {
|
||||
case 'array': {
|
||||
|
||||
@@ -406,7 +406,7 @@ export const traverseFields = ({
|
||||
indexes,
|
||||
localesColumns,
|
||||
localesIndexes,
|
||||
newTableName: parentTableName,
|
||||
newTableName,
|
||||
parentTableName,
|
||||
relationsToBuild,
|
||||
relationships,
|
||||
|
||||
@@ -79,42 +79,43 @@ describe('fields', () => {
|
||||
await expect(textCell).toHaveText(String(numberDoc.number))
|
||||
})
|
||||
|
||||
|
||||
test('should filter Number fields in the collection view - greaterThanOrEqual', async () => {
|
||||
await page.goto(url.list);
|
||||
await page.goto(url.list)
|
||||
|
||||
// should have 3 entries
|
||||
await expect(page.locator('table >> tbody >> tr')).toHaveCount(3);
|
||||
await expect(page.locator('table >> tbody >> tr')).toHaveCount(3)
|
||||
|
||||
// open the filter options
|
||||
await page.locator('.list-controls__toggle-where').click();
|
||||
await expect(page.locator('.list-controls__where.rah-static--height-auto')).toBeVisible();
|
||||
await page.locator('.where-builder__add-first-filter').click();
|
||||
await page.locator('.list-controls__toggle-where').click()
|
||||
await expect(page.locator('.list-controls__where.rah-static--height-auto')).toBeVisible()
|
||||
await page.locator('.where-builder__add-first-filter').click()
|
||||
|
||||
const initialField = page.locator('.condition__field');
|
||||
const operatorField = page.locator('.condition__operator');
|
||||
const valueField = page.locator('.condition__value >> input');
|
||||
const initialField = page.locator('.condition__field')
|
||||
const operatorField = page.locator('.condition__operator')
|
||||
const valueField = page.locator('.condition__value >> input')
|
||||
|
||||
// select Number field to filter on
|
||||
await initialField.click();
|
||||
const initialFieldOptions = initialField.locator('.rs__option');
|
||||
await initialFieldOptions.locator('text=number').first().click();
|
||||
expect(initialField.locator('.rs__single-value')).toContainText('Number');
|
||||
await initialField.click()
|
||||
const initialFieldOptions = initialField.locator('.rs__option')
|
||||
await initialFieldOptions.locator('text=number').first().click()
|
||||
await expect(initialField.locator('.rs__single-value')).toContainText('Number')
|
||||
|
||||
// select >= operator
|
||||
await operatorField.click();
|
||||
const operatorOptions = operatorField.locator('.rs__option');
|
||||
await operatorOptions.last().click();
|
||||
expect(operatorField.locator('.rs__single-value')).toContainText('is greater than or equal to');
|
||||
await operatorField.click()
|
||||
const operatorOptions = operatorField.locator('.rs__option')
|
||||
await operatorOptions.last().click()
|
||||
await expect(operatorField.locator('.rs__single-value')).toContainText(
|
||||
'is greater than or equal to',
|
||||
)
|
||||
|
||||
// enter value of 3
|
||||
await valueField.fill('3');
|
||||
await expect(valueField).toHaveValue('3');
|
||||
await wait(300);
|
||||
await valueField.fill('3')
|
||||
await expect(valueField).toHaveValue('3')
|
||||
await wait(300)
|
||||
|
||||
// should have 2 entries after filtering
|
||||
await expect(page.locator('table >> tbody >> tr')).toHaveCount(2);
|
||||
});
|
||||
await expect(page.locator('table >> tbody >> tr')).toHaveCount(2)
|
||||
})
|
||||
|
||||
test('should create', async () => {
|
||||
const input = 5
|
||||
@@ -676,6 +677,22 @@ describe('fields', () => {
|
||||
await page.locator('.tabs-field__tab-button:has-text("Tab with Row")').click()
|
||||
await expect(page.locator('#field-textInRow')).toHaveValue(textInRowValue)
|
||||
})
|
||||
|
||||
test('should render array data within unnamed tabs', async () => {
|
||||
await page.goto(url.list)
|
||||
await page.locator('.cell-id a').click()
|
||||
await page.locator('.tabs-field__tab-button:has-text("Tab with Array")').click()
|
||||
await expect(page.locator('#field-array__0__text')).toHaveValue("Hello, I'm the first row")
|
||||
})
|
||||
|
||||
test('should render array data within named tabs', async () => {
|
||||
await page.goto(url.list)
|
||||
await page.locator('.cell-id a').click()
|
||||
await page.locator('.tabs-field__tab-button:nth-child(5)').click()
|
||||
await expect(page.locator('#field-tab__array__0__text')).toHaveValue(
|
||||
"Hello, I'm the first row, in a named tab",
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
describe('richText', () => {
|
||||
|
||||
Reference in New Issue
Block a user