Skip to content

Commit

Permalink
Consolidate duplicate block tests (WordPress#51352)
Browse files Browse the repository at this point in the history
* Remove unnecessary select all text command from duplicate block e2e test

* Consolodate duplicate block tests
  • Loading branch information
jeryj authored and sethrubenstein committed Jul 13, 2023
1 parent 64c82e5 commit 95b57f3
Showing 1 changed file with 7 additions and 21 deletions.
28 changes: 7 additions & 21 deletions test/e2e/specs/editor/various/duplicating-blocks.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,15 @@ test.describe( 'Duplicating blocks', () => {
await admin.createNewPost();
} );

test( 'should duplicate blocks using the block settings menu', async ( {
test( 'should duplicate blocks using the block settings menu and keyboard shortcut', async ( {
page,
pageUtils,
editor,
} ) => {
await editor.insertBlock( { name: 'core/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 pageUtils.pressKeys( 'primary+a' );

// Test: Duplicate using the block settings menu.
await editor.clickBlockToolbarButton( 'Options' );
await page.click( 'role=menuitem[name=/Duplicate/i]' );

Expand All @@ -33,29 +29,19 @@ test.describe( 'Duplicating blocks', () => {
<p>Clone me</p>
<!-- /wp:paragraph -->`
);
} );

test( 'should duplicate blocks using the keyboard shortcut', async ( {
page,
pageUtils,
editor,
} ) => {
await editor.insertBlock( { name: 'core/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 pageUtils.pressKeys( 'primary+a' );

// Duplicate using the keyboard shortccut.
// Test: Duplicate using the keyboard shortccut.
await pageUtils.pressKeys( 'primaryShift+d' );

expect( await editor.getEditedPostContent() ).toBe(
`<!-- wp:paragraph -->
<p>Clone me</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p>Clone me</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p>Clone me</p>
<!-- /wp:paragraph -->`
Expand Down

0 comments on commit 95b57f3

Please sign in to comment.