Skip to content

Add unit tests for ai-consent#22415

Merged
vraja-pro merged 20 commits intotrunkfrom
617-ai-consent-unit-tests
Jul 30, 2025
Merged

Add unit tests for ai-consent#22415
vraja-pro merged 20 commits intotrunkfrom
617-ai-consent-unit-tests

Conversation

@SergeyBiryukov
Copy link
Copy Markdown
Member

@SergeyBiryukov SergeyBiryukov commented Jul 8, 2025

Context

Summary

This PR can be summarized in the following changelog entry:

  • Adds unit tests covering the classes in src/ai-consent directory.

Relevant technical choices:

Test instructions

Test instructions for the acceptance test before the PR gets merged

This PR can be acceptance tested by following these steps:

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.

QA can test this PR by following these steps:

Impact check

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

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 https://github.com/Yoast/reserved-tasks/issues/617

@coveralls
Copy link
Copy Markdown

coveralls commented Jul 8, 2025

Pull Request Test Coverage Report for Build 2651e113d3b5014200fcee579a9723355686ffc6

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

  • 1 of 1 (100.0%) changed or added relevant line in 1 file are covered.
  • 76 unchanged lines in 5 files lost coverage.
  • Overall coverage decreased (-0.2%) to 52.353%

Files with Coverage Reduction New Missed Lines %
src/conditionals/ai-editor-conditional.php 1 0.0%
admin/class-admin-asset-manager.php 3 16.22%
src/ai-generator/user-interface/get-usage-route.php 22 0.0%
src/integrations/admin/redirects-page-integration.php 24 45.45%
admin/class-config.php 26 0.0%
Totals Coverage Status
Change from base Build 9c25037ba1d2718e9c26760b2e404c0bc55ce252: -0.2%
Covered Lines: 30586
Relevant Lines: 59089

💛 - Coveralls

@SergeyBiryukov SergeyBiryukov added the changelog: non-user-facing Needs to be included in the 'Non-userfacing' category in the changelog label Jul 10, 2025
@SergeyBiryukov SergeyBiryukov marked this pull request as ready for review July 10, 2025 23:54
@pls78 pls78 changed the base branch from feature/ai-generator-in-free to trunk July 15, 2025 09:20
@pls78 pls78 removed this from the feature/ai-generator-in-free milestone Jul 15, 2025
@github-actions
Copy link
Copy Markdown

A merge conflict has been detected for the proposed code changes in this PR. Please resolve the conflict by either rebasing the PR or merging in changes from the base branch.

@vraja-pro vraja-pro changed the base branch from trunk to release/25.6 July 15, 2025 14:27
@vraja-pro vraja-pro changed the base branch from release/25.6 to trunk July 15, 2025 14:30
Copy link
Copy Markdown
Contributor

@vraja-pro vraja-pro left a comment

Choose a reason for hiding this comment

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

CR 🚧

  • In some class cover annotation is used in the method level and the class level and that generated a warning. Remove that cover annotation on the method level and the extra space, and that would resolve the warnings.
  • Some methods are not covered, so either mention in the Technical debt section why or add coverage:
    • Consent_Route::consent
    • Consent_Route::check_permissions
    • Ai_Consent_Integration::get_script_data

@SergeyBiryukov
Copy link
Copy Markdown
Member Author

  • In some class cover annotation is used in the method level and the class level and that generated a warning. Remove that cover annotation on the method level and the extra space, and that would resolve the warnings.

  • Some methods are not covered, so either mention in the Technical debt section why or add coverage

Thanks @vraja-pro, all the suggestions are applied now.

@SergeyBiryukov SergeyBiryukov requested a review from vraja-pro July 22, 2025 01:20
@vraja-pro
Copy link
Copy Markdown
Contributor

Missing coverage for the catch block for the Consent_Route::consent method
Screenshot 2025-07-24 at 15 13 15

@SergeyBiryukov
Copy link
Copy Markdown
Member Author

Missing coverage for the catch block for the Consent_Route::consent method

@vraja-pro Thanks, added 🙂

Copy link
Copy Markdown
Contributor

@vraja-pro vraja-pro left a comment

Choose a reason for hiding this comment

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

CR ✅

@vraja-pro vraja-pro added this to the 25.8 milestone Jul 30, 2025
@vraja-pro vraja-pro merged commit d4d7d4e into trunk Jul 30, 2025
27 checks passed
@vraja-pro vraja-pro deleted the 617-ai-consent-unit-tests branch July 30, 2025 12:54
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.

4 participants