Skip to content

Commit

Permalink
Update experimental features tests (#48164)
Browse files Browse the repository at this point in the history
* Update experimental features tests

* Add @parallel tag

* Fix feature check

* Add more output where it doesn't generate misleading failures

* Remove deliberately failing property

* Align with #48032

* remove separate experimental data test file

* cleanup commented code

* remove failing case

* Drop wp.editSite check, as it appears to already be obsolete
  • Loading branch information
deBhal authored Dec 24, 2020
1 parent 251a800 commit 5881cb3
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 67 deletions.
52 changes: 0 additions & 52 deletions test/e2e/specs/wp-gutenberg-experimental-data-spec.js

This file was deleted.

47 changes: 32 additions & 15 deletions test/e2e/specs/wp-gutenberg-experimental-features-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@ const gutenbergUser =
const EXPERIMENTAL_FEATURES = {
'@wordpress/block-editor': [ '__experimentalBlock', '__experimentalInserterMenuExtension' ],
'@wordpress/date': [ '__experimentalGetSettings' ],
'@wordpress/interface': [ '__experimentalMainDashboardButton' ],
'@wordpress/components': [ '__experimentalNavigationBackButton' ],
'@wordpress/edit-site': [ '__experimentalMainDashboardButton' ],
};

/**
Expand All @@ -50,34 +48,38 @@ before( async function () {
driver = await driverManager.startBrowser();
} );

describe( `[${ host }] Experimental features we depend on are available (${ screenSize })`, function () {
describe( `[${ host }] Experimental features we depend on are available (${ screenSize }) @parallel`, function () {
this.timeout( mochaTimeOut );

step( 'Can log in', async function () {
this.loginFlow = new LoginFlow( driver, gutenbergUser );
return await this.loginFlow.loginAndStartNewPost( null, true );
} );

for ( const [ packageName, features ] of Object.entries( EXPERIMENTAL_FEATURES ) ) {
// Removes the `@wordpress/` prefix and hyphens from package name
// The algorithm WP uses to convert package names to variable names is here: https://github.com/WordPress/gutenberg/blob/a03ea51e11a36d0abeecb4ce4e4cea5ffebdffc5/packages/dependency-extraction-webpack-plugin/lib/util.js#L40-L45
const wpGlobalName = camelCaseDash( packageName.substr( '@wordpress/'.length ) );
describe( 'Can find experimental package features', async function () {
for ( const [ packageName, features ] of Object.entries( EXPERIMENTAL_FEATURES ) ) {
// Removes the `@wordpress/` prefix and hyphens from package name
// The algorithm WP uses to convert package names to variable names is here: https://github.com/WordPress/gutenberg/blob/a03ea51e11a36d0abeecb4ce4e4cea5ffebdffc5/packages/dependency-extraction-webpack-plugin/lib/util.js#L40-L45
const wpGlobalName = camelCaseDash( packageName.substr( '@wordpress/'.length ) );

describe( packageName, () => {
step(
`"${ wpGlobalName }" package should be available in the global window object`,
async () => {
async function () {
const typeofPackage = await driver.executeScript(
`typeof window.wp['${ wpGlobalName }']`
`return typeof window.wp['${ wpGlobalName }']`
);
assert.notStrictEqual(
typeofPackage,
'undefined',
`${ wpGlobalName } is ${ typeofPackage }`
);
assert.notStrictEqual( typeofPackage, 'undefined'`${ wpGlobalName } is undefined` );
}
);

for ( const feature of features ) {
step( `${ feature } should be available in ${ packageName }`, async () => {
step( `${ feature } should be available in ${ packageName }`, async function () {
const typeofExperimentalFeature = await driver.executeScript(
`typeof window.wp['${ wpGlobalName }']['${ feature }']`
`return typeof window.wp['${ wpGlobalName }']['${ feature }']`
);
assert.notStrictEqual(
typeofExperimentalFeature,
Expand All @@ -86,8 +88,23 @@ describe( `[${ host }] Experimental features we depend on are available (${ scre
);
} );
}
} );
}
}
} );

describe( 'Experimental data we depend on is available', function () {
step(
`is iterable: wp.data.select( 'core/editor' ).getEditorSettings().__experimentalBlockPatterns`,
async function () {
const __experimentalBlockPatternsAreIterable = await driver.executeScript(
`return Array.isArray( window.wp.data.select( 'core/editor' ).getEditorSettings().__experimentalBlockPatterns )`
);
assert(
__experimentalBlockPatternsAreIterable,
'__experimentalBlockPatterns was not iterable, please contact #team-ganon to update premium pattern highlighting'
);
}
);
} );

after( async () => {
return await driver.switchTo().defaultContent();
Expand Down

0 comments on commit 5881cb3

Please sign in to comment.