Skip to content

Add integration tests for analytics adapter#22888

Merged
vraja-pro merged 8 commits intotrunkfrom
add/integration-tests-for-analytics-adapter
Jan 28, 2026
Merged

Add integration tests for analytics adapter#22888
vraja-pro merged 8 commits intotrunkfrom
add/integration-tests-for-analytics-adapter

Conversation

@leonidasmi
Copy link
Copy Markdown
Contributor

@leonidasmi leonidasmi commented Jan 14, 2026

Context

Summary

This PR can be summarized in the following changelog entry:

  • Adds integration tests for analytics adapter.

Relevant technical choices:

  • We used to try and test also how Site Kit responds when a user that hasn't authenticated its modules with their Google account tries to request our integration data. This has now been removed due to inherent restrictions of our integration tests. In more detail:
    • Because we're working with the external Site Kit plugin which registers its endpoints upon init and the way we require that plugin means that it happens after init has been fired, we had to re-trigger init ourselves (which is something we dont want).
    • To avoid re-triggering init, we have to manually use Site Kit's classes to register its endpoints, but this gets a bit messy: 00d428c
    • To conclude,we removed all that, thus making the PR test mostly our side of things (aka, the way we handle mocked responses from Site Kit's), and if we still want to test Site Kit's side and predictability, we can put more prio to the other automated testing task.

Test instructions

Test instructions for the acceptance test before the PR gets merged

This PR can be acceptance tested by following these steps:

  • N/A

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

Impact check

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

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.
  • This PR also affects Yoast SEO for Google Docs. I have added a changelog entry starting with [yoast-doc-extension], added test instructions for Yoast SEO for Google Docs and attached the Google Docs Add-on 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.
  • I have run grunt build:images and commited the results, if my PR introduces new images or SVGs.

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 #

@leonidasmi leonidasmi added the changelog: non-user-facing Needs to be included in the 'Non-userfacing' category in the changelog label Jan 14, 2026
@coveralls
Copy link
Copy Markdown

coveralls commented Jan 14, 2026

Pull Request Test Coverage Report for Build c571f6f7c0a3ddedbd56c66f8b514ca25a1a9017

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.
  • 13 unchanged lines in 2 files lost coverage.
  • Overall coverage decreased (-0.4%) to 52.949%

Files with Coverage Reduction New Missed Lines %
src/generators/schema/howto.php 4 93.75%
src/integrations/blocks/structured-data-blocks.php 9 12.5%
Totals Coverage Status
Change from base Build ff2f33de1ce7594487c7285b42c46e5570ceee1c: -0.4%
Covered Lines: 32390
Relevant Lines: 61220

💛 - Coveralls

@leonidasmi leonidasmi force-pushed the add/integration-tests-for-analytics-adapter branch from 6047382 to 674bfa7 Compare January 14, 2026 11:28
@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.

@leonidasmi leonidasmi marked this pull request as ready for review January 26, 2026 08:51
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.

  • The class that is being tested is Site_Kit_Analytics_4_Adapter but the folder name is Analytics_4, I would expect to have a folder in Analytics_4 named Site_Kit_Analytics_4_Adapter and the tests file name should be names only after the method that is being tested without the prefix.
  • get_period method was not covered with tests.

@leonidasmi
Copy link
Copy Markdown
Contributor Author

leonidasmi commented Jan 28, 2026

The class that is being tested is Site_Kit_Analytics_4_Adapter but the folder name is Analytics_4, I would expect to have a folder in Analytics_4 named Site_Kit_Analytics_4_Adapter and the tests file name should be names only after the method that is being tested without the prefix

that's exactly what we're doing with the tests of the other module's adapter, Search_Console_Adapter in the very same folder, I'd leave it as is.

For covering get_period(), I pushed a couple of commits.

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 ✅ coverage 💯

@vraja-pro vraja-pro added this to the 27.0 milestone Jan 28, 2026
@vraja-pro vraja-pro merged commit a335bb1 into trunk Jan 28, 2026
31 checks passed
@vraja-pro vraja-pro deleted the add/integration-tests-for-analytics-adapter branch January 28, 2026 12:30
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