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 Convert Block Type test to Playwright #42760

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.

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();
kevin940726 marked this conversation as resolved.
Show resolved Hide resolved
} );

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 -->` );
} );
} );