From df392a47b373a8b042ddbc3bcf3b365296956f8d Mon Sep 17 00:00:00 2001 From: MaggieCabrera Date: Fri, 21 Jul 2023 12:42:51 +0200 Subject: [PATCH] migrated test: is not created when we click away from the link input --- .../specs/editor/various/links.test.js | 21 ----------- test/e2e/specs/editor/blocks/links.spec.js | 35 +++++++++++++++++++ 2 files changed, 35 insertions(+), 21 deletions(-) diff --git a/packages/e2e-tests/specs/editor/various/links.test.js b/packages/e2e-tests/specs/editor/various/links.test.js index 5f73464ee44e4e..e761c56fd565ad 100644 --- a/packages/e2e-tests/specs/editor/various/links.test.js +++ b/packages/e2e-tests/specs/editor/various/links.test.js @@ -30,27 +30,6 @@ describe( 'Links', () => { } ); }; - it( 'is not created when we click away from the link input', async () => { - // Create a block with some text. - await clickBlockAppender(); - await page.keyboard.type( 'This is Gutenberg' ); - - // Select some text. - await pressKeyWithModifier( 'shiftAlt', 'ArrowLeft' ); - - // Click on the Link button. - await page.click( 'button[aria-label="Link"]' ); - - // Wait for the URL field to auto-focus. - await waitForURLFieldAutoFocus(); - - // Type a URL. - await page.keyboard.type( 'https://wordpress.org/gutenberg' ); - - // Click somewhere else - it doesn't really matter where. - await canvas().click( '.editor-post-title' ); - } ); - const createAndReselectLink = async () => { // Create a block with some text. await clickBlockAppender(); diff --git a/test/e2e/specs/editor/blocks/links.spec.js b/test/e2e/specs/editor/blocks/links.spec.js index b8d115836630dc..50bc501f5b9a3a 100644 --- a/test/e2e/specs/editor/blocks/links.spec.js +++ b/test/e2e/specs/editor/blocks/links.spec.js @@ -180,6 +180,41 @@ test.describe( 'Links', () => { ] ); } ); + test( `is not created when we click away from the link input`, async ( { + page, + editor, + pageUtils, + } ) => { + // Create a block with some text. + await editor.insertBlock( { + name: 'core/paragraph', + } ); + await page.keyboard.type( 'This is Gutenberg' ); + + // Select some text. + await pageUtils.pressKeys( 'shiftAlt+ArrowLeft' ); + + // Click on the Link button. + await page.getByRole( 'button', { name: 'Link' } ).click(); + + // Type a URL. + await page.keyboard.type( 'https://wordpress.org/gutenberg' ); + + // Click somewhere else - it doesn't really matter where. + await editor.canvas + .getByRole( 'textbox', { name: 'Add title' } ) + .focus(); + + await expect.poll( editor.getBlocks ).toMatchObject( [ + { + name: 'core/paragraph', + attributes: { + content: 'This is Gutenberg', + }, + }, + ] ); + } ); + test( `can be created by selecting text and using keyboard shortcuts`, async ( { page, editor,