Skip to content

Commit

Permalink
Migrate Convert Block Type test to Playwright (#42760)
Browse files Browse the repository at this point in the history
* Migrate Conver Block Type test to Playwright

* Addressed Review Feedbacks

* Fix Stylint Issue
  • Loading branch information
pooja-muchandikar authored Jul 28, 2022
1 parent 8179690 commit ed5813c
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 45 deletions.

This file was deleted.

32 changes: 0 additions & 32 deletions packages/e2e-tests/specs/editor/various/convert-block-type.test.js

This file was deleted.

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

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

test.afterEach( async ( { requestUtils } ) => {
await requestUtils.deleteAllPosts();
} );

test( 'should convert to a preformatted block', async ( {
page,
editor,
} ) => {
const code = 'print "Hello Dolly!"';

await editor.insertBlock( { name: 'core/code' } );
await page.keyboard.type( code );

// Verify the content starts out as a Code block.

await expect.poll( editor.getEditedPostContent ).toBe( `<!-- wp:code -->
<pre class="wp-block-code"><code>${ code }</code></pre>
<!-- /wp:code -->` );

await editor.transformBlockTo( 'core/preformatted' );

// The content should now be a Preformatted block with no data loss.
await expect.poll( editor.getEditedPostContent )
.toBe( `<!-- wp:preformatted -->
<pre class="wp-block-preformatted">${ code }</pre>
<!-- /wp:preformatted -->` );
} );
} );

0 comments on commit ed5813c

Please sign in to comment.