Skip to content

Commit

Permalink
E2E: Try to fix the flaky autocomplete spec (#55081)
Browse files Browse the repository at this point in the history
  • Loading branch information
WunderBart authored Oct 5, 2023
1 parent 8b09de4 commit b8b89ce
Showing 1 changed file with 29 additions and 9 deletions.
38 changes: 29 additions & 9 deletions test/e2e/specs/editor/various/autocomplete-and-mentions.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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( `<!-- wp:paragraph -->
<p>@ringbearer +thebetterhobbit</p>
<!-- /wp:paragraph -->` );

await expect.poll( editor.getBlocks ).toMatchObject( [
{
name: 'core/paragraph',
attributes: { content: '@ringbearer +thebetterhobbit' },
},
] );
} );

test( 'should hide UI when selection changes (by keyboard)', async ( {
Expand Down

0 comments on commit b8b89ce

Please sign in to comment.