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
26 lines
738 B
TypeScript
26 lines
738 B
TypeScript
import type { Page } from '@playwright/test'
|
|
|
|
import { expect } from '@playwright/test'
|
|
|
|
export const removeAllBlocks = async ({
|
|
page,
|
|
fieldName = 'blocks',
|
|
}: {
|
|
fieldName: string
|
|
page: Page
|
|
}) => {
|
|
const blocksField = page.locator(`#field-${fieldName}`)
|
|
|
|
const blocks = blocksField.locator(`[id^="${fieldName}-row-"]`)
|
|
const count = await blocks.count()
|
|
|
|
expect(count).toBeGreaterThan(0)
|
|
|
|
for (let i = 0; i < count; i++) {
|
|
// delete in reverse order to avoid index issues
|
|
const block = blocksField.locator(`[id^="${fieldName}-row-${count - i - 1}"]`)
|
|
await block.locator('.array-actions__button').first().click()
|
|
await block.locator('.array-actions__action.array-actions__remove').first().click()
|
|
}
|
|
}
|