From 04dad9d7a62aa96d9c7061354dbd697210ade2b3 Mon Sep 17 00:00:00 2001 From: Alessio Gravili Date: Thu, 6 Feb 2025 20:24:49 -0700 Subject: [PATCH] chore: fix flaky lexical test (#11035) The "select decoratorNodes" test was flaky, as it often selected the relationship block node with a relationship to "payload.jpg", instead of the upload node for "payload.jpg", depending on which node loaded first. This PR ensures it waits for all blocks to be loaded, and updates the selector to specifically target the upload node --- test/fields/collections/Lexical/e2e/main/e2e.spec.ts | 10 +++++++++- test/fields/payload-types.ts | 2 ++ test/playwright.config.ts | 4 ++-- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/test/fields/collections/Lexical/e2e/main/e2e.spec.ts b/test/fields/collections/Lexical/e2e/main/e2e.spec.ts index e353081e63..63197fe2be 100644 --- a/test/fields/collections/Lexical/e2e/main/e2e.spec.ts +++ b/test/fields/collections/Lexical/e2e/main/e2e.spec.ts @@ -61,6 +61,14 @@ async function navigateToLexicalFields( await linkToDoc.click() await page.waitForURL(`**${linkDocHref}`) + + if (collectionSlug === 'lexical-fields') { + const richTextField = page.locator('.rich-text-lexical').nth(2) // second + await richTextField.scrollIntoViewIfNeeded() + await expect(richTextField).toBeVisible() + // Wait until there at least 10 blocks visible in that richtext field - thus wait for it to be fully loaded + await expect(richTextField.locator('.lexical-block')).toHaveCount(10) + } } describe('lexicalMain', () => { @@ -1339,7 +1347,7 @@ describe('lexicalMain', () => { // test await navigateToLexicalFields() const bottomOfUploadNode = page - .locator('div') + .locator('.lexical-upload div') .filter({ hasText: /^payload\.jpg$/ }) .first() await bottomOfUploadNode.click() diff --git a/test/fields/payload-types.ts b/test/fields/payload-types.ts index 81ec226d30..a9c08c8c4c 100644 --- a/test/fields/payload-types.ts +++ b/test/fields/payload-types.ts @@ -881,6 +881,7 @@ export interface TextField { fieldWithDefaultValue?: string | null; dependentOnFieldWithDefaultValue?: string | null; hasMany?: string[] | null; + readOnlyHasMany?: string[] | null; validatesHasMany?: string[] | null; localizedHasMany?: string[] | null; withMinRows?: string[] | null; @@ -3243,6 +3244,7 @@ export interface TextFieldsSelect { fieldWithDefaultValue?: T; dependentOnFieldWithDefaultValue?: T; hasMany?: T; + readOnlyHasMany?: T; validatesHasMany?: T; localizedHasMany?: T; withMinRows?: T; diff --git a/test/playwright.config.ts b/test/playwright.config.ts index 27a2c56590..67727cbd64 100644 --- a/test/playwright.config.ts +++ b/test/playwright.config.ts @@ -8,8 +8,8 @@ const dirname = path.dirname(filename) dotenv.config({ path: path.resolve(dirname, 'test.env') }) -let multiplier = process.env.CI ? 5 : 1 -let smallMultiplier = process.env.CI ? 4 : 1 +let multiplier = process.env.CI ? 4 : 1 +let smallMultiplier = process.env.CI ? 3 : 1 export const TEST_TIMEOUT_LONG = 640000 * multiplier // 8*3 minutes - used as timeOut for the beforeAll export const TEST_TIMEOUT = 40000 * multiplier