Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consolidate duplicate block tests #51352

Merged
merged 2 commits into from
Jun 9, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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