Skip to content

Commit

Permalink
migrated test: should correctly replace targetted links text within r…
Browse files Browse the repository at this point in the history
…ich text value when multiple matching values exist
  • Loading branch information
MaggieCabrera committed Aug 17, 2023
1 parent 23027a8 commit 6169732
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 92 deletions.
92 changes: 0 additions & 92 deletions packages/e2e-tests/specs/editor/various/links.test.js

This file was deleted.

51 changes: 51 additions & 0 deletions test/e2e/specs/editor/blocks/links.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1100,6 +1100,57 @@ test.describe( 'Links', () => {
)
).not.toBeVisible();
} );

// Based on issue reported in https://github.com/WordPress/gutenberg/issues/41771/.
test( 'should correctly replace targetted links text within rich text value when multiple matching values exist', async ( {
page,
pageUtils,
editor,
} ) => {
// Create a block with some text.
await editor.insertBlock( {
name: 'core/paragraph',
} );

// Note the two instances of the string "a".
await page.keyboard.type( `a b c a` );

// Select the last "a" only.
await pageUtils.pressKeys( 'shift+ArrowLeft' );

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

// Type a URL.
await page.keyboard.type( 'www.wordpress.org' );

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

await pageUtils.pressKeys( 'ArrowLeft' );

// Click the "Edit" button in Link UI
await page.getByRole( 'button', { name: 'Edit' } ).click();

// Delete existing value from "Text" field
await pageUtils.pressKeys( 'Backspace' );

// Change text to "z"
await page.keyboard.type( 'z' );

await pageUtils.pressKeys( 'Enter' );

// Check that the correct (i.e. last) instance of "a" was replaced with "z".
await expect.poll( editor.getBlocks ).toMatchObject( [
{
name: 'core/paragraph',
attributes: {
content:
'a b c <a href="http://www.wordpress.org">z</a>',
},
},
] );
} );
} );
} );

Expand Down

0 comments on commit 6169732

Please sign in to comment.