From b8b89cecd6b6e274d70867d9d0dd7acd005be3e5 Mon Sep 17 00:00:00 2001 From: Bart Kalisz Date: Thu, 5 Oct 2023 14:30:38 +0000 Subject: [PATCH] E2E: Try to fix the flaky autocomplete spec (#55081) --- .../various/autocomplete-and-mentions.spec.js | 38 ++++++++++++++----- 1 file changed, 29 insertions(+), 9 deletions(-) diff --git a/test/e2e/specs/editor/various/autocomplete-and-mentions.spec.js b/test/e2e/specs/editor/various/autocomplete-and-mentions.spec.js index 6e1e0edfa3aba4..ec0ca999993c2f 100644 --- a/test/e2e/specs/editor/various/autocomplete-and-mentions.spec.js +++ b/test/e2e/specs/editor/various/autocomplete-and-mentions.spec.js @@ -427,23 +427,43 @@ test.describe( 'Autocomplete (@firefox, @webkit)', () => { page, editor, } ) => { + const typingDelay = 100; + await editor.canvas - .locator( 'role=button[name="Add default block"i]' ) + .getByRole( 'button', { name: 'Add default block' } ) .click(); - await page.keyboard.type( '@fr' ); + + await page.keyboard.type( '@fr', { delay: typingDelay } ); await expect( - page.locator( 'role=option', { hasText: 'Frodo Baggins' } ) + page.getByRole( 'option', { + name: 'Frodo Baggins', + selected: true, + } ) ).toBeVisible(); + await page.keyboard.press( 'Enter' ); - await page.keyboard.type( ' +bi' ); + await expect.poll( editor.getBlocks ).toMatchObject( [ + { + name: 'core/paragraph', + attributes: { content: '@ringbearer' }, + }, + ] ); + + await page.keyboard.type( ' +bi', { delay: typingDelay } ); await expect( - page.locator( 'role=option', { hasText: 'Bilbo Baggins' } ) + page.getByRole( 'option', { + name: 'Bilbo Baggins', + selected: true, + } ) ).toBeVisible(); await page.keyboard.press( 'Enter' ); - await expect.poll( editor.getEditedPostContent ) - .toBe( ` -

@ringbearer +thebetterhobbit

-` ); + + await expect.poll( editor.getBlocks ).toMatchObject( [ + { + name: 'core/paragraph', + attributes: { content: '@ringbearer +thebetterhobbit' }, + }, + ] ); } ); test( 'should hide UI when selection changes (by keyboard)', async ( {