Adds various helpers to make it easier and more standard to manage array fields within e2e tests. Retrofits existing tests to ensure consistent interactions across the board, and also organizes existing blocks and relationship field helpers in the same way. --- - To see the specific tasks where the Asana app for GitHub is being used, see below: - https://app.asana.com/0/0/1211094073049046
46 lines
1.1 KiB
TypeScript
46 lines
1.1 KiB
TypeScript
import type { Locator, Page } from 'playwright'
|
|
|
|
import { expect } from 'playwright/test'
|
|
|
|
/**
|
|
* Opens the row actions menu for the specified array row.
|
|
* If already open, does nothing.
|
|
*/
|
|
export const openArrayRowActions = async (
|
|
page: Page,
|
|
{
|
|
fieldName,
|
|
rowIndex = 0,
|
|
}: {
|
|
fieldName: string
|
|
rowIndex?: number
|
|
},
|
|
): Promise<{
|
|
popupContentLocator: Locator
|
|
rowActionsButtonLocator: Locator
|
|
}> => {
|
|
// replace double underscores with single hyphens for the row ID
|
|
const formattedRowID = fieldName.toString().replace(/__/g, '-')
|
|
|
|
const rowActions = page
|
|
.locator(`#field-${fieldName} #${formattedRowID}-row-${rowIndex} .array-actions`)
|
|
.first()
|
|
|
|
const popupContentLocator = rowActions.locator('.popup__content')
|
|
|
|
if (await popupContentLocator.isVisible()) {
|
|
throw new Error(`Row actions for field "${fieldName}" at index ${rowIndex} are already open.`)
|
|
}
|
|
|
|
const rowActionsButtonLocator = rowActions.locator(`.array-actions__button`)
|
|
|
|
await rowActionsButtonLocator.click()
|
|
|
|
await expect(popupContentLocator).toBeVisible()
|
|
|
|
return {
|
|
rowActionsButtonLocator,
|
|
popupContentLocator,
|
|
}
|
|
}
|