diff --git a/packages/e2e-tests/specs/editor/various/mentions.test.js b/packages/e2e-tests/specs/editor/various/mentions.test.js deleted file mode 100644 index 458449a1b30d4..0000000000000 --- a/packages/e2e-tests/specs/editor/various/mentions.test.js +++ /dev/null @@ -1,69 +0,0 @@ -/** - * WordPress dependencies - */ -import { - clickBlockAppender, - createNewPost, - createUser, - deleteUser, - getEditedPostContent, - pressKeyTimes, -} from '@wordpress/e2e-test-utils'; - -describe( 'autocomplete mentions', () => { - beforeAll( async () => { - await createUser( 'testuser', { firstName: 'Jane', lastName: 'Doe' } ); - } ); - - beforeEach( async () => { - await createNewPost(); - } ); - - afterAll( async () => { - await deleteUser( 'testuser' ); - } ); - - it( 'should insert mention', async () => { - await clickBlockAppender(); - await page.keyboard.type( 'I am @a' ); - await page.waitForSelector( '.components-autocomplete__result' ); - await page.keyboard.press( 'Enter' ); - await page.keyboard.type( '.' ); - expect( await getEditedPostContent() ).toMatchInlineSnapshot( ` - " -
I am @admin.
- " - ` ); - } ); - - it( 'should insert mention between two other words', async () => { - await clickBlockAppender(); - await page.keyboard.type( 'Stuck in the middle with you.' ); - await pressKeyTimes( 'ArrowLeft', 'you.'.length ); - await page.keyboard.type( '@j' ); - await page.waitForSelector( '.components-autocomplete__result' ); - await page.keyboard.press( 'Enter' ); - await page.keyboard.type( ' ' ); - expect( await getEditedPostContent() ).toMatchInlineSnapshot( ` - " -Stuck in the middle with @testuser you.
- " - ` ); - } ); - - it( 'should insert two subsequent mentions', async () => { - await clickBlockAppender(); - await page.keyboard.type( 'I am @j' ); - await page.waitForSelector( '.components-autocomplete__result' ); - await page.keyboard.press( 'Enter' ); - await page.keyboard.type( ' @a' ); - await page.waitForSelector( '.components-autocomplete__result' ); - await page.keyboard.press( 'Enter' ); - await page.keyboard.type( '.' ); - expect( await getEditedPostContent() ).toMatchInlineSnapshot( ` - " -I am @testuser @admin.
- " - ` ); - } ); -} ); diff --git a/test/e2e/specs/editor/various/mentions.spec.js b/test/e2e/specs/editor/various/mentions.spec.js new file mode 100644 index 0000000000000..878cf148e8abf --- /dev/null +++ b/test/e2e/specs/editor/various/mentions.spec.js @@ -0,0 +1,83 @@ +/** + * WordPress dependencies + */ +const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' ); + +test.describe( 'autocomplete mentions', () => { + test.beforeAll( async ( { requestUtils } ) => { + await requestUtils.createUser( { + username: 'testuser', + email: 'testuser@example.com', + firstName: 'Jane', + lastName: 'Doe', + password: 'secret', + } ); + } ); + + test.beforeEach( async ( { admin } ) => { + await admin.createNewPost(); + } ); + + test.afterAll( async ( { requestUtils } ) => { + await requestUtils.deleteAllUsers(); + } ); + + test( 'should insert mention', async ( { page, editor } ) => { + await page.click( 'role=button[name="Add default block"i]' ); + await page.keyboard.type( 'I am @ad' ); + await expect( + page.locator( 'role=listbox >> role=option[name=/admin/i]' ) + ).toBeVisible(); + await page.keyboard.press( 'Enter' ); + await page.keyboard.type( '.' ); + await expect.poll( editor.getEditedPostContent ).toBe( + ` +I am @admin.
+` + ); + } ); + + test( 'should insert mention between two other words', async ( { + page, + editor, + pageUtils, + } ) => { + await page.click( 'role=button[name="Add default block"i]' ); + await page.keyboard.type( 'Stuck in the middle with you' ); + await pageUtils.pressKeyTimes( 'ArrowLeft', 'you'.length ); + await page.keyboard.type( '@j' ); + await expect( + page.locator( 'role=listbox >> role=option[name=/testuser/i]' ) + ).toBeVisible(); + await page.keyboard.press( 'Enter' ); + await page.keyboard.type( ' ' ); + await expect.poll( editor.getEditedPostContent ).toBe( + ` +Stuck in the middle with @testuser you
+` + ); + } ); + + test( 'should insert two subsequent mentions', async ( { + page, + editor, + } ) => { + await page.click( 'role=button[name="Add default block"i]' ); + await page.keyboard.type( 'I am @j' ); + await expect( + page.locator( 'role=listbox >> role=option[name=/testuser/i]' ) + ).toBeVisible(); + await page.keyboard.press( 'Enter' ); + await page.keyboard.type( ' @ad' ); + await expect( + page.locator( 'role=listbox >> role=option[name=/admin/i]' ) + ).toBeVisible(); + await page.keyboard.press( 'Enter' ); + await page.keyboard.type( '.' ); + await expect.poll( editor.getEditedPostContent ).toBe( + ` +I am @testuser @admin.
+` + ); + } ); +} );