diff --git a/packages/e2e-tests/plugins/iframed-inline-styles.php b/packages/e2e-tests/plugins/iframed-inline-styles.php index 0f8c69e1073337..ef3484e1a6498f 100644 --- a/packages/e2e-tests/plugins/iframed-inline-styles.php +++ b/packages/e2e-tests/plugins/iframed-inline-styles.php @@ -7,13 +7,6 @@ * @package gutenberg-test-iframed-inline-styles */ -add_action( - 'setup_theme', - static function () { - add_theme_support( 'block-templates' ); - } -); - add_action( 'init', static function () { diff --git a/packages/e2e-tests/specs/editor/plugins/__snapshots__/iframed-inline-styles.test.js.snap b/packages/e2e-tests/specs/editor/plugins/__snapshots__/iframed-inline-styles.test.js.snap deleted file mode 100644 index 49823edc5b1ea5..00000000000000 --- a/packages/e2e-tests/specs/editor/plugins/__snapshots__/iframed-inline-styles.test.js.snap +++ /dev/null @@ -1,7 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`iframed inline styles should load inline styles in iframe 1`] = ` -" -
Save
-" -`; diff --git a/packages/e2e-tests/specs/editor/plugins/iframed-inline-styles.test.js b/packages/e2e-tests/specs/editor/plugins/iframed-inline-styles.test.js deleted file mode 100644 index eafc0b1f48b614..00000000000000 --- a/packages/e2e-tests/specs/editor/plugins/iframed-inline-styles.test.js +++ /dev/null @@ -1,56 +0,0 @@ -/** - * WordPress dependencies - */ -import { - activatePlugin, - createNewPost, - deactivatePlugin, - insertBlock, - getEditedPostContent, - canvas, - createNewTemplate, -} from '@wordpress/e2e-test-utils'; - -async function getComputedStyle( context, property ) { - await context.waitForSelector( '.wp-block-test-iframed-inline-styles' ); - return await context.evaluate( ( prop ) => { - const container = document.querySelector( - '.wp-block-test-iframed-inline-styles' - ); - return window.getComputedStyle( container )[ prop ]; - }, property ); -} - -describe( 'iframed inline styles', () => { - beforeEach( async () => { - await activatePlugin( 'gutenberg-test-iframed-inline-styles' ); - await createNewPost( { postType: 'page' } ); - } ); - - afterEach( async () => { - await deactivatePlugin( 'gutenberg-test-iframed-inline-styles' ); - } ); - - it( 'should load inline styles in iframe', async () => { - await insertBlock( 'Iframed Inline Styles' ); - - expect( await getEditedPostContent() ).toMatchSnapshot(); - expect( await getComputedStyle( canvas(), 'padding' ) ).toBe( '20px' ); - expect( await getComputedStyle( canvas(), 'border-width' ) ).toBe( - '2px' - ); - - await createNewTemplate( 'Iframed Test' ); - - // Inline styles of properly enqueued stylesheet should load. - expect( await getComputedStyle( canvas(), 'padding' ) ).toBe( '20px' ); - - // Inline styles of stylesheet loaded with the compatibility layer - // should load. - expect( await getComputedStyle( canvas(), 'border-width' ) ).toBe( - '2px' - ); - - expect( console ).toHaveWarned(); - } ); -} ); diff --git a/test/e2e/specs/editor/plugins/iframed-equeue-block-assets.spec.js b/test/e2e/specs/editor/plugins/iframed-equeue-block-assets.spec.js index 391e1fdc17ec72..a523ba1f8e9e3d 100644 --- a/test/e2e/specs/editor/plugins/iframed-equeue-block-assets.spec.js +++ b/test/e2e/specs/editor/plugins/iframed-equeue-block-assets.spec.js @@ -3,7 +3,7 @@ */ const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' ); -test.describe( 'iframed inline styles', () => { +test.describe( 'iframed enqueue block assets', () => { test.beforeAll( async ( { requestUtils } ) => { await Promise.all( [ requestUtils.activateTheme( 'emptytheme' ), diff --git a/test/e2e/specs/editor/plugins/iframed-inline-styles.spec.js b/test/e2e/specs/editor/plugins/iframed-inline-styles.spec.js new file mode 100644 index 00000000000000..8fa4cbffa9df8c --- /dev/null +++ b/test/e2e/specs/editor/plugins/iframed-inline-styles.spec.js @@ -0,0 +1,46 @@ +/** + * WordPress dependencies + */ +const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' ); + +test.describe( 'iframed inline styles', () => { + test.beforeAll( async ( { requestUtils } ) => { + await requestUtils.activatePlugin( + 'gutenberg-test-iframed-inline-styles' + ); + } ); + + test.afterAll( async ( { requestUtils } ) => { + await requestUtils.deactivatePlugin( + 'gutenberg-test-iframed-inline-styles' + ); + } ); + + test( 'should load inline styles in iframe', async ( { + admin, + editor, + page, + } ) => { + let hasWarning; + page.on( 'console', ( msg ) => { + if ( msg.type() === 'warning' ) { + hasWarning = true; + } + } ); + + await admin.createNewPost( { postType: 'page' } ); + await editor.insertBlock( { name: 'test/iframed-inline-styles' } ); + + const block = editor.canvas.getByRole( 'document', { + name: 'Block: Iframed Inline Styles', + } ); + await expect( block ).toBeVisible(); + + // Inline styles of properly enqueued stylesheet should load. + await expect( block ).toHaveCSS( 'padding', '20px' ); + + // Inline styles of stylesheet loaded with the compatibility layer should load. + await expect( block ).toHaveCSS( 'border-width', '2px' ); + expect( hasWarning ).toBe( true ); + } ); +} );