From 4c2ce3891ed2e43e3834d5058ed33afbc079a9c3 Mon Sep 17 00:00:00 2001 From: Jarda Snajdr Date: Tue, 10 Jan 2023 09:22:07 +0100 Subject: [PATCH] Multi-block selection and rich text test: wait for expected UI to appear --- .../various/multi-block-selection.test.js | 17 +++++++++++++++-- .../specs/editor/various/rich-text.test.js | 4 ++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/packages/e2e-tests/specs/editor/various/multi-block-selection.test.js b/packages/e2e-tests/specs/editor/various/multi-block-selection.test.js index 1b165c31698aeb..0a4ddaa08ef8a3 100644 --- a/packages/e2e-tests/specs/editor/various/multi-block-selection.test.js +++ b/packages/e2e-tests/specs/editor/various/multi-block-selection.test.js @@ -395,7 +395,7 @@ describe( 'Multi-block selection', () => { await page.keyboard.press( 'Enter' ); await page.keyboard.type( '/group' ); await page.waitForXPath( - `//*[contains(@class, "components-autocomplete__result") and contains(@class, "is-selected") and contains(text(), 'Group')]` + '//button[@aria-selected="true"][text()="Group"]' ); await page.keyboard.press( 'Enter' ); @@ -658,6 +658,9 @@ describe( 'Multi-block selection', () => { it( 'should gradually multi-select', async () => { await clickBlockAppender(); await page.keyboard.type( '/columns' ); + await page.waitForXPath( + '//button[@aria-selected="true"][text()="Columns"]' + ); await page.keyboard.press( 'Enter' ); // Select two columns. await page.keyboard.press( 'ArrowRight' ); @@ -665,9 +668,13 @@ describe( 'Multi-block selection', () => { // Navigate to appender. await page.keyboard.press( 'ArrowRight' ); await page.keyboard.press( 'Enter' ); - // Select a paragraph. + // Wait for inserter results to appear and then select a paragraph. + await page.waitForSelector( + '.block-editor-inserter__quick-inserter-results .block-editor-block-types-list__item' + ); await page.keyboard.press( 'Tab' ); await page.keyboard.press( 'Enter' ); + // Type two paragraphs await page.keyboard.type( '1' ); await page.keyboard.press( 'Enter' ); await page.keyboard.type( '2' ); @@ -705,6 +712,9 @@ describe( 'Multi-block selection', () => { await page.keyboard.press( 'Enter' ); // Add a list. await page.keyboard.type( '/list' ); + await page.waitForXPath( + '//button[@aria-selected="true"][text()="List"]' + ); await page.keyboard.press( 'Enter' ); await page.keyboard.type( '1' ); @@ -924,6 +934,9 @@ describe( 'Multi-block selection', () => { await page.keyboard.press( 'Enter' ); await page.keyboard.press( 'Enter' ); await page.keyboard.type( '/hr' ); + await page.waitForXPath( + '//button[@aria-selected="true"][text()="Separator"]' + ); await page.keyboard.press( 'Enter' ); await page.keyboard.press( 'ArrowUp' ); await page.keyboard.press( 'ArrowUp' ); diff --git a/packages/e2e-tests/specs/editor/various/rich-text.test.js b/packages/e2e-tests/specs/editor/various/rich-text.test.js index f4d8e0d391721a..36d85e98cae1dc 100644 --- a/packages/e2e-tests/specs/editor/various/rich-text.test.js +++ b/packages/e2e-tests/specs/editor/various/rich-text.test.js @@ -408,6 +408,10 @@ describe( 'RichText', () => { await button.evaluate( ( element ) => element.scrollIntoView() ); await button.click(); + // Wait for the popover with "Text" tab to appear. + await page.waitForXPath( + '//button[@role="tab"][@aria-selected="true"][text()="Text"]' + ); // Tab to the "Text" tab. await page.keyboard.press( 'Tab' ); // Tab to black.