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
This commit is contained in:
Alessio Gravili
2025-02-06 20:24:49 -07:00
committed by GitHub
parent 098fe10ade
commit 04dad9d7a6
3 changed files with 13 additions and 3 deletions

View File

@@ -61,6 +61,14 @@ async function navigateToLexicalFields(
await linkToDoc.click() await linkToDoc.click()
await page.waitForURL(`**${linkDocHref}`) 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', () => { describe('lexicalMain', () => {
@@ -1339,7 +1347,7 @@ describe('lexicalMain', () => {
// test // test
await navigateToLexicalFields() await navigateToLexicalFields()
const bottomOfUploadNode = page const bottomOfUploadNode = page
.locator('div') .locator('.lexical-upload div')
.filter({ hasText: /^payload\.jpg$/ }) .filter({ hasText: /^payload\.jpg$/ })
.first() .first()
await bottomOfUploadNode.click() await bottomOfUploadNode.click()

View File

@@ -881,6 +881,7 @@ export interface TextField {
fieldWithDefaultValue?: string | null; fieldWithDefaultValue?: string | null;
dependentOnFieldWithDefaultValue?: string | null; dependentOnFieldWithDefaultValue?: string | null;
hasMany?: string[] | null; hasMany?: string[] | null;
readOnlyHasMany?: string[] | null;
validatesHasMany?: string[] | null; validatesHasMany?: string[] | null;
localizedHasMany?: string[] | null; localizedHasMany?: string[] | null;
withMinRows?: string[] | null; withMinRows?: string[] | null;
@@ -3243,6 +3244,7 @@ export interface TextFieldsSelect<T extends boolean = true> {
fieldWithDefaultValue?: T; fieldWithDefaultValue?: T;
dependentOnFieldWithDefaultValue?: T; dependentOnFieldWithDefaultValue?: T;
hasMany?: T; hasMany?: T;
readOnlyHasMany?: T;
validatesHasMany?: T; validatesHasMany?: T;
localizedHasMany?: T; localizedHasMany?: T;
withMinRows?: T; withMinRows?: T;

View File

@@ -8,8 +8,8 @@ const dirname = path.dirname(filename)
dotenv.config({ path: path.resolve(dirname, 'test.env') }) dotenv.config({ path: path.resolve(dirname, 'test.env') })
let multiplier = process.env.CI ? 5 : 1 let multiplier = process.env.CI ? 4 : 1
let smallMultiplier = 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_LONG = 640000 * multiplier // 8*3 minutes - used as timeOut for the beforeAll
export const TEST_TIMEOUT = 40000 * multiplier export const TEST_TIMEOUT = 40000 * multiplier