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

Update E2E tests for Twenty Twenty theme #17566

Merged
merged 6 commits into from
Sep 25, 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
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\\":\\"white\\"} -->
<h2 class=\\"has-white-color\\">Heading</h2>
"<!-- wp:heading {\\"textColor\\":\\"accent\\"} -->
<h2 class=\\"has-accent-color\\">Heading</h2>
<!-- /wp:heading -->"
`;
Expand Down
8 changes: 4 additions & 4 deletions packages/e2e-tests/specs/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 whiteColorButtonSelector = `${ TEXT_COLOR_UI_X_SELECTOR }//button[@aria-label='Color: White']`;
const [ whiteColorButton ] = await page.$x( whiteColorButtonSelector );
await whiteColorButton.click();
const accentColorButtonSelector = `${ TEXT_COLOR_UI_X_SELECTOR }//button[@aria-label='Color: Accent Color']`;
const [ accentColorButton ] = await page.$x( accentColorButtonSelector );
await accentColorButton.click();
await page.click( '.wp-block-heading' );
await page.waitForXPath( `${ whiteColorButtonSelector }[@aria-pressed='true']` );
await page.waitForXPath( `${ accentColorButtonSelector }[@aria-pressed='true']` );
expect( await getEditedPostContent() ).toMatchSnapshot();
} );
} );
2 changes: 1 addition & 1 deletion packages/e2e-tests/specs/font-size-picker.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ describe( 'Font Size Picker', () => {

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( '19.5' );
await page.keyboard.type( '16' );

// Ensure content matches snapshot.
const content = await getEditedPostContent();
Expand Down
2 changes: 1 addition & 1 deletion packages/e2e-tests/specs/manage-reusable-blocks.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ describe( 'Managing reusable blocks', () => {
* @return {Promise} Promise resolving to number of post list entries.
*/
async function getNumberOfEntries() {
return page.evaluate( () => document.querySelectorAll( '.entry' ).length );
return page.evaluate( () => document.querySelectorAll( '.hentry' ).length );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.hentry? 🙃

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I'm not really sure how this ever worked. The rows in the Manage All Blocks screen have class hentry. We could maybe consider selecting .type-wp_block instead.

Screen Shot 2019-09-25 at 16 17 24

}

beforeAll( async () => {
Expand Down
4 changes: 2 additions & 2 deletions packages/e2e-tests/specs/preview.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -239,11 +239,11 @@ describe( 'Preview with Custom Fields enabled', () => {
// Return to editor and modify the title and content.
await editorPage.bringToFront();
await editorPage.click( '.editor-post-title__input' );
await pressKeyWithModifier( 'shift', 'Home' );
await pressKeyWithModifier( 'primary', 'a' );
await editorPage.keyboard.press( 'Delete' );
await editorPage.keyboard.type( 'title 2' );
await editorPage.keyboard.press( 'Tab' );
await pressKeyWithModifier( 'shift', 'Home' );
await pressKeyWithModifier( 'primary', 'a' );
await editorPage.keyboard.press( 'Delete' );
await editorPage.keyboard.type( 'content 2' );

Expand Down
18 changes: 16 additions & 2 deletions packages/e2e-tests/specs/typewriter.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ describe( 'TypeWriter', () => {

const positionAfterArrowUp = await getCaretPosition();

expect( positionAfterArrowUp ).toBeLessThan( newPosition );
expect( positionAfterArrowUp ).toBeLessThanOrEqual( newPosition );

// Should be scrolled to new position.
await page.keyboard.press( 'Enter' );
Expand All @@ -75,6 +75,13 @@ describe( 'TypeWriter', () => {
// Create first block.
await page.keyboard.press( 'Enter' );

// Create blocks until there is a scrollable container.
while ( await page.evaluate( () =>
! wp.dom.getScrollContainer( document.activeElement )
) ) {
await page.keyboard.press( 'Enter' );
}

await page.evaluate( () =>
wp.dom.getScrollContainer( document.activeElement ).scrollTop = 1
);
Expand Down Expand Up @@ -107,6 +114,13 @@ describe( 'TypeWriter', () => {
// Create first block.
await page.keyboard.press( 'Enter' );

// Create blocks until there is a scrollable container.
while ( await page.evaluate( () =>
! wp.dom.getScrollContainer( document.activeElement )
) ) {
await page.keyboard.press( 'Enter' );
}

let count = 0;

// Create blocks until the the typewriter effect kicks in.
Expand All @@ -131,7 +145,7 @@ describe( 'TypeWriter', () => {

const newBottomPosition = await getCaretPosition();

expect( newBottomPosition ).toBeLessThan( bottomPostition );
expect( newBottomPosition ).toBeLessThanOrEqual( bottomPostition );

// Should maintain new caret position.
await page.keyboard.press( 'Enter' );
Expand Down