Skip to content
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
11 changes: 7 additions & 4 deletions packages/e2e-test-utils/src/are-pre-publish-checks-enabled.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
/**
* Internal dependencies
*/
import { wpDataSelect } from './wp-data-select';

/**
* Verifies if publish checks are enabled.
* @return {boolean} Boolean which represents the state of prepublish checks.
*/
export async function arePrePublishChecksEnabled() {
return page.evaluate( () =>
window.wp.data.select( 'core/editor' ).isPublishSidebarEnabled()
);
export function arePrePublishChecksEnabled() {
return wpDataSelect( 'core/editor', 'isPublishSidebarEnabled' );
}
12 changes: 7 additions & 5 deletions packages/e2e-test-utils/src/get-all-blocks.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
/**
* Internal dependencies
*/
import { wpDataSelect } from './wp-data-select';

/**
* Returns an array with all blocks; Equivalent to calling wp.data.select( 'core/editor' ).getBlocks();
*
* @return {Promise} Promise resolving with an array containing all blocks in the document.
*/
export async function getAllBlocks() {
return await page.evaluate( () => {
const { select } = window.wp.data;
return select( 'core/editor' ).getBlocks();
} );
export function getAllBlocks() {
return wpDataSelect( 'core/editor', 'getBlocks' );
}
9 changes: 6 additions & 3 deletions packages/e2e-test-utils/src/get-edited-post-content.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
/**
* Internal dependencies
*/
import { wpDataSelect } from './wp-data-select';

/**
* Returns a promise which resolves with the edited post content (HTML string).
*
* @return {Promise} Promise resolving with post content markup.
*/
export async function getEditedPostContent() {
return await page.evaluate( () => {
return window.wp.data.select( 'core/editor' ).getEditedPostContent();
} );
return wpDataSelect( 'core/editor', 'getEditedPostContent' );
}
18 changes: 18 additions & 0 deletions packages/e2e-test-utils/src/wp-data-select.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/**
* Queries the WordPress data module.
* @param {string} store Store to query e.g: core/editor, core/blocks...
* @param {string} selector Selector to exectute e.g: getBlocks.
* @param {...Object} parameters Parameters to pass to the selector.
*
* @return {?Object} Result of querying.
*/
export function wpDataSelect( store, selector, ...parameters ) {
return page.evaluate(
( _store, _selector, ..._parameters ) => {
return window.wp.data.select( _store )[ _selector ]( ..._parameters );
},
store,
selector,
parameters
);
}