-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate Convert Block Type test to Playwright (#42760)
* Migrate Conver Block Type test to Playwright * Addressed Review Feedbacks * Fix Stylint Issue
- Loading branch information
1 parent
8179690
commit ed5813c
Showing
3 changed files
with
38 additions
and
45 deletions.
There are no files selected for viewing
13 changes: 0 additions & 13 deletions
13
packages/e2e-tests/specs/editor/various/__snapshots__/convert-block-type.test.js.snap
This file was deleted.
Oops, something went wrong.
32 changes: 0 additions & 32 deletions
32
packages/e2e-tests/specs/editor/various/convert-block-type.test.js
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 -->` ); | ||
} ); | ||
} ); |