-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix keyboard block duplication (#21317)
- Loading branch information
1 parent
d87920f
commit 2aaa18b
Showing
3 changed files
with
73 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
packages/e2e-tests/specs/editor/various/__snapshots__/duplicating-blocks.test.js.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`Duplicating blocks should duplicate blocks using the block settings menu 1`] = ` | ||
"<!-- wp:paragraph --> | ||
<p>Clone me</p> | ||
<!-- /wp:paragraph --> | ||
<!-- wp:paragraph --> | ||
<p>Clone me</p> | ||
<!-- /wp:paragraph -->" | ||
`; | ||
|
||
exports[`Duplicating blocks should duplicate blocks using the keyboard shortcut 1`] = ` | ||
"<!-- wp:paragraph --> | ||
<p>Clone me</p> | ||
<!-- /wp:paragraph --> | ||
<!-- wp:paragraph --> | ||
<p>Clone me</p> | ||
<!-- /wp:paragraph -->" | ||
`; |
49 changes: 49 additions & 0 deletions
49
packages/e2e-tests/specs/editor/various/duplicating-blocks.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { | ||
createNewPost, | ||
insertBlock, | ||
getEditedPostContent, | ||
clickBlockToolbarButton, | ||
pressKeyWithModifier, | ||
} from '@wordpress/e2e-test-utils'; | ||
|
||
describe( 'Duplicating blocks', () => { | ||
beforeEach( async () => { | ||
await createNewPost(); | ||
} ); | ||
|
||
it( 'should duplicate blocks using the block settings menu', async () => { | ||
await insertBlock( 'Paragraph' ); | ||
await page.keyboard.type( 'Clone me' ); | ||
|
||
// Select the test we just typed | ||
// This doesn't do anything but we previously had a duplicationi bug | ||
// When the selection was not collapsed | ||
await pressKeyWithModifier( 'primary', 'a' ); | ||
|
||
await clickBlockToolbarButton( 'More options' ); | ||
const duplicateButton = await page.waitForXPath( | ||
'//button[text()="Duplicate"]' | ||
); | ||
await duplicateButton.click(); | ||
|
||
expect( await getEditedPostContent() ).toMatchSnapshot(); | ||
} ); | ||
|
||
it( 'should duplicate blocks using the keyboard shortcut', async () => { | ||
await insertBlock( 'Paragraph' ); | ||
await page.keyboard.type( 'Clone me' ); | ||
|
||
// Select the test we just typed | ||
// This doesn't do anything but we previously had a duplicationi bug | ||
// When the selection was not collapsed | ||
await pressKeyWithModifier( 'primary', 'a' ); | ||
|
||
// Duplicate using the keyboard shortccut | ||
await pressKeyWithModifier( 'primaryShift', 'd' ); | ||
|
||
expect( await getEditedPostContent() ).toMatchSnapshot(); | ||
} ); | ||
} ); |