From 9352269b1ee99ecb9047c90fe5e367dc3716d0ae Mon Sep 17 00:00:00 2001 From: Eugene Manuilov Date: Tue, 30 Jun 2020 11:08:14 +0300 Subject: [PATCH 01/24] Add base write-scope-requests.test.js file. --- .../analytics/write-scope-requests.test.js | 57 +++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 tests/e2e/specs/modules/analytics/write-scope-requests.test.js diff --git a/tests/e2e/specs/modules/analytics/write-scope-requests.test.js b/tests/e2e/specs/modules/analytics/write-scope-requests.test.js new file mode 100644 index 00000000000..a060ca46a24 --- /dev/null +++ b/tests/e2e/specs/modules/analytics/write-scope-requests.test.js @@ -0,0 +1,57 @@ +/** + * Analytics write scope requests tests. + * + * Site Kit by Google, Copyright 2020 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Internal dependencies + */ +import { + deactivateUtilityPlugins, + resetSiteKit, + setSiteVerification, + setSearchConsoleProperty, + setupAnalytics, + useRequestInterception, +} from '../../../utils'; + +describe( 'Analytics write scope requests', () => { + beforeAll( async () => { + await page.setRequestInterception( true ); + useRequestInterception( ( request ) => { + if ( request.url().match( 'google-site-kit/v1/data/' ) ) { + request.respond( { + status: 200, + body: JSON.stringify( mockBatchResponse ), + } ); + } else { + request.continue(); + } + } ); + } ); + + beforeEach( async () => { + await activatePlugin( 'e2e-tests-oauth-callback-plugin' ) + await setSiteVerification(); + await setSearchConsoleProperty(); + await setupAnalytics(); + } ); + + afterEach( async () => { + await deactivateUtilityPlugins(); + await resetSiteKit(); + } ); +} ); From f5990e8f45a923de75e7431a1afb8e4d5b9a7f77 Mon Sep 17 00:00:00 2001 From: Eugene Manuilov Date: Wed, 1 Jul 2020 16:55:56 +0300 Subject: [PATCH 02/24] Add check for a notice above the button that explains user will need to grant additional permissions. --- .../analytics/common/account-create.js | 6 +-- jest-puppeteer.config.js | 40 ++++++++++++++++++ .../analytics/write-scope-requests.test.js | 42 +++++++++++++++---- 3 files changed, 76 insertions(+), 12 deletions(-) create mode 100644 jest-puppeteer.config.js diff --git a/assets/js/modules/analytics/common/account-create.js b/assets/js/modules/analytics/common/account-create.js index ec075d80870..8260f7559a5 100644 --- a/assets/js/modules/analytics/common/account-create.js +++ b/assets/js/modules/analytics/common/account-create.js @@ -162,10 +162,8 @@ export default function AccountCreate() { -

- { hasProvisioningScope && __( 'You will be redirected to Google Analytics to accept the terms of service.', 'google-site-kit' ) } - { ! hasProvisioningScope && __( 'You will need to give Site Kit permission to create an Analytics account on your behalf and also accept the Google Analytics terms of service.', 'google-site-kit' ) } -

+ { hasProvisioningScope &&

{ __( 'You will be redirected to Google Analytics to accept the terms of service.', 'google-site-kit' ) }

} + { ! hasProvisioningScope &&

{ __( 'You will need to give Site Kit permission to create an Analytics account on your behalf and also accept the Google Analytics terms of service.', 'google-site-kit' ) }

}
- { hasProvisioningScope &&

{ __( 'You will be redirected to Google Analytics to accept the terms of service.', 'google-site-kit' ) }

} - { ! hasProvisioningScope &&

{ __( 'You will need to give Site Kit permission to create an Analytics account on your behalf and also accept the Google Analytics terms of service.', 'google-site-kit' ) }

} + { hasProvisioningScope &&

{ __( 'You will be redirected to Google Analytics to accept the terms of service.', 'google-site-kit' ) }

} + { ! hasProvisioningScope &&

{ __( 'You will need to give Site Kit permission to create an Analytics account on your behalf and also accept the Google Analytics terms of service.', 'google-site-kit' ) }

}
+
+ +
+
- { hasProvisioningScope &&

{ __( 'You will be redirected to Google Analytics to accept the terms of service.', 'google-site-kit' ) }

} - { ! hasProvisioningScope &&

{ __( 'You will need to give Site Kit permission to create an Analytics account on your behalf and also accept the Google Analytics terms of service.', 'google-site-kit' ) }

} + { hasProvisioningScope &&

{ __( 'You will be redirected to Google Analytics to accept the terms of service.', 'google-site-kit' ) }

} + { ! hasProvisioningScope &&

{ __( 'You will need to give Site Kit permission to create an Analytics account on your behalf and also accept the Google Analytics terms of service.', 'google-site-kit' ) }

}
- { hasProvisioningScope &&

{ __( 'You will be redirected to Google Analytics to accept the terms of service.', 'google-site-kit' ) }

} - { ! hasProvisioningScope &&

{ __( 'You will need to give Site Kit permission to create an Analytics account on your behalf and also accept the Google Analytics terms of service.', 'google-site-kit' ) }

} +

+ { hasProvisioningScope && __( 'You will be redirected to Google Analytics to accept the terms of service.', 'google-site-kit' ) } + { ! hasProvisioningScope && __( 'You will need to give Site Kit permission to create an Analytics account on your behalf and also accept the Google Analytics terms of service.', 'google-site-kit' ) } +