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

Migrate duplicating block test to playwright #43171

Merged
Show file tree
Hide file tree
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

This file was deleted.

This file was deleted.

64 changes: 64 additions & 0 deletions test/e2e/specs/editor/various/duplicating-blocks.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/**
* WordPress dependencies
*/
const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' );

test.describe( 'Duplicating blocks', () => {
test.beforeEach( async ( { admin } ) => {
await admin.createNewPost();
} );

test( 'should duplicate blocks using the block settings menu', 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.pressKeyWithModifier( 'primary', 'a' );

await editor.clickBlockToolbarButton( 'Options' );
await page.click( 'role=menuitem[name=/Duplicate/i]' );

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

<!-- wp:paragraph -->
<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.pressKeyWithModifier( 'primary', 'a' );

// Duplicate using the keyboard shortccut.
await pageUtils.pressKeyWithModifier( 'primaryShift', 'd' );

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

<!-- wp:paragraph -->
<p>Clone me</p>
<!-- /wp:paragraph -->`
);
} );
} );