fix: hidden and disabled fields cause incorrect field paths (#9680)
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user