Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it( 'Should be possible to change alignment', async () => {
expect( console ).toHaveWarned();
await insertRowBlock();
await selectRowBlock();
// Change horizontal alignment
await clickBlockToolbarButton( 'Change horizontal alignment of columns' );
await clickButton( 'Align columns right' );
expect( await page.$( '[data-type="wp-bootstrap-blocks/row"][data-alignment="right"]' ) ).not.toBeNull();
expect( await getEditedPostContent() ).toMatchSnapshot();
// Change vertical alignment
await clickBlockToolbarButton( 'Change vertical alignment of columns' );
await clickButton( 'Align columns bottom' );
expect( await page.$( '[data-type="wp-bootstrap-blocks/row"][data-vertical-alignment="bottom"]' ) ).not.toBeNull();
expect( await getEditedPostContent() ).toMatchSnapshot();
} );
it( 'Should be possible to change alignment', async () => {
expect( console ).toHaveWarned();
await insertRowBlock();
await selectRowBlock();
// Change horizontal alignment
await clickBlockToolbarButton( 'Change horizontal alignment of columns' );
await clickButton( 'Align columns right' );
expect( await page.$( '[data-type="wp-bootstrap-blocks/row"][data-alignment="right"]' ) ).not.toBeNull();
expect( await getEditedPostContent() ).toMatchSnapshot();
// Change vertical alignment
await clickBlockToolbarButton( 'Change vertical alignment of columns' );
await clickButton( 'Align columns bottom' );
expect( await page.$( '[data-type="wp-bootstrap-blocks/row"][data-vertical-alignment="bottom"]' ) ).not.toBeNull();
expect( await getEditedPostContent() ).toMatchSnapshot();
} );
it( 'Should be possible to change alignment', async () => {
await insertButtonBlock();
await selectButtonBlock();
// Change alignment
await clickBlockToolbarButton( 'Change button alignment' );
await clickButton( 'Align Text Center' );
expect( await page.$( '[data-type="wp-bootstrap-blocks/button"][data-alignment="center"]' ) ).not.toBeNull();
// Editor content should match snapshot
expect( await getEditedPostContent() ).toMatchSnapshot();
} );
} );
export const toolbarOptionIsActive = async ( toolbarLabel, buttonText ) => {
await clickBlockToolbarButton( toolbarLabel ); // Open toolbar
const isActive = ( await page.$x( `//button[contains(text(),"${ buttonText }") and contains(@class,"is-active")]` ) ).length === 1;
await page.keyboard.press( 'Escape' ); // Close toolbar
return isActive;
};
async switchFormat( buttonNumber ) {
await clickBlockToolbarButton( 'Pick an ad format' );
const formatButtonsSelector = '.wp-block-jetpack-wordads__format-picker button';
await waitForSelector( this.page, formatButtonsSelector );
const allButtons = await this.page.$$( formatButtonsSelector );
await allButtons[ buttonNumber ].click();
}