Skip to content

Commit

Permalink
Fix unreliable link test (#13161)
Browse files Browse the repository at this point in the history
* Enable test

* Wait for speficic suggestion xpath during test
  • Loading branch information
talldan authored Apr 16, 2019
1 parent 3d6fe8e commit 5d14c98
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions packages/e2e-tests/specs/links.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand All @@ -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 ];

Expand Down Expand Up @@ -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' );
Expand Down

0 comments on commit 5d14c98

Please sign in to comment.