Skip to content

Commit

Permalink
Merge pull request #602 from google/fix/e2e-deactivate-utilities
Browse files Browse the repository at this point in the history
Update E2E plugin deactivation utility to only touch utility plugins
  • Loading branch information
felixarntz authored Sep 26, 2019
2 parents ff0bcb7 + abfe387 commit 39e8d2d
Show file tree
Hide file tree
Showing 13 changed files with 34 additions and 34 deletions.
6 changes: 3 additions & 3 deletions tests/e2e/config/bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { getQueryArg } from '@wordpress/url';
*/
import {
clearSessionStorage,
deactivateAllOtherPlugins,
deactivateUtilityPlugins,
resetSiteKit,
} from '../utils';
import {
Expand Down Expand Up @@ -210,7 +210,7 @@ beforeAll( async () => {
}
await setBrowserViewport( 'large' );

await deactivateAllOtherPlugins();
await deactivateUtilityPlugins();
await resetSiteKit();
} );

Expand All @@ -221,7 +221,7 @@ afterEach( async () => {
} );

afterAll( async () => {
await deactivateAllOtherPlugins();
await deactivateUtilityPlugins();
await resetSiteKit();
removePageEvents();
await page.setRequestInterception( false );
Expand Down
4 changes: 2 additions & 2 deletions tests/e2e/specs/auth-flow.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { activatePlugin, createURL, visitAdminPage } from '@wordpress/e2e-test-u
* Internal dependencies
*/
import {
deactivateAllOtherPlugins,
deactivateUtilityPlugins,
resetSiteKit,
pasteText,
setSearchConsoleProperty,
Expand Down Expand Up @@ -60,7 +60,7 @@ describe( 'Site Kit set up flow for the first time', () => {
} );

afterEach( async () => {
await deactivateAllOtherPlugins();
await deactivateUtilityPlugins();
await resetSiteKit();
} );

Expand Down
4 changes: 2 additions & 2 deletions tests/e2e/specs/auth-setup-search-console.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { activatePlugin, createURL, visitAdminPage } from '@wordpress/e2e-test-u
* Internal dependencies
*/
import {
deactivateAllOtherPlugins,
deactivateUtilityPlugins,
pasteText,
resetSiteKit,
testClientConfig,
Expand Down Expand Up @@ -48,7 +48,7 @@ describe( 'Site Kit set up flow for the first time with search console setup', (
} );

afterEach( async () => {
await deactivateAllOtherPlugins();
await deactivateUtilityPlugins();
await resetSiteKit();
} );

Expand Down
4 changes: 2 additions & 2 deletions tests/e2e/specs/auth-setup-verification.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { activatePlugin, createURL, visitAdminPage } from '@wordpress/e2e-test-u
* Internal dependencies
*/
import {
deactivateAllOtherPlugins,
deactivateUtilityPlugins,
pasteText,
resetSiteKit,
testClientConfig,
Expand Down Expand Up @@ -42,7 +42,7 @@ describe( 'Site Kit set up flow for the first time with site verification', () =
} );

afterEach( async () => {
await deactivateAllOtherPlugins();
await deactivateUtilityPlugins();
await resetSiteKit();
} );

Expand Down
4 changes: 2 additions & 2 deletions tests/e2e/specs/modules/adsense/setup-new-user.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { createURL, activatePlugin, visitAdminPage } from '@wordpress/e2e-test-u
* Internal dependencies
*/
import {
deactivateAllOtherPlugins,
deactivateUtilityPlugins,
resetSiteKit,
setAuthToken,
setClientConfig,
Expand Down Expand Up @@ -89,7 +89,7 @@ describe( 'setting up the AdSense module', () => {

afterEach( async () => {
Object.keys( datapointHandlers ).forEach( ( key ) => datapointHandlers[ key ] = defaultHandler );
await deactivateAllOtherPlugins();
await deactivateUtilityPlugins();
await resetSiteKit();
} );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { activatePlugin, createURL, visitAdminPage } from '@wordpress/e2e-test-u
* Internal dependencies
*/
import {
deactivateAllOtherPlugins,
deactivateUtilityPlugins,
resetSiteKit,
useRequestInterception,
setSearchConsoleProperty,
Expand Down Expand Up @@ -48,7 +48,7 @@ describe( 'setting up the Analytics module with no existing account and no exist
} );

afterEach( async () => {
await deactivateAllOtherPlugins();
await deactivateUtilityPlugins();
await resetSiteKit();
} );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { activatePlugin, visitAdminPage } from '@wordpress/e2e-test-utils';
* Internal dependencies
*/
import {
deactivateAllOtherPlugins,
deactivateUtilityPlugins,
resetSiteKit,
setAnalyticsExistingPropertyId,
setAuthToken,
Expand Down Expand Up @@ -66,7 +66,7 @@ describe( 'setting up the Analytics module with no existing account and with an
} );

afterEach( async () => {
await deactivateAllOtherPlugins();
await deactivateUtilityPlugins();
await resetSiteKit();
} );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { activatePlugin, createURL, visitAdminPage } from '@wordpress/e2e-test-u
* Internal dependencies
*/
import {
deactivateAllOtherPlugins,
deactivateUtilityPlugins,
resetSiteKit,
setSearchConsoleProperty,
wpApiFetch,
Expand Down Expand Up @@ -73,7 +73,7 @@ describe( 'setting up the Analytics module with an existing account and no exist
} );

afterEach( async () => {
await deactivateAllOtherPlugins();
await deactivateUtilityPlugins();
await resetSiteKit();
} );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { activatePlugin, visitAdminPage } from '@wordpress/e2e-test-utils';
* Internal dependencies
*/
import {
deactivateAllOtherPlugins,
deactivateUtilityPlugins,
resetSiteKit,
setAnalyticsExistingPropertyId,
setAuthToken,
Expand Down Expand Up @@ -68,7 +68,7 @@ describe( 'setting up the Analytics module with an existing account and existing
} );

afterEach( async () => {
await deactivateAllOtherPlugins();
await deactivateUtilityPlugins();
await resetSiteKit();
} );

Expand Down
4 changes: 2 additions & 2 deletions tests/e2e/specs/modules/pagespeed-insights/activation.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { visitAdminPage, activatePlugin } from '@wordpress/e2e-test-utils';
* Internal dependencies
*/
import {
deactivateAllOtherPlugins,
deactivateUtilityPlugins,
pasteText,
resetSiteKit,
setSearchConsoleProperty,
Expand All @@ -22,7 +22,7 @@ describe( 'PageSpeed Insights Activation', () => {
} );

afterEach( async () => {
await deactivateAllOtherPlugins();
await deactivateUtilityPlugins();
await resetSiteKit();
} );

Expand Down
4 changes: 2 additions & 2 deletions tests/e2e/specs/modules/tagmanager/setup.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { activatePlugin, visitAdminPage, createURL } from '@wordpress/e2e-test-u
* Internal dependencies
*/
import {
deactivateAllOtherPlugins,
deactivateUtilityPlugins,
resetSiteKit,
useRequestInterception,
setSearchConsoleProperty,
Expand Down Expand Up @@ -49,7 +49,7 @@ describe( 'setting up the TagManager module with no existing account', () => {
} );

afterEach( async () => {
await deactivateAllOtherPlugins();
await deactivateUtilityPlugins();
await resetSiteKit();
} );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,30 @@
import { switchUserToAdmin, visitAdminPage, switchUserToTest, isCurrentURL } from '@wordpress/e2e-test-utils';

/**
* Deactivate all plugins except Site Kit.
* Deactivate Site Kit utility plugins.
*/
export async function deactivateAllOtherPlugins() {
export async function deactivateUtilityPlugins() {
await switchUserToAdmin();

if ( ! isCurrentURL( 'wp-admin/plugins.php' ) ) {
await visitAdminPage( 'plugins.php' );
}

await page.waitForSelector( 'input[type="checkbox"][value="google-site-kit/google-site-kit.php"]' );
const activePlugins = await page.$$eval( '.active[data-plugin]', ( rows ) => {
await page.waitForSelector( '#wpfooter' );

const activeUtilities = await page.$$eval( '.active[data-plugin^="google-site-kit-test-plugins/"]', ( rows ) => {
return rows.map( ( row ) => row.dataset.plugin );
} );

// Bail if there are no plugins to deactivate
if ( 1 === activePlugins.length && 'google-site-kit/google-site-kit.php' === activePlugins[ 0 ] ) {
if ( ! activeUtilities.length ) {
return;
}

// Select all plugins
await page.click( '#cb-select-all-1' );

// Uncheck Site Kit
await page.click( 'input[type="checkbox"][value="google-site-kit/google-site-kit.php"]' );
// Check the boxes of plugins to deactivate.
await page.$$eval( '.active[data-plugin^="google-site-kit-test-plugins/"] input[type="checkbox"]', ( checkboxes ) => {
checkboxes.forEach( ( checkbox ) => checkbox.checked = true );
} );

// Bulk deactivate
await page.select( 'select#bulk-action-selector-bottom', 'deactivate-selected' );
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/utils/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export { clearSessionStorage } from './clear-session-storage';
export { deactivateAllOtherPlugins } from './deactivate-all-other-plugins';
export { deactivateUtilityPlugins } from './deactivate-utility-plugins';
export { logoutUser } from './logout-user';
export { pasteText } from './paste-text';
export { resetSiteKit } from './reset';
Expand Down

0 comments on commit 39e8d2d

Please sign in to comment.