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

Block editor: iframe: add editor style e2e test #33403

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all 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
24 changes: 24 additions & 0 deletions packages/e2e-tests/plugins/iframed-editor-style.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php
/**
* Plugin Name: Gutenberg Test Iframed Editor Style
* Plugin URI: https://github.com/WordPress/gutenberg
* Author: Gutenberg Team
*
* @package gutenberg-test-iframed-add-editor-style
*/

// Enable the template editor to test the iframed content.
add_action(
'setup_theme',
function() {
add_theme_support( 'block-templates' );
}
);

add_action(
'block_editor_settings_all',
function( $settings ) {
$settings['styles'][] = array( 'css' => 'p { border: 1px solid red }' );
return $settings;
}
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/**
* WordPress dependencies
*/
import {
activatePlugin,
createNewPost,
deactivatePlugin,
insertBlock,
openDocumentSettingsSidebar,
clickButton,
canvas,
} from '@wordpress/e2e-test-utils';

async function getComputedStyle( context ) {
return await context.evaluate( () => {
const container = document.querySelector( '.wp-block-paragraph' );
return window.getComputedStyle( container )[ 'border-width' ];
} );
}

describe( 'iframed editor styles', () => {
beforeEach( async () => {
await activatePlugin( 'gutenberg-test-iframed-editor-style' );
await createNewPost( { postType: 'page' } );
} );

afterEach( async () => {
await deactivatePlugin( 'gutenberg-test-iframed-editor-style' );
} );

it( 'should load editor styles through the block editor settings', async () => {
await insertBlock( 'Paragraph' );

expect( await getComputedStyle( page ) ).toBe( '1px' );

await openDocumentSettingsSidebar();
await clickButton( 'Page' );
await clickButton( 'Template' );
await clickButton( 'New' );
await page.keyboard.press( 'Tab' );
await page.keyboard.press( 'Tab' );
await page.keyboard.type( 'Iframed Test' );
await clickButton( 'Create' );
await page.waitForSelector( 'iframe[name="editor-canvas"]' );
await canvas().waitForSelector( '.wp-block-paragraph' );

expect( await getComputedStyle( canvas() ) ).toBe( '1px' );
} );
} );