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

Try: Refactor contextual toolbar to work better with floats #11357

Merged
merged 5 commits into from
Nov 9, 2018
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Use block navigator to select the blocks
  • Loading branch information
notnownikki authored and Joen Asmussen committed Nov 9, 2018
commit 120fe08ad8e5eda11d8c60e9eb27daa14377d9fc
24 changes: 11 additions & 13 deletions test/e2e/specs/block-icons.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
* Internal dependencies
*/
import {
ACCESS_MODIFIER_KEYS,
pressWithModifier,
newPost,
insertBlock,
searchForBlock,
selectBlockByClientId,
} from '../support/utils';
import { activatePlugin, deactivatePlugin } from '../support/plugins';

Expand Down Expand Up @@ -34,18 +35,17 @@ async function getFirstInserterIcon() {
return await getInnerHTML( INSERTER_ICON_SELECTOR );
}

async function selectFirstBlock() {
await pressWithModifier( ACCESS_MODIFIER_KEYS, 'o' );
const navButtons = await page.$$( '.editor-block-navigation__item-button' );
await navButtons[ 0 ].click();
}

describe( 'Correctly Renders Block Icons on Inserter and Inspector', () => {
const dashIconRegex = /<svg.*?class=".*?dashicons-cart.*?">.*?<\/svg>/;
const circleString = '<circle cx="10" cy="10" r="10" fill="red" stroke="blue" stroke-width="10"></circle>';
const svgIcon = new RegExp( `<svg.*?viewBox="0 0 20 20".*?>${ circleString }</svg>` );

const getBlockIdFromBlockName = async ( blockName ) => {
return await page.$eval(
`[data-type="${ blockName }"] > .editor-block-list__block-edit`,
( el ) => el.getAttribute( 'data-block' )
);
};

const validateSvgIcon = ( iconHtml ) => {
expect( iconHtml ).toMatch( svgIcon );
};
Expand Down Expand Up @@ -81,7 +81,7 @@ describe( 'Correctly Renders Block Icons on Inserter and Inspector', () => {

it( 'Renders correctly the icon on the inspector', async () => {
await insertBlock( blockTitle );
await selectBlockByClientId( await getBlockIdFromBlockName( blockName ) );
await selectFirstBlock();
validateIcon( await getInnerHTML( INSPECTOR_ICON_SELECTOR ) );
} );
}
Expand All @@ -105,7 +105,6 @@ describe( 'Correctly Renders Block Icons on Inserter and Inspector', () => {
} );

describe( 'Block with dash icon and background and foreground colors', () => {
const blockName = 'test/test-dash-icon-colors';
const blockTitle = 'TestDashIconColors';
it( 'Renders the icon in the inserter with the correct colors', async () => {
await searchForBlock( blockTitle );
Expand All @@ -116,7 +115,7 @@ describe( 'Correctly Renders Block Icons on Inserter and Inspector', () => {

it( 'Renders the icon in the inspector with the correct colors', async () => {
await insertBlock( blockTitle );
await selectBlockByClientId( await getBlockIdFromBlockName( blockName ) );
await selectFirstBlock();
validateDashIcon(
await getInnerHTML( INSPECTOR_ICON_SELECTOR )
);
Expand All @@ -126,7 +125,6 @@ describe( 'Correctly Renders Block Icons on Inserter and Inspector', () => {
} );

describe( 'Block with svg icon and background color', () => {
const blockName = 'test/test-svg-icon-background';
const blockTitle = 'TestSvgIconBackground';
it( 'Renders the icon in the inserter with the correct background color and an automatically compute readable foreground color', async () => {
await searchForBlock( blockTitle );
Expand All @@ -137,7 +135,7 @@ describe( 'Correctly Renders Block Icons on Inserter and Inspector', () => {

it( 'Renders correctly the icon on the inspector', async () => {
await insertBlock( blockTitle );
await selectBlockByClientId( await getBlockIdFromBlockName( blockName ) );
await selectFirstBlock();
validateSvgIcon(
await getInnerHTML( INSPECTOR_ICON_SELECTOR )
);
Expand Down