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
29 lines
699 B
TypeScript
29 lines
699 B
TypeScript
import type { Page } from '@playwright/test'
|
|
|
|
import { expect } from '@playwright/test'
|
|
import { exactText } from 'helpers.js'
|
|
|
|
import { openBlocksDrawer } from './openBlocksDrawer.js'
|
|
|
|
export const addBlock = async ({
|
|
page,
|
|
fieldName = 'blocks',
|
|
blockLabel = 'Block',
|
|
}: {
|
|
blockLabel: string
|
|
fieldName: string
|
|
page: Page
|
|
}) => {
|
|
const blocksDrawer = await openBlocksDrawer({ page, fieldName })
|
|
|
|
const blockCard = blocksDrawer.locator('.blocks-drawer__block .thumbnail-card__label', {
|
|
hasText: blockLabel,
|
|
})
|
|
|
|
await expect(blockCard).toBeVisible()
|
|
|
|
await blocksDrawer.getByRole('button', { name: exactText(blockLabel) }).click()
|
|
|
|
// expect to see the block on the page
|
|
}
|