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

Force feature flag to always be enabled. #5111

Closed
wants to merge 4 commits into from
Closed
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
4 changes: 4 additions & 0 deletions assets/js/features/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ export const isFeatureEnabled = (
feature,
_enabledFeatures = enabledFeatures
) => {
if ( feature === 'unifiedDashboard' ) {
return true;
}

if ( ! ( _enabledFeatures instanceof Set ) ) {
return false;
}
Expand Down
4 changes: 4 additions & 0 deletions includes/Core/Util/Feature_Flags.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ public static function enabled( $feature ) {
return false;
}

if ( 'unifiedDashboard' === $feature ) {
return true;
}

/**
* Filters a feature flag's status (on or off).
*
Expand Down
134 changes: 134 additions & 0 deletions tests/e2e/specs/auth/gcp-flow-admin-2.test.js.orig
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
/**
* WordPress dependencies
*/
import {
activatePlugin,
loginUser,
createURL,
visitAdminPage,
} from '@wordpress/e2e-test-utils';

/**
* Internal dependencies
*/
import {
logoutUser,
safeLoginUser,
setAuthToken,
setSearchConsoleProperty,
setSiteVerification,
useRequestInterception,
wpApiFetch,
} from '../../utils';

describe( 'the set up flow for the second administrator', () => {
beforeAll( async () => {
await page.setRequestInterception( true );
useRequestInterception( ( request ) => {
const url = request.url();
if (
url.startsWith( 'https://accounts.google.com/o/oauth2/auth' )
) {
request.respond( {
status: 302,
headers: {
location: createURL(
'/wp-admin/index.php',
'oauth2callback=1&code=valid-test-code'
),
},
} );
<<<<<<< HEAD
} else if ( url.match( 'search-console/data/searchanalytics' ) ) {
request.respond( { status: 200, body: '[]' } );
} else if ( url.match( 'pagespeed-insights/data/pagespeed' ) ) {
request.respond( { status: 200, body: '{}' } );
} else if ( url.match( 'user/data/survey-timeouts' ) ) {
=======
} else if ( url.match( 'pagespeed-insights/data/pagespeed' ) ) {
request.respond( { status: 200, body: '{}' } );
} else if (
url.match( 'search-console/data/searchanalytics' ) ||
url.match( 'user/data/survey-timeouts' )
) {
>>>>>>> 87d77a8017 (Fix empty GET searchanalytics responses in e2e.)
request.respond( { status: 200, body: '[]' } );
} else {
request.continue();
}
} );
} );

beforeEach( async () => {
await activatePlugin( 'e2e-tests-gcp-credentials-plugin' );
await activatePlugin( 'e2e-tests-oauth-callback-plugin' );
await activatePlugin( 'e2e-tests-site-verification-api-mock' );
await setAuthToken();
await setSiteVerification();
await setSearchConsoleProperty();
await logoutUser();
} );

afterEach( async () => {
await logoutUser();

// Restore the default/admin user
// (switchToAdmin will not work as it is not aware of the current user)
await loginUser();
} );

it( 'connects a secondary admin after the initial set up', async () => {
await safeLoginUser( 'admin-2', 'password' );
// Ensure we're logged in with the correct user.
await expect( page ).toMatchElement(
'#wp-admin-bar-user-info .display-name',
{
text: 'admin-2',
}
);

// Simulate that the user is already verified.
await wpApiFetch( {
path: 'google-site-kit/v1/e2e/verify-site',
method: 'post',
} );
await visitAdminPage( 'admin.php', 'page=googlesitekit-splash' );

await expect( page ).toMatchElement(
'.googlesitekit-wizard-step__title',
{
text: /Authenticate with Google/i,
}
);

await Promise.all( [
expect( page ).toClick( '.googlesitekit-wizard-step button', {
text: /sign in with google/i,
} ),
page.waitForNavigation(),
] );

await page.waitForSelector( '.googlesitekit-wizard-step button' );
await expect( page ).toMatchElement(
'.googlesitekit-wizard-step__title',
{
text: /congratulations!/i,
}
);

await Promise.all( [
expect( page ).toClick( '.googlesitekit-wizard-step button', {
text: /go to dashboard/i,
} ),
page.waitForNavigation(),
] );

await expect( page ).toMatchElement( '#js-googlesitekit-dashboard' );
await expect( page ).toMatchElement(
'.googlesitekit-publisher-win__title',
{
text: /Congrats on completing the setup for Site Kit!/i,
}
);
} );
} );
125 changes: 125 additions & 0 deletions tests/e2e/specs/auth/gcp-flow.test.js.orig
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
/**
* WordPress dependencies
*/
import {
activatePlugin,
createURL,
visitAdminPage,
} from '@wordpress/e2e-test-utils';

/**
* Internal dependencies
*/
import {
deactivateUtilityPlugins,
resetSiteKit,
setSearchConsoleProperty,
useRequestInterception,
setAuthToken,
setSiteVerification,
} from '../../utils';

function handleRequest( request ) {
const url = request.url();
if ( url.startsWith( 'https://accounts.google.com/o/oauth2/auth' ) ) {
request.respond( {
status: 302,
headers: {
location: createURL(
'/wp-admin/index.php',
'oauth2callback=1&code=valid-test-code&e2e-site-verification=1'
),
},
} );
<<<<<<< HEAD
} else if ( url.match( 'search-console/data/searchanalytics' ) ) {
request.respond( { status: 200, body: '[]' } );
} else if ( url.match( 'pagespeed-insights/data/pagespeed' ) ) {
request.respond( { status: 200, body: '{}' } );
} else if ( url.match( 'user/data/survey-timeouts' ) ) {
=======
} else if ( url.match( 'pagespeed-insights/data/pagespeed' ) ) {
request.respond( { status: 200, body: '{}' } );
} else if (
url.match( 'search-console/data/searchanalytics' ) ||
url.match( 'user/data/survey-timeouts' )
) {
>>>>>>> 87d77a8017 (Fix empty GET searchanalytics responses in e2e.)
request.respond( { status: 200, body: '[]' } );
} else if ( url.match( 'search-console/data/matched-sites' ) ) {
request.respond( {
status: 200,
contentType: 'application/json',
body: JSON.stringify( [
{
siteURL: process.env.WP_BASE_URL,
permissionLevel: 'siteOwner',
},
] ),
} );
} else {
request.continue();
}
}

const disconnectFromSiteKit = async () => {
await page.waitForSelector( 'button[aria-controls="user-menu"]' );
await page.click( 'button[aria-controls="user-menu"]' );

await page.waitForSelector( '#user-menu .mdc-list-item' );
await page.click( '#user-menu .mdc-list-item' );

await page.waitForSelector(
'.mdc-dialog__container button.mdc-button--danger'
);
await page.click( '.mdc-dialog__container button.mdc-button--danger' );
await page.waitForNavigation();
};

describe( 'Site Kit set up flow for the first time', () => {
beforeEach( async () => {
await activatePlugin( 'e2e-tests-gcp-credentials-plugin' );
await setSearchConsoleProperty();
} );

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

it( 'authenticates from splash page', async () => {
await activatePlugin( 'e2e-tests-oauth-callback-plugin' );
await visitAdminPage( 'admin.php', 'page=googlesitekit-splash' );
// Sign in with Google
await page.setRequestInterception( true );
useRequestInterception( handleRequest );
await expect( page ).toClick( '.googlesitekit-wizard-step button', {
text: /sign in with Google/i,
} );
await page.waitForNavigation();

await expect( page ).toMatchElement( '#js-googlesitekit-dashboard' );
await expect( page ).toMatchElement(
'.googlesitekit-publisher-win__title',
{
text: /Congrats on completing the setup for Site Kit!/i,
}
);
} );

it( 'disconnects user from Site Kit', async () => {
await setAuthToken();
await setSiteVerification();
await visitAdminPage( 'admin.php', 'page=googlesitekit-dashboard' );

await disconnectFromSiteKit();

// Ensure the user is on step one of the setup wizard.
await expect(
page
).toMatchElement(
'.googlesitekit-wizard-progress-step__number-text--inprogress',
{ text: '1' }
);
} );
} );
Loading