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

Reorganize e2e tests folders and files #36734

Merged
merged 3 commits into from
Nov 29, 2021
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
1 change: 1 addition & 0 deletions packages/e2e-tests/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const baseConfig = require( '@wordpress/scripts/config/jest-e2e.config' );

module.exports = {
...baseConfig,
testMatch: [ '<rootDir>/specs/**/*.test.js' ],
setupFiles: [ '<rootDir>/config/gutenberg-phase.js' ],
setupFilesAfterEnv: [
'<rootDir>/config/setup-test-framework.js',
Expand Down
39 changes: 39 additions & 0 deletions packages/e2e-tests/specs/experiments/experimental-features.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/**
* WordPress dependencies
*/
import { addQueryArgs } from '@wordpress/url';
import { visitAdminPage } from '@wordpress/e2e-test-utils';

async function setExperimentalFeaturesState( features, enable ) {
const query = addQueryArgs( '', {
page: 'gutenberg-experiments',
} );
await visitAdminPage( '/admin.php', query );

await Promise.all(
features.map( async ( feature ) => {
await page.waitForSelector( feature );
const checkedSelector = `${ feature }[checked=checked]`;
const isChecked = !! ( await page.$( checkedSelector ) );
if ( ( ! isChecked && enable ) || ( isChecked && ! enable ) ) {
await page.click( feature );
}
} )
);
await Promise.all( [
page.waitForNavigation( { waitUntil: 'networkidle0' } ),
page.click( '#submit' ),
] );
}

/**
* Establishes test lifecycle to enable experimental feature for the duration of
* the grouped test block.
*
* @param {Array} features Array of {string} selectors of settings to enable.
* Assumes they can be enabled with one click.
*/
export function useExperimentalFeatures( features ) {
beforeAll( () => setExperimentalFeaturesState( features, true ) );
afterAll( () => setExperimentalFeaturesState( features, false ) );
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { addQueryArgs } from '@wordpress/url';
/**
* Internal dependencies
*/
import { useExperimentalFeatures } from '../../experimental-features';
import { useExperimentalFeatures } from './experimental-features';
import menuItemsFixture from './fixtures/menu-items-request-fixture.json';

const TYPE_NAMES = {
Expand Down
2 changes: 1 addition & 1 deletion packages/e2e-tests/specs/performance/site-editor.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
/**
* Internal dependencies
*/
import { siteEditor } from '../../experimental-features';
import { siteEditor } from '../site-editor/utils';
import {
readFile,
deleteFile,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { trashAllPosts, activateTheme } from '@wordpress/e2e-test-utils';
/**
* Internal dependencies
*/
import { siteEditor } from '../../experimental-features';
import { siteEditor } from './utils';

async function getDocumentSettingsTitle() {
const titleElement = await page.waitForSelector(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
/**
* Internal dependencies
*/
import { navigationPanel, siteEditor } from '../../experimental-features';
import { navigationPanel, siteEditor } from './utils';

const clickTemplateItem = async ( menus, itemName ) => {
await navigationPanel.open();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
/**
* Internal dependencies
*/
import { siteEditor } from '../../experimental-features';
import { siteEditor } from './utils';

describe( 'Multi-entity save flow', () => {
// Selectors - usable between Post/Site editors.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
/**
* Internal dependencies
*/
import { siteEditor } from '../../experimental-features';
import { siteEditor } from './utils';

async function toggleSidebar() {
await page.click(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { trashAllPosts, activateTheme } from '@wordpress/e2e-test-utils';
/**
* Internal dependencies
*/
import { siteEditor } from '../../experimental-features';
import { siteEditor } from './utils';

async function waitForFileExists( filePath, timeout = 10000 ) {
const start = Date.now();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { trashAllPosts, activateTheme } from '@wordpress/e2e-test-utils';
/**
* Internal dependencies
*/
import { siteEditor } from '../../experimental-features';
import { siteEditor } from './utils';

describe( 'Site Editor Inserter', () => {
beforeAll( async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
/**
* Internal dependencies
*/
import { siteEditor } from '../../experimental-features';
import { siteEditor } from './utils';

const templatePartNameInput =
'.edit-site-create-template-part-modal .components-text-control__input';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { addQueryArgs } from '@wordpress/url';
/**
* Internal dependencies
*/
import { siteEditor } from '../../experimental-features';
import { siteEditor } from './utils';

const {
visit: visitSiteEditor,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,40 +4,6 @@
import { addQueryArgs } from '@wordpress/url';
import { visitAdminPage } from '@wordpress/e2e-test-utils';

async function setExperimentalFeaturesState( features, enable ) {
const query = addQueryArgs( '', {
page: 'gutenberg-experiments',
} );
await visitAdminPage( '/admin.php', query );

await Promise.all(
features.map( async ( feature ) => {
await page.waitForSelector( feature );
const checkedSelector = `${ feature }[checked=checked]`;
const isChecked = !! ( await page.$( checkedSelector ) );
if ( ( ! isChecked && enable ) || ( isChecked && ! enable ) ) {
await page.click( feature );
}
} )
);
await Promise.all( [
page.waitForNavigation( { waitUntil: 'networkidle0' } ),
page.click( '#submit' ),
] );
}

/**
* Establishes test lifecycle to enable experimental feature for the duration of
* the grouped test block.
*
* @param {Array} features Array of {string} selectors of settings to enable.
* Assumes they can be enabled with one click.
*/
export function useExperimentalFeatures( features ) {
beforeAll( () => setExperimentalFeaturesState( features, true ) );
afterAll( () => setExperimentalFeaturesState( features, false ) );
}

export const navigationPanel = {
async open() {
const isOpen = !! ( await page.$(
Expand Down