Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

E2E: Try to fix the flaky autocomplete spec #55081

Merged
merged 3 commits into from
Oct 5, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading