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

E2E Tests: Fix theme colors and font sizes. #18761

Merged
merged 3 commits into from
Dec 4, 2019
Merged
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
18 changes: 18 additions & 0 deletions packages/e2e-tests/mu-plugins/normalize-theme.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php
/**
* Plugin Name: Gutenberg Test Plugin, Normalize Theme
* Plugin URI: https://github.com/WordPress/gutenberg
* Author: Gutenberg Team
*
* @package gutenberg-test-normalize-theme
*/

/**
* Fixes colors and font sizes so that tests
* are consistent across different themes.
*/
function normalize_theme_init() {
remove_theme_support( 'editor-color-palette' );
remove_theme_support( 'editor-font-sizes' );
}
add_action( 'init', 'normalize_theme_init' );
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ exports[`Heading it should correctly apply custom colors 1`] = `
`;

exports[`Heading it should correctly apply named colors 1`] = `
"<!-- wp:heading {\\"textColor\\":\\"accent\\"} -->
<h2 class=\\"has-accent-color has-text-color\\">Heading</h2>
"<!-- wp:heading {\\"textColor\\":\\"very-dark-gray\\"} -->
<h2 class=\\"has-very-dark-gray-color has-text-color\\">Heading</h2>
<!-- /wp:heading -->"
`;

Expand Down
8 changes: 4 additions & 4 deletions packages/e2e-tests/specs/editor/blocks/heading.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,11 @@ describe( 'Heading', () => {
const [ colorPanelToggle ] = await page.$x( COLOR_PANEL_TOGGLE_X_SELECTOR );
await colorPanelToggle.click();

const accentColorButtonSelector = `${ TEXT_COLOR_UI_X_SELECTOR }//button[@aria-label='Color: Accent Color']`;
const [ accentColorButton ] = await page.$x( accentColorButtonSelector );
await accentColorButton.click();
const colorButtonSelector = `${ TEXT_COLOR_UI_X_SELECTOR }//button[@aria-label='Color: Very dark gray']`;
const [ colorButton ] = await page.$x( colorButtonSelector );
await colorButton.click();
await page.click( '[data-type="core/heading"] h2' );
await page.waitForXPath( `${ accentColorButtonSelector }[@aria-pressed='true']` );
await page.waitForXPath( `${ colorButtonSelector }[@aria-pressed='true']` );
expect( await getEditedPostContent() ).toMatchSnapshot();
} );
} );
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ describe( 'Editing modes (visual/HTML)', () => {

// Change the font size using the sidebar.
await page.click( '.components-font-size-picker__select' );
await page.click( '.components-custom-select__item:nth-child(3)' );
await page.click( '.components-custom-select__item:nth-child(4)' );

// Make sure the HTML content updated.
htmlBlockContent = await page.$eval( '.block-editor-block-list__layout .block-editor-block-list__block .block-editor-block-list__block-html-textarea', ( node ) => node.textContent );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ describe( 'Font Size Picker', () => {
await clickBlockAppender();
await page.keyboard.type( 'Paragraph to be made "large"' );
await page.click( '.components-font-size-picker__select' );
await page.click( '.components-custom-select__item:nth-child(3)' );
await page.click( '.components-custom-select__item:nth-child(4)' );

// Ensure content matches snapshot.
const content = await getEditedPostContent();
Expand All @@ -31,8 +31,8 @@ describe( 'Font Size Picker', () => {
await page.keyboard.type( 'Paragraph to be made "small"' );

await page.click( '.blocks-font-size .components-range-control__number' );
// This should be the "small" font-size of the current theme.
await page.keyboard.type( '18' );
// This should be the "small" font-size of the editor defaults.
await page.keyboard.type( '13' );

// Ensure content matches snapshot.
const content = await getEditedPostContent();
Expand Down