Skip to content

563 create endpoint to grant revoke consent#22011

Merged
vraja-pro merged 11 commits intotrunkfrom
563-create-endpoint-to-grant-revoke-consent
Feb 4, 2025
Merged

563 create endpoint to grant revoke consent#22011
vraja-pro merged 11 commits intotrunkfrom
563-create-endpoint-to-grant-revoke-consent

Conversation

@pls78
Copy link
Copy Markdown
Member

@pls78 pls78 commented Feb 2, 2025

Context

  • We want to add an endpoint to manage user consent to connect to the Site Kit plugin.

Summary

This PR can be summarized in the following changelog entry:

  • Adds an endpoint to manage user consent to connect to the Site Kit plugin.

Relevant technical choices:

  • Out of the scope of this PR, I fixed Is_Site_Kit_Configuration_Dismissed_Test and Set_Site_Kit_Configuration_Dismissal_Test by swapping the implementation of the two methods
  • The following test files/classes:
    • tests/Unit/Dashboard/User_Interface/Configuration/Site_Kit_Configuration_Permanent_Dismissal_Route_Check_Capabilities_Test.php
    • tests/Unit/Dashboard/User_Interface/Configuration/Site_Kit_Configuration_Permanent_Dismissal_Route_Constructor_Test.php
    • tests/Unit/Dashboard/User_Interface/Configuration/Site_Kit_Configuration_Permanent_Dismissal_Route_Get_Conditionals_Test.php
    • tests/Unit/Dashboard/User_Interface/Configuration/Site_Kit_Configuration_Permanent_Dismissal_Route_Register_Routes_Test.php
    • tests/Unit/Dashboard/Infrastructure/Configuration/Permanently_Dismissed_Site_Kit_Configuration_Repository_Constructor_Test.php
      have only been renamed for consistency with the tests introduced by this PR.

Test instructions

Test instructions for the acceptance test before the PR gets merged

This PR can be acceptance tested by following these steps:

  • Make sure you are logged in as admin
  • By using an API client of choice (e.g. Postmar or cURL), perform the following POST request:
    https://YOUR_WORDPRESS_SITE/wp-json/yoast/v1/site_kit_manage_consent
    whereYOUR_WORDPRESS_SITE is the URL of your WordPress installation
  • Set the request body as follows:
    {
      "consent": true
    }
    
    • Verify you get a successful response
  • With a MySQL inspect the value of the wpseo option array in the wp_options table
    • Verify that site_kit_connected is set to 1
  • Log in as an author
  • Perform the same API call as before
    • Verify you get a 403 - rest_forbidden response

Relevant test scenarios

  • Changes should be tested with the browser console open
  • Changes should be tested on different posts/pages/taxonomies/custom post types/custom taxonomies
  • Changes should be tested on different editors (Default Block/Gutenberg/Classic/Elementor/other)
  • Changes should be tested on different browsers
  • Changes should be tested on multisite

Test instructions for QA when the code is in the RC

  • QA should use the same steps as above.

Impact check

This PR affects the following parts of the plugin, which may require extra testing:

  • N/A

UI changes

  • This PR changes the UI in the plugin. I have added the 'UI change' label to this PR.

Other environments

  • This PR also affects Shopify. I have added a changelog entry starting with [shopify-seo], added test instructions for Shopify and attached the Shopify label to this PR.

Documentation

  • I have written documentation for this change. For example, comments in the Relevant technical choices, comments in the code, documentation on Confluence / shared Google Drive / Yoast developer portal, or other.

Quality assurance

  • I have tested this code to the best of my abilities.
  • During testing, I had activated all plugins that Yoast SEO provides integrations for.
  • I have added unit tests to verify the code works as intended.
  • If any part of the code is behind a feature flag, my test instructions also cover cases where the feature flag is switched off.
  • I have written this PR in accordance with my team's definition of done.
  • I have checked that the base branch is correctly set.

Innovation

  • No innovation project is applicable for this PR.
  • This PR falls under an innovation project. I have attached the innovation label.
  • I have added my hours to the WBSO document.

Fixes #

@coveralls
Copy link
Copy Markdown

coveralls commented Feb 2, 2025

Pull Request Test Coverage Report for Build 9238d2f41634d306df0dea1b2a3f970df4bc66db

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 35 of 48 (72.92%) changed or added relevant lines in 4 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-3.1%) to 54.506%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/dashboard/user-interface/configuration/site-kit-consent-management-route.php 27 32 84.38%
src/dashboard/infrastructure/endpoints/site-kit-consent-management-endpoint.php 0 8 0.0%
Totals Coverage Status
Change from base Build c975fa023e802752a88b75cc24841cc4d1888cd2: -3.1%
Covered Lines: 30205
Relevant Lines: 55852

💛 - Coveralls

@pls78 pls78 added the changelog: non-user-facing Needs to be included in the 'Non-userfacing' category in the changelog label Feb 3, 2025
@pls78 pls78 marked this pull request as ready for review February 3, 2025 10:10
'json' => (object) [
'success' => $result,
],
],
Copy link
Copy Markdown
Contributor

@vraja-pro vraja-pro Feb 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in order to accept the response (as in the test instructions):

{
  "consent": true
}

we should return:

return new WP_REST_Response(
			[
				'success' => $result,
			],

@vraja-pro
Copy link
Copy Markdown
Contributor

CR & AC ✅

@vraja-pro vraja-pro added this to the 24.6 milestone Feb 4, 2025
@vraja-pro vraja-pro merged commit 3c9e4a6 into trunk Feb 4, 2025
@vraja-pro vraja-pro deleted the 563-create-endpoint-to-grant-revoke-consent branch February 4, 2025 11:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog: non-user-facing Needs to be included in the 'Non-userfacing' category in the changelog

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants