Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ntsekouras committed Apr 13, 2022
1 parent e8b0901 commit 0d20c29
Show file tree
Hide file tree
Showing 15 changed files with 16 additions and 62 deletions.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,7 @@
*/
const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' );

test.describe( 'Copy/cut/paste of whole blocks', () => {
test( 'should copy and paste individual blocks', async ( {
page,
pageUtils,
} ) => {
await pageUtils.createNewPost();

await page.click( 'role=button[name="Add default block"i]' );

await page.keyboard.type(
'Here is a unique string so we can test copying.'
);
await page.keyboard.press( 'Enter' );
await page.keyboard.type( '2' );
await page.keyboard.press( 'ArrowUp' );

await pageUtils.pressKeyWithModifier( 'primary', 'c' );
expect( await pageUtils.getEditedPostContent() ).toMatchSnapshot();

await page.keyboard.press( 'ArrowDown' );
await pageUtils.pressKeyWithModifier( 'primary', 'v' );
expect( await pageUtils.getEditedPostContent() ).toMatchSnapshot();
} );

test.describe( 'Copy/cut/paste', () => {
test( 'should copy blocks when non textual elements are focused (image, spacer)', async ( {
page,
pageUtils,
Expand All @@ -47,24 +24,22 @@ test.describe( 'Copy/cut/paste of whole blocks', () => {
expect( await pageUtils.getEditedPostContent() ).toMatchSnapshot();
} );

test( 'should cut and paste individual blocks', async ( {
test( 'should cut and paste individual non textual blocks', async ( {
page,
pageUtils,
} ) => {
await pageUtils.createNewPost();

await page.click( 'role=button[name="Add default block"i]' );

await page.keyboard.type( 'Yet another unique string.' );
await page.keyboard.press( 'Enter' );
await page.keyboard.type( '2' );
await page.keyboard.press( 'ArrowUp' );

await pageUtils.insertBlock( { name: 'core/spacer' } );
// At this point the spacer wrapper should be focused.
await pageUtils.pressKeyWithModifier( 'primary', 'x' );
expect( await pageUtils.getEditedPostContent() ).toMatchSnapshot();

await page.keyboard.press( 'Tab' );
await page.keyboard.press( 'ArrowDown' );
// The block appender is only visible when there's no selection.
await page.evaluate( () => {
window.wp.data.dispatch( 'core/block-editor' ).clearSelectedBlock();
} );
await page.click( 'role=button[name="Add default block"i]' );
await pageUtils.pressKeyWithModifier( 'primary', 'v' );
expect( await pageUtils.getEditedPostContent() ).toMatchSnapshot();
} );
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<!-- wp:paragraph -->
<p></p>
<!-- /wp:paragraph -->

<!-- wp:spacer -->
<div style="height:100px" aria-hidden="true" class="wp-block-spacer"></div>
<!-- /wp:spacer -->

0 comments on commit 0d20c29

Please sign in to comment.