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 iframed block test to Playwright #44164

Merged
merged 6 commits into from
Sep 30, 2022
Merged
Show file tree
Hide file tree
Changes from 5 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.

49 changes: 0 additions & 49 deletions packages/e2e-tests/specs/editor/plugins/iframed-block.test.js

This file was deleted.

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 -->
44 changes: 44 additions & 0 deletions test/e2e/specs/editor/plugins/iframed-block.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/**
* 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.locator( 'role=button[name= "Page"i]' ).first().click();
Rink9 marked this conversation as resolved.
Show resolved Hide resolved

// 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)'
);
} );
} );