test: add array field helpers (#13493)

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
This commit is contained in:
Jacob Fletcher
2025-08-19 15:44:59 -04:00
committed by GitHub
parent 368cd901f8
commit adb83b1e06
24 changed files with 252 additions and 141 deletions

View File

@@ -2,6 +2,7 @@ import type { BrowserContext, Page } from '@playwright/test'
import type { GeneratedTypes } from 'helpers/sdk/types.js'
import { expect, test } from '@playwright/test'
import { addArrayRow } from 'helpers/e2e/fields/array/index.js'
import { navigateToDoc } from 'helpers/e2e/navigateToDoc.js'
import { openDocControls } from 'helpers/e2e/openDocControls.js'
import { upsertPreferences } from 'helpers/e2e/preferences.js'
@@ -420,8 +421,7 @@ describe('Localization', () => {
const nestedArrayURL = new AdminUrlUtil(serverURL, nestedToArrayAndBlockCollectionSlug)
await page.goto(nestedArrayURL.create)
await changeLocale(page, 'ar')
const addArrayRow = page.locator('#field-topLevelArray .array-field__add-row')
await addArrayRow.click()
await addArrayRow(page, { fieldName: 'topLevelArray' })
const arrayField = page.locator('#field-topLevelArray__0__localizedText')
await expect(arrayField).toBeVisible()
@@ -676,8 +676,7 @@ describe('Localization', () => {
async function createLocalizedArrayItem(page: Page, url: AdminUrlUtil) {
await changeLocale(page, defaultLocale)
await page.goto(url.create)
const addArrayRow = page.locator('#field-items .array-field__add-row')
await addArrayRow.click()
await addArrayRow(page, { fieldName: 'items' })
const textField = page.locator('#field-items__0__text')
await textField.fill('test')
await saveDocAndAssert(page)