question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add e2e coverage for additional scopes requests

See original GitHub issue

#1566 introduced a more incremental way to request write scopes only when necessary. At the moment this is only used by Analytics, but shortly will be used by Tag Manager as well (#1608), and potentially further modules in the future.

While this has been tested and will be shipped without e2e tests in 1.9.0 (due to time constraints), we should have some e2e tests to cover these cases, since it’s not something that can reasonably be covered with Jest.


Do not alter or remove anything below. The following sections will be managed by moderators only.

Acceptance criteria

  • There should be new e2e tests for the following:
    • Creating an Analytics account (via proxy & provisioning API) when not having the https://www.googleapis.com/auth/analytics.provision scope yet. Expected experience:
      • The user sees a notice above the button that explains they will need to grant additional permissions.
      • Upon clicking the button, they’re redirected to OAuth (should be mocked).
      • When returning, their original action is automatically invoked, without requiring them to click the button again.
      • They should be redirected to the Analytics TOS (can be mocked to an immediate success redirect to Site Kit (...?gatoscallback=1...)).
      • They should end up on the dashboard.
    • Creating an Analytics property when not having the https://www.googleapis.com/auth/analytics.edit scope yet. Expected experience:
      • Upon clicking the button, a dialog opens informing the user that they will need to grant additional permissions.
      • Once they click that button, they’re redirected to OAuth (should be mocked).
      • When returning, their original action is automatically invoked, without requiring them to click the button again.
      • They should end up on the dashboard.
    • Creating an Analytics view when not having the https://www.googleapis.com/auth/analytics.edit scope yet. Expected experience should match the one for creating an Analytics property above.

Implementation Brief

  • Create a new write-scope-requests.test.js in tests/e2e/specs/modules/analytics
  • Implement a new describe for Analytics write scope requests
  • In a beforeAll, ensure that any oAuth requests are intercepted and successfully returned. See this example. Also ensure that any requests to the Analytics TOS as are also mocked and returned successfully.
  • In the beforeEach, ensure that the Analytics module is set up by adding the following helpers:
    • activatePlugin( 'e2e-tests-oauth-callback-plugin' )
    • setSiteVerification()
    • setSearchConsoleProperty()
    • setupAnalytics()
  • Write tests fulfilling the requirements as indicated in the AC.

QA Brief

Changelog entry

  • N/A

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:14 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
aaemnnosttvcommented, Jul 14, 2020

@felixarntz I’ve updated the AC for the first case (account provisioning) as mentioned above to only test up until the redirect to the TOS. This is because it would require more substantial changes to only test the gatoscallback handler which is already well tested in PHPUnit.

0reactions
tofumattcommented, Jul 15, 2020

Code here looks good to me and the tests behave appropriately, so moving to approval.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Add Coverage to e2e tests #6286 - angular/angular-cli - GitHub
E2E tests takes more time to run than unit tests so if you have lot of e2e tests covering each and every case...
Read more >
E2E Testing Part 4: Code-Coverage - SAP Blogs
Inside this 4th part we will implement code-coverage for e2e tests and realize integration tests using testcafe. UI Code Coverage for E2E tests....
Read more >
Best Practices for Creating End-to-End Tests - Datadog
Best practices for creating end-to-end tests · Define your test coverage · Build meaningful tests for key application workflows. Break workflows ...
Read more >
A Complete End to End (E2E) Testing Tutorial - LambdaTest
A comprehensive end to end Testing tutorial that covers what E2E Testing is, its importance, benefits, and how to perform it with real-time...
Read more >
Context-based Code Coverage (now with more .NET!) - Medium
We do this by analyzing incoming requests. If the Scope agent detects that an incoming request is originating from an instrumented test, then ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found