Similar to the goals of #11026. Adds helper utilities to make interacting with the blocks field easier within e2e tests. This will also standardize common functionality across tests and reduce the overall lines of code for each, making them easier to navigate and digest. The following helpers are now available: - `openBlocksDrawer`: self-explanatory - `addBlock`: opens the blocks drawer and selects the given block - `reorderBlocks`: similar to `reorderColumn`, moves blocks using the drag handle - `removeAllBlocks`: iterates all rows of a given blocks field and removes them
23 lines
539 B
TypeScript
23 lines
539 B
TypeScript
import type { Locator, Page } from '@playwright/test'
|
|
|
|
import { expect } from '@playwright/test'
|
|
|
|
export const openBlocksDrawer = async ({
|
|
page,
|
|
fieldName = 'blocks',
|
|
}: {
|
|
fieldName: string
|
|
page: Page
|
|
}): Promise<Locator> => {
|
|
const blocksDrawer = page.locator('[id^=drawer_1_blocks-drawer-]')
|
|
|
|
if (!(await blocksDrawer.isVisible())) {
|
|
const addButton = page.locator(`#field-${fieldName} > .blocks-field__drawer-toggler`)
|
|
await addButton.click()
|
|
}
|
|
|
|
await expect(blocksDrawer).toBeVisible()
|
|
|
|
return blocksDrawer
|
|
}
|