fix(ui): avoid calling getTableState from join field on create (#9256)

### What?
Fixes the issue when visiting the create view with the Join Field and
using postgres adapter
```
invalid input syntax for type integer: "NaN"
```
This happens because we don't have an ID yet and we send to the
database:
`WHERE id = NaN`

### How?
Avoids calling `getTableState` inside of `RelationshipTable` if there's
no ID yet, as it will always lead to the same empty result. While we
_could_ avoid error directly in the database adapter, I don't think we
should do that render request

Fixes https://github.com/payloadcms/payload/issues/9193
This commit is contained in:
Sasha
2024-11-17 18:32:50 +02:00
committed by GitHub
parent d21fca9156
commit ef2475d804
3 changed files with 25 additions and 5 deletions

View File

@@ -5,7 +5,12 @@ import { reorderColumns } from 'helpers/e2e/reorderColumns.js'
import * as path from 'path'
import { fileURLToPath } from 'url'
import { ensureCompilationIsDone, exactText, initPageConsoleErrorCatch } from '../helpers.js'
import {
ensureCompilationIsDone,
exactText,
initPageConsoleErrorCatch,
saveDocAndAssert,
} from '../helpers.js'
import { AdminUrlUtil } from '../helpers/adminUrlUtil.js'
import { navigateToDoc } from '../helpers/e2e/navigateToDoc.js'
import { initPayloadE2ENoConfig } from '../helpers/initPayloadE2ENoConfig.js'
@@ -57,6 +62,14 @@ test.describe('Admin Panel', () => {
expect(columns).toBe(3)
})
test('should render the create page and create doc with the join field', async () => {
await page.goto(categoriesURL.create)
const nameField = page.locator('#field-name')
await expect(nameField).toBeVisible()
await nameField.fill('test category')
await saveDocAndAssert(page)
})
test('should render collection type in first column of relationship table', async () => {
await navigateToDoc(page, categoriesURL)
const joinField = page.locator('.field-type.join').first()