Skip to content

Commit

Permalink
migrated test: can be edited
Browse files Browse the repository at this point in the history
  • Loading branch information
MaggieCabrera committed Jul 21, 2023
1 parent df392a4 commit a81d929
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,6 @@ exports[`Links allows use of escape key to dismiss the url popover 1`] = `
<!-- /wp:paragraph -->"
`;

exports[`Links can be edited 1`] = `
"<!-- wp:paragraph -->
<p>This is <a href="https://wordpress.org/gutenberg/handbook">Gutenberg</a></p>
<!-- /wp:paragraph -->"
`;

exports[`Links can be edited with collapsed selection 1`] = `
"<!-- wp:paragraph -->
<p>This is <a href="https://wordpress.org/gutenberg/handbook">Gutenberg</a></p>
Expand Down
22 changes: 0 additions & 22 deletions packages/e2e-tests/specs/editor/various/links.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,28 +54,6 @@ describe( 'Links', () => {
await pressKeyWithModifier( 'shiftAlt', 'ArrowLeft' );
};

it( 'can be edited', async () => {
await createAndReselectLink();

// Click on the Edit button.
const [ editButton ] = await page.$x(
'//button[contains(@aria-label, "Edit")]'
);
await editButton.click();

// Wait for the URL field to auto-focus.
await waitForURLFieldAutoFocus();

// Change the URL.
await page.keyboard.type( '/handbook' );

// Submit the link.
await page.keyboard.press( 'Enter' );

// The link should have been updated.
expect( await getEditedPostContent() ).toMatchSnapshot();
} );

it( 'can be removed', async () => {
await createAndReselectLink();

Expand Down
43 changes: 43 additions & 0 deletions test/e2e/specs/editor/blocks/links.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,49 @@ test.describe( 'Links', () => {
] );
} );

test( `can be edited`, 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 on the Submit button.
await pageUtils.pressKeys( 'Enter' );

// Reselect the link.
await pageUtils.pressKeys( 'shiftAlt+ArrowLeft' );

// Click on the Edit button.
await page.getByRole( 'button', { name: 'Edit' } ).click();

// Change the URL.
await page.getByPlaceholder( 'Search or type url' ).fill( '' );
await page.keyboard.type( '/handbook' );

// Submit the link.
await pageUtils.pressKeys( 'Enter' );

// The link should have been updated.
await expect.poll( editor.getBlocks ).toMatchObject( [
{
name: 'core/paragraph',
attributes: {
content: 'This is <a href="/handbook">Gutenberg</a>',
},
},
] );
} );

test( `can be created by selecting text and using keyboard shortcuts`, async ( {
page,
editor,
Expand Down

0 comments on commit a81d929

Please sign in to comment.