Skip to content

Add integration tests for the analytics adapter #22102

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 17 commits into
base: trunk
Choose a base branch
from

Conversation

leonidasmi
Copy link
Contributor

@leonidasmi leonidasmi commented Mar 12, 2025

Context

  • Adds integration tests for the analytics adapter

Summary

This PR can be summarized in the following changelog entry:

  • Adds integration tests for the analytics 4 adapter

Relevant technical choices:

  • Added the Site_Kit_Analytics_4_Adapter::set_analytics_4_module() and the Site_Kit_Analytics_4_Adapter::get_analytics_4_module() functions to facilitate testing - it shouldnt have an impact in the normal behavior of the class.

Test instructions

Test instructions for the acceptance test before the PR gets merged

This PR can be acceptance tested by following these steps:

  • Quickly Smoke test the organic sessions widget

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:

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/481

@coveralls
Copy link

coveralls commented Mar 12, 2025

Pull Request Test Coverage Report for Build becfdad042b62ad2f0ae038e96b2a9cec4516f14

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

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.1%) to 54.946%

Totals Coverage Status
Change from base Build 18e587253363eab23879045deb60a6ca96e0d042: 0.1%
Covered Lines: 30825
Relevant Lines: 56556

💛 - Coveralls

@leonidasmi leonidasmi changed the base branch from trunk to 580-add-integration-tests-for-search-console-adapter March 12, 2025 13:22
Base automatically changed from 580-add-integration-tests-for-search-console-adapter to trunk March 14, 2025 10:19
@leonidasmi leonidasmi added the changelog: non-user-facing Needs to be included in the 'Non-userfacing' category in the changelog label Mar 14, 2025
@leonidasmi leonidasmi marked this pull request as ready for review March 14, 2025 13:52
Copy link
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.

what about the methods:

  • __construct
  • set_analytics_4_module
  • is_connected

If certain methods are not worth writing tests for please add ignore annotation.

@vraja-pro
Copy link
Contributor

The test file names for is_connected and __construct should end with _Test.
Also for is_connected please add a test to include this case:
Screenshot 2025-03-18 at 15 25 45

thijsoo and others added 5 commits March 25, 2025 10:11
…tp-requests-to-site-kit-endpoints-when-on-our-own-rest-endpoints

# Conflicts:
#	src/dashboard/infrastructure/search-console/site-kit-search-console-adapter.php
…own-rest-endpoints' into 481-add-unitintegration-tests-for-the-analytics-adapter
@leonidasmi leonidasmi changed the base branch from trunk to 493-do-http-requests-to-site-kit-endpoints-when-on-our-own-rest-endpoints April 7, 2025 11:21
@leonidasmi leonidasmi force-pushed the 481-add-unitintegration-tests-for-the-analytics-adapter branch from 9fb1ae3 to 90719b8 Compare April 7, 2025 11:49
@leonidasmi leonidasmi force-pushed the 481-add-unitintegration-tests-for-the-analytics-adapter branch from 90719b8 to 0e46ec9 Compare April 7, 2025 11:53
@leonidasmi
Copy link
Contributor Author

Also for is_connected please add a test to include this case

I'm not including a test for that case, because we're removing that function anyway here.

When that PR is merged, I'll go back and do the appropriate changes

@pls78 pls78 force-pushed the 493-do-http-requests-to-site-kit-endpoints-when-on-our-own-rest-endpoints branch from bd71b78 to 13f30b7 Compare April 10, 2025 20:50
Copy link

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.

Base automatically changed from 493-do-http-requests-to-site-kit-endpoints-when-on-our-own-rest-endpoints to trunk April 10, 2025 21:37
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 merge conflict
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants