diff --git a/packages/e2e-tests/specs/links.test.js b/packages/e2e-tests/specs/links.test.js index a41aa953bd8e7a..d9d10541fabe10 100644 --- a/packages/e2e-tests/specs/links.test.js +++ b/packages/e2e-tests/specs/links.test.js @@ -267,7 +267,7 @@ describe( 'Links', () => { // Test for regressions of https://github.com/WordPress/gutenberg/issues/10496. // Disabled until improved as it wasn't reliable enough. - it.skip( 'allows autocomplete suggestions to be selected with the mouse', async () => { + it( 'allows autocomplete suggestions to be selected with the mouse', async () => { // First create a post that we can search for using the link autocompletion. const titleText = 'Test post mouse'; const postURL = await createPostWithTitle( titleText ); @@ -284,11 +284,12 @@ describe( 'Links', () => { await waitForAutoFocus(); await page.keyboard.type( titleText ); - await page.waitForSelector( '.block-editor-url-input__suggestion' ); - const autocompleteSuggestions = await page.$x( `//*[contains(@class, "block-editor-url-input__suggestion")]//button[contains(text(), '${ titleText }')]` ); + const suggestionXPath = `//*[contains(@class, "block-editor-url-input__suggestion")]//button[contains(text(), '${ titleText }')]`; + await page.waitForXPath( suggestionXPath ); + const autocompleteSuggestions = await page.$x( suggestionXPath ); // Expect there to be some autocomplete suggestions. - expect( autocompleteSuggestions.length ).toBeGreaterThan( 0 ); + expect( autocompleteSuggestions ).toHaveLength( 1 ); const firstSuggestion = autocompleteSuggestions[ 0 ]; @@ -330,7 +331,7 @@ describe( 'Links', () => { const autocompleteSuggestions = await page.$x( `//*[contains(@class, "block-editor-url-input__suggestion")]//button[contains(text(), '${ titleText }')]` ); // Expect there to be some autocomplete suggestions. - expect( autocompleteSuggestions.length ).toBeGreaterThan( 0 ); + expect( autocompleteSuggestions ).toHaveLength( 1 ); // Expect the the first suggestion to be selected when pressing the down arrow. await page.keyboard.press( 'ArrowDown' );