-
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 iframed block test to Playwright (#44164)
* Migrate iframed block test * fix: failed on CI * fix: failed from CI * remove: snapshot from packages * update: addressed feedbacks * update: addressed feedbacks
- Loading branch information
Showing
4 changed files
with
49 additions
and
56 deletions.
There are no files selected for viewing
7 changes: 0 additions & 7 deletions
7
packages/e2e-tests/specs/editor/plugins/__snapshots__/iframed-block.test.js.snap
This file was deleted.
Oops, something went wrong.
49 changes: 0 additions & 49 deletions
49
packages/e2e-tests/specs/editor/plugins/iframed-block.test.js
This file was deleted.
Oops, something went wrong.
3 changes: 3 additions & 0 deletions
3
...e/specs/editor/plugins/__snapshots__/Iframed-block-Should-save-the-changes-1-chromium.txt
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,3 @@ | ||
<!-- wp:test/iframed-block --> | ||
<p class="wp-block-test-iframed-block">Iframed Block (saved)</p> | ||
<!-- /wp:test/iframed-block --> |
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,46 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' ); | ||
|
||
test.describe( 'Iframed block', () => { | ||
test.beforeEach( async ( { requestUtils, admin } ) => { | ||
await requestUtils.activatePlugin( 'gutenberg-test-iframed-block' ); | ||
await admin.createNewPost( { postType: 'page' } ); | ||
} ); | ||
|
||
test.afterEach( async ( { requestUtils } ) => { | ||
await requestUtils.deactivatePlugin( 'gutenberg-test-iframed-block' ); | ||
} ); | ||
|
||
test( 'Should save the changes', async ( { editor, page } ) => { | ||
await editor.insertBlock( { name: 'test/iframed-block' } ); | ||
expect( await editor.getEditedPostContent() ).toMatchSnapshot(); | ||
|
||
await expect( | ||
page.locator( 'role=document[name="Block: Iframed Block"i]' ) | ||
).toContainText( 'Iframed Block (set with jQuery)' ); | ||
|
||
// open page from sidebar settings | ||
await page.click( | ||
'role=region[name="Editor settings"i] >> role=button[name="Page"i]' | ||
); | ||
|
||
// Opens the template editor with a newly created template. | ||
await page.click( 'role=button[name="Select template"i]' ); | ||
await page.click( 'role=button[name="Add template"i]' ); | ||
await page.fill( 'role=textbox[name="NAME"i]', 'Test template' ); | ||
await page.click( 'role=button[name="Create"i]' ); | ||
|
||
// Expect iframe canvas to be visible | ||
await expect( | ||
page.locator( 'iframe[name="editor-canvas"]' ) | ||
).toBeVisible(); | ||
|
||
// Expect the script to load in the iframe, which replaces the block text. | ||
const iframedText = page.frameLocator( 'iframe' ).locator( 'body' ); | ||
await expect( iframedText ).toContainText( | ||
'Iframed Block (set with jQuery)' | ||
); | ||
} ); | ||
} ); |