Skip to content

Commit

Permalink
Fix: End to end tests do not disable the experiments (#18093)
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgefilipecosta committed Oct 24, 2019
1 parent dd8885b commit 63a0e56
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 16 deletions.
1 change: 1 addition & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions packages/e2e-test-utils/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## Master

### Breaking Changes
- The util function `enableExperimentalFeatures` was removed. It is now available for internal usage in the `e2e-tests` package.


## 2.0.0 (2019-05-21)

### Requirements
Expand Down
1 change: 0 additions & 1 deletion packages/e2e-test-utils/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ export { createURL } from './create-url';
export { deactivatePlugin } from './deactivate-plugin';
export { disablePrePublishChecks } from './disable-pre-publish-checks';
export { dragAndResize } from './drag-and-resize';
export { enableExperimentalFeatures } from './enable-experimental-features';
export { enablePageDialogAccept } from './enable-page-dialog-accept';
export { enablePrePublishChecks } from './enable-pre-publish-checks';
export { ensureSidebarOpened } from './ensure-sidebar-opened';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,9 @@
* WordPress dependencies
*/
import { addQueryArgs } from '@wordpress/url';
import { visitAdminPage } from '@wordpress/e2e-test-utils';

/**
* Internal dependencies
*/
import { visitAdminPage } from './visit-admin-page';

/**
* Enables experimental features from the plugin settings section.
*
* @param {Array} features Array of {string} selectors of settings to enable. Assumes they can be enabled with one click.
*/
export async function enableExperimentalFeatures( features ) {
async function setExperimentalFeaturesState( features, enable ) {
const query = addQueryArgs( '', {
page: 'gutenberg-experiments',
} );
Expand All @@ -23,7 +14,7 @@ export async function enableExperimentalFeatures( features ) {
await page.waitForSelector( feature );
const checkedSelector = `${ feature }[checked=checked]`;
const isChecked = !! ( await page.$( checkedSelector ) );
if ( ! isChecked ) {
if ( ( ! isChecked && enable ) || ( isChecked && ! enable ) ) {
await page.click( feature );
}
} ) );
Expand All @@ -32,3 +23,21 @@ export async function enableExperimentalFeatures( features ) {
page.click( '#submit' ),
] );
}

/**
* Enables experimental features from the plugin settings section.
*
* @param {Array} features Array of {string} selectors of settings to enable. Assumes they can be enabled with one click.
*/
export async function enableExperimentalFeatures( features ) {
await setExperimentalFeaturesState( features, true );
}

/**
* Disables experimental features from the plugin settings section.
*
* @param {Array} features Array of {string} selectors of settings to disable. Assumes they can be disabled with one click.
*/
export async function disableExperimentalFeatures( features ) {
await setExperimentalFeaturesState( features, false );
}
1 change: 1 addition & 0 deletions packages/e2e-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"@wordpress/jest-console": "file:../jest-console",
"@wordpress/jest-puppeteer-axe": "file:../jest-puppeteer-axe",
"@wordpress/scripts": "file:../scripts",
"@wordpress/url": "file:../url",
"expect-puppeteer": "^4.3.0",
"lodash": "^4.17.15",
"uuid": "^3.3.2"
Expand Down
23 changes: 20 additions & 3 deletions packages/e2e-tests/specs/experimental/block-transforms.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,25 @@ import {
* WordPress dependencies
*/
import {
createNewPost,
getAllBlocks,
getAvailableBlockTransforms,
getBlockSetting,
getEditedPostContent,
hasBlockSwitcher,
createNewPost,
enableExperimentalFeatures,
setPostContent,
selectBlockByClientId,
setPostContent,
transformBlockTo,
} from '@wordpress/e2e-test-utils';

/**
* Internal dependencies
*/
import {
enableExperimentalFeatures,
disableExperimentalFeatures,
} from '../../experimental-features';

/**
* Internal dependencies
*/
Expand Down Expand Up @@ -120,6 +127,16 @@ describe( 'Block transforms', () => {
}
} );

afterAll(
async () => {
await disableExperimentalFeatures( [
'#gutenberg-widget-experiments',
'#gutenberg-menu-block',
'#gutenberg-full-site-editing',
] );
}
);

it( 'should contain the expected transforms', async () => {
const transforms = mapValues(
pickBy(
Expand Down

0 comments on commit 63a0e56

Please sign in to comment.