woocommerce / google-listings-and-ads

Sync your store with Google to list products for free, run paid ads, and track performance straight from your store dashboard.
https://woo.com/products/google-listings-and-ads/
GNU General Public License v3.0
44 stars 21 forks source link

Change connection test page capabilities to manage_woocommerce #2443

Closed jorgemd24 closed 2 months ago

jorgemd24 commented 2 months ago

Changes proposed in this Pull Request:

Part of #2146

Currently, the connection test page is only available to the administrator because it is registered with the manage_options capability. However, all our endpoints are checking the manage_woocommerce capability.

https://github.com/woocommerce/google-listings-and-ads/blob/cbcff08cf1270def397a0317d55316c991c5efd2/src/API/PermissionsTrait.php#L20-L22

This makes it harder for a Shop Manager to debug any issues with the new approach as the connection test page is not available. Therefore, this PR updates the capability to manage_woocommerce. Since all actions available on the connection test page are also accessible through the UI for users with manage_woocommerce capability I don't think we are giving new privileges to the Shop Manager role.

Screenshots:

Detailed test instructions:

  1. Log in to wp-admin with a Shop Manager user role.
  2. Add this filter add_filter('woocommerce_gla_enable_connection_test','__return_true'); or navigate to wp-admin/admin.php?page=connection-test-admin-page
  3. Check that you can access the Connection Test Page.

Additional details:

Not sure why but the phpcs were failing for the account services test, so I fixed it in this PR.

Changelog entry

codecov[bot] commented 2 months ago

Codecov Report

Attention: Patch coverage is 0% with 4 lines in your changes missing coverage. Please review.

Project coverage is 64.5%. Comparing base (aec6d57) to head (e048937). Report is 477 commits behind head on feature/google-api-project.

Additional details and impacted files [![Impacted file tree graph](https://app.codecov.io/gh/woocommerce/google-listings-and-ads/pull/2443/graphs/tree.svg?width=650&height=150&src=pr&token=UROWUPF1LX&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=woocommerce)](https://app.codecov.io/gh/woocommerce/google-listings-and-ads/pull/2443?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=woocommerce) ```diff @@ Coverage Diff @@ ## feature/google-api-project #2443 +/- ## ============================================================== + Coverage 64.2% 64.5% +0.3% - Complexity 4484 4541 +57 ============================================================== Files 471 472 +1 Lines 18862 17707 -1155 ============================================================== - Hits 12117 11425 -692 + Misses 6745 6282 -463 ``` | [Flag](https://app.codecov.io/gh/woocommerce/google-listings-and-ads/pull/2443/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=woocommerce) | Coverage Δ | | |---|---|---| | [php-unit-tests](https://app.codecov.io/gh/woocommerce/google-listings-and-ads/pull/2443/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=woocommerce) | `64.5% <0.0%> (+0.3%)` | :arrow_up: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=woocommerce#carryforward-flags-in-the-pull-request-comment) to find out more. | [Files](https://app.codecov.io/gh/woocommerce/google-listings-and-ads/pull/2443?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=woocommerce) | Coverage Δ | | |---|---|---| | [src/ConnectionTest.php](https://app.codecov.io/gh/woocommerce/google-listings-and-ads/pull/2443?src=pr&el=tree&filepath=src%2FConnectionTest.php&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=woocommerce#diff-c3JjL0Nvbm5lY3Rpb25UZXN0LnBocA==) | `0.0% <0.0%> (ø)` | | ... and [202 files with indirect coverage changes](https://app.codecov.io/gh/woocommerce/google-listings-and-ads/pull/2443/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=woocommerce)