diff --git a/packages/e2e-tests/specs/editor/plugins/__snapshots__/iframed-block.test.js.snap b/packages/e2e-tests/specs/editor/plugins/__snapshots__/iframed-block.test.js.snap deleted file mode 100644 index a4efcd222188e..0000000000000 --- a/packages/e2e-tests/specs/editor/plugins/__snapshots__/iframed-block.test.js.snap +++ /dev/null @@ -1,7 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`changing image size should load script and dependencies in iframe 1`] = ` -" -
Iframed Block (saved)
-" -`; diff --git a/packages/e2e-tests/specs/editor/plugins/iframed-block.test.js b/packages/e2e-tests/specs/editor/plugins/iframed-block.test.js deleted file mode 100644 index 4107cbe5352f7..0000000000000 --- a/packages/e2e-tests/specs/editor/plugins/iframed-block.test.js +++ /dev/null @@ -1,49 +0,0 @@ -/** - * WordPress dependencies - */ -import { - activatePlugin, - createNewPost, - deactivatePlugin, - insertBlock, - getEditedPostContent, - canvas, - createNewTemplate, -} from '@wordpress/e2e-test-utils'; - -describe( 'changing image size', () => { - beforeEach( async () => { - await activatePlugin( 'gutenberg-test-iframed-block' ); - await createNewPost( { postType: 'page' } ); - } ); - - afterEach( async () => { - await deactivatePlugin( 'gutenberg-test-iframed-block' ); - } ); - - it( 'should load script and dependencies in iframe', async () => { - await insertBlock( 'Iframed Block' ); - - expect( await getEditedPostContent() ).toMatchSnapshot(); - - const element = await page.waitForSelector( - '.wp-block-test-iframed-block' - ); - const text = await element.evaluate( ( el ) => el.textContent ); - - expect( text ).toBe( 'Iframed Block (set with jQuery)' ); - - await createNewTemplate( 'Iframed Test' ); - - const iframeElement = await canvas().waitForSelector( - '.wp-block-test-iframed-block' - ); - const iframedText = await iframeElement.evaluate( - ( el ) => el.textContent - ); - - // Expect the script to load in the iframe, which replaces the block - // text. - expect( iframedText ).toBe( 'Iframed Block (set with jQuery)' ); - } ); -} ); diff --git a/test/e2e/specs/editor/plugins/__snapshots__/Iframed-block-Should-save-the-changes-1-chromium.txt b/test/e2e/specs/editor/plugins/__snapshots__/Iframed-block-Should-save-the-changes-1-chromium.txt new file mode 100644 index 0000000000000..bcc47c713c778 --- /dev/null +++ b/test/e2e/specs/editor/plugins/__snapshots__/Iframed-block-Should-save-the-changes-1-chromium.txt @@ -0,0 +1,3 @@ + +Iframed Block (saved)
+ \ No newline at end of file diff --git a/test/e2e/specs/editor/plugins/iframed-block.spec.js b/test/e2e/specs/editor/plugins/iframed-block.spec.js new file mode 100644 index 0000000000000..55b67cb70fe86 --- /dev/null +++ b/test/e2e/specs/editor/plugins/iframed-block.spec.js @@ -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)' + ); + } ); +} );