fix(ui): incorrect conditions in WhereBuilder (#5503)

* fix: relationship field tests e2e

* chore: adds POLL_TOPASS_TIMEOUT to relationship field tests

* chore: adds comments to relationship test waits
This commit is contained in:
Patrik
2024-03-28 13:14:00 -04:00
committed by GitHub
parent c1d654c4ce
commit 5873dfb731
4 changed files with 51 additions and 43 deletions

View File

@@ -17,6 +17,7 @@ import {
import { AdminUrlUtil } from '../helpers/adminUrlUtil.js'
import { initPayloadE2E } from '../helpers/initPayloadE2E.js'
import { RESTClient } from '../helpers/rest.js'
import { POLL_TOPASS_TIMEOUT } from '../playwright.config.js'
import { jsonDoc } from './collections/JSON/shared.js'
import { numberDoc } from './collections/Number/shared.js'
import { textDoc } from './collections/Text/shared.js'
@@ -32,7 +33,7 @@ import {
const filename = fileURLToPath(import.meta.url)
const dirname = path.dirname(filename)
const { afterEach, beforeAll, beforeEach, describe } = test
const { beforeAll, beforeEach, describe } = test
let payload: Payload
let client: RESTClient
@@ -1494,14 +1495,6 @@ describe('fields', () => {
url = new AdminUrlUtil(serverURL, 'relationship-fields')
})
afterEach(async () => {
// delete all existing relationship documents
await payload.delete({
collection: relationshipFieldsSlug,
where: { id: { exists: true } },
})
})
test('should create inline relationship within field with many relations', async () => {
await page.goto(url.create)
@@ -1530,7 +1523,7 @@ describe('fields', () => {
test('should create nested inline relationships', async () => {
await page.goto(url.create)
await page.waitForURL(`**/${url.create}`)
// Open first modal
await page.locator('#relationToSelf-add-new .relationship-add-new__add-button').click()
@@ -1557,7 +1550,7 @@ describe('fields', () => {
// Save then close the second modal
await page.locator('[id^=doc-drawer_relationship-fields_2_] #action-save').click()
await wait(200)
await expect.poll(() => page.url(), { timeout: POLL_TOPASS_TIMEOUT }).toContain('create')
await page.locator('[id^=close-drawer__doc-drawer_relationship-fields_2_]').click()
// Assert that the first modal is still open and the value matches
@@ -1570,7 +1563,7 @@ describe('fields', () => {
// Save then close the first modal
await page.locator('[id^=doc-drawer_relationship-fields_1_] #action-save').click()
await wait(200)
await expect.poll(() => page.url(), { timeout: POLL_TOPASS_TIMEOUT }).toContain('create')
await page.locator('[id^=close-drawer__doc-drawer_relationship-fields_1_]').click()
// Expect the original field to have a value filled
@@ -1581,7 +1574,7 @@ describe('fields', () => {
// Fill the required field
await page.locator('#field-relationship').click()
await page.locator('.rs__option:has-text("Seeded text document")').click()
await expect.poll(() => page.url(), { timeout: POLL_TOPASS_TIMEOUT }).toContain('create')
await page.locator('#action-save').click()
await expect(page.locator('.Toastify')).toContainText('successfully')
@@ -1662,7 +1655,7 @@ describe('fields', () => {
// Related issue: https://github.com/payloadcms/payload/issues/2815
test('should modify fields in relationship drawer', async () => {
await page.goto(url.create)
await page.waitForURL(`**/${url.create}`)
// First fill out the relationship field, as it's required
await page.locator('#relationship-add-new .relationship-add-new__add-button').click()
await page
@@ -1678,12 +1671,10 @@ describe('fields', () => {
await expect(page.locator('.Toastify')).toContainText('successfully')
// Create a new doc for the `relationshipHasMany` field
await page
.locator('#field-relationshipHasMany button.relationship-add-new__add-button')
.click()
const textField2 = page.locator('[id^=doc-drawer_text-fields_1_] #field-text')
await expect.poll(() => page.url(), { timeout: POLL_TOPASS_TIMEOUT }).not.toContain('create')
await page.locator('#field-relationshipHasMany .relationship-add-new__add-button').click()
const value = 'Hello, world!'
await textField2.fill(value)
await page.locator('.drawer__content #field-text').fill(value)
// Save and close the drawer
await page.locator('[id^=doc-drawer_text-fields_1_] #action-save').click()
@@ -1731,13 +1722,16 @@ describe('fields', () => {
// opened through the edit button can be saved using the hotkey.
test('should save using hotkey in edit document drawer', async () => {
await page.goto(url.create)
// First fill out the relationship field, as it's required
await page.locator('#relationship-add-new .relationship-add-new__add-button').click()
await page.locator('#field-relationship .value-container').click()
// Select "Seeded text document" relationship
await page.getByText('Seeded text document', { exact: true }).click()
// Need to wait to properly open drawer - without this the drawer state is flakey and closes before
// the text below can be filled before the save on the drawer
await wait(200)
// Click edit button which opens drawer
await page.getByRole('button', { name: 'Edit Seeded text document' }).click()
@@ -1778,19 +1772,24 @@ describe('fields', () => {
test('should fail min rows validation when rows are present', async () => {
await page.goto(url.create)
// First fill out the relationship field, as it's required
await page.locator('#relationship-add-new .relationship-add-new__add-button').click()
await page.locator('#field-relationship .value-container').click()
await page.getByText('Seeded text document', { exact: true }).click()
// Need to wait to allow for field to retrieve documents before the save occurs
await wait(200)
await page.locator('#field-relationshipWithMinRows .value-container').click()
await page
.locator('#field-relationshipWithMinRows .rs__option:has-text("Seeded text document")')
.click()
await page.click('#action-save', { delay: 100 })
await expect(page.locator('.Toastify')).toContainText('Please correct invalid fields')
await expect(page.locator('.Toastify')).toContainText(
'The following field is invalid: relationshipWithMinRows',
)
})
test('should sort relationship options by sortOptions property (ID in ascending order)', async () => {