fix: hidden and disabled fields cause incorrect field paths (#9680)

This commit is contained in:
Jacob Fletcher
2024-12-03 21:22:28 -05:00
committed by GitHub
parent fce210b9b1
commit a53c1d5517
26 changed files with 303 additions and 51 deletions

View File

@@ -1,18 +1,17 @@
import type { Page } from '@playwright/test'
import { expect } from '@playwright/test'
import { wait } from 'payload/shared'
import { exactText } from '../../helpers.js'
export const toggleColumn = async (
export const openListColumns = async (
page: Page,
{
togglerSelector = '.list-controls__toggle-columns',
columnContainerSelector = '.list-controls__columns',
columnLabel,
}: {
columnContainerSelector?: string
columnLabel: string
togglerSelector?: string
},
): Promise<any> => {
@@ -25,6 +24,25 @@ export const toggleColumn = async (
await expect(page.locator(`${columnContainerSelector}.rah-static--height-auto`)).toBeVisible()
return columnContainer
}
export const toggleColumn = async (
page: Page,
{
togglerSelector,
columnContainerSelector,
columnLabel,
targetState: targetStateFromArgs,
}: {
columnContainerSelector?: string
columnLabel: string
targetState?: 'off' | 'on'
togglerSelector?: string
},
): Promise<any> => {
const columnContainer = await openListColumns(page, { togglerSelector, columnContainerSelector })
const column = columnContainer.locator(`.column-selector .column-selector__column`, {
hasText: exactText(columnLabel),
})
@@ -33,16 +51,24 @@ export const toggleColumn = async (
el.classList.contains('column-selector__column--active'),
)
const targetState =
targetStateFromArgs !== undefined ? targetStateFromArgs : isActiveBeforeClick ? 'off' : 'on'
await expect(column).toBeVisible()
await column.click()
if (
(isActiveBeforeClick && targetState === 'off') ||
(!isActiveBeforeClick && targetState === 'on')
) {
await column.click()
}
if (isActiveBeforeClick) {
if (targetState === 'off') {
// no class
await expect(column).not.toHaveClass('column-selector__column--active')
await expect(column).not.toHaveClass(/column-selector__column--active/)
} else {
// has class
await expect(column).toHaveClass('column-selector__column--active')
await expect(column).toHaveClass(/column-selector__column--active/)
}
return column