Skip to content

Commit

Permalink
Testing: Await E2E promise interactions (#14219)
Browse files Browse the repository at this point in the history
* Testing: Await E2E promise interactions

* Testing: Disable animations on every admin screen

* Testing: Refactor reusable block management to compare before/after entry count
  • Loading branch information
aduth authored and youknowriad committed Mar 20, 2019
1 parent a1b1f55 commit eb65b1f
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 11 deletions.
2 changes: 1 addition & 1 deletion packages/e2e-tests/plugins/disable-animations.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ function enqueue_disable_animations_stylesheet() {
wp_add_inline_style( 'wp-components', $custom_css );
}

add_action( 'enqueue_block_editor_assets', 'enqueue_disable_animations_stylesheet' );
add_action( 'admin_enqueue_scripts', 'enqueue_disable_animations_stylesheet' );
8 changes: 4 additions & 4 deletions packages/e2e-tests/specs/block-hierarchy-navigation.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ describe( 'Navigating the block hierarchy', () => {

// Tweak the columns count.
await page.focus( '.edit-post-settings-sidebar__panel-block .components-range-control__number[aria-label="Columns"]' );
page.keyboard.down( 'Shift' );
page.keyboard.press( 'ArrowLeft' );
page.keyboard.up( 'Shift' );
page.keyboard.type( '3' );
await page.keyboard.down( 'Shift' );
await page.keyboard.press( 'ArrowLeft' );
await page.keyboard.up( 'Shift' );
await page.keyboard.type( '3' );

// Navigate to the last column block.
await page.click( '[aria-label="Block Navigation"]' );
Expand Down
4 changes: 2 additions & 2 deletions packages/e2e-tests/specs/change-detection.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ describe( 'Change detection', () => {
await createNewPost();
} );

afterEach( () => {
afterEach( async () => {
if ( handleInterceptedRequest ) {
releaseSaveIntercept();
await releaseSaveIntercept();
}
} );

Expand Down
2 changes: 1 addition & 1 deletion packages/e2e-tests/specs/demo.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const stripIframeFromEmbed = ( embedObject ) => {

describe( 'new editor state', () => {
beforeAll( async () => {
setUpResponseMocking( [
await setUpResponseMocking( [
{
match: createURLMatcher( 'oembed%2F1.0%2Fproxy' ),
onRequestMatch: mockOrTransform( couldNotBePreviewed, MOCK_VIMEO_RESPONSE, stripIframeFromEmbed ),
Expand Down
18 changes: 16 additions & 2 deletions packages/e2e-tests/specs/manage-reusable-blocks.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,23 @@ import path from 'path';
import { visitAdminPage } from '@wordpress/e2e-test-utils';

describe( 'Managing reusable blocks', () => {
/**
* Returns a Promise which resolves to the number of post list entries on
* the current page.
*
* @return {Promise} Promise resolving to number of post list entries.
*/
async function getNumberOfEntries() {
return page.evaluate( () => document.querySelectorAll( '.entry' ).length );
}

beforeAll( async () => {
await visitAdminPage( 'edit.php', 'post_type=wp_block' );
} );

it( 'Should import reusable blocks', async () => {
const originalEntries = await getNumberOfEntries();

// Import Reusable block
await page.waitForSelector( '.list-reusable-blocks__container' );
const importButton = await page.$( '.list-reusable-blocks__container button' );
Expand All @@ -36,7 +48,9 @@ describe( 'Managing reusable blocks', () => {
// Refresh the page
await visitAdminPage( 'edit.php', 'post_type=wp_block' );

// The reusable block has been imported
page.waitForXPath( 'div[@class="post_title"][contains(text(), "Greeting")]' );
const expectedEntries = originalEntries + 1;
const actualEntries = await getNumberOfEntries();

expect( actualEntries ).toBe( expectedEntries );
} );
} );
2 changes: 1 addition & 1 deletion packages/e2e-tests/specs/taxonomies.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ describe( 'Taxonomies', () => {
await page.reload();

// Wait for the tags to load.
page.waitForSelector( '.components-form-token-field__token' );
await page.waitForSelector( '.components-form-token-field__token' );

tags = await getCurrentTags();

Expand Down

0 comments on commit eb65b1f

Please sign in to comment.