Skip to content

Jetpack Connection Heath tests: Migrate from Jetpack plugin to Connection package#47837

Open
fgiannar wants to merge 19 commits intotrunkfrom
update/migrate-cnx-health-tests-to-package
Open

Jetpack Connection Heath tests: Migrate from Jetpack plugin to Connection package#47837
fgiannar wants to merge 19 commits intotrunkfrom
update/migrate-cnx-health-tests-to-package

Conversation

@fgiannar
Copy link
Copy Markdown
Contributor

@fgiannar fgiannar commented Mar 30, 2026

Closes CONNECT-219
Related to CONNECT-210

DO NOT MERGE till we have a final confirmation on the updated copies.

Proposed changes

Migrates Jetpack connection health / Site Health tests out of the Jetpack plugin into the automattic/jetpack-connection package, while keeping Jetpack-specific tests (e.g., Sync health) extensible via hooks.

Changes:

  • Introduces a connection-package health testing framework (Connection_Health_Test_Base, Connection_Health_Tests) and Site Health integration (Site_Health), and wires it into Manager::configure().
  • Updates Jetpack plugin surfaces (CLI, legacy debugger page, REST endpoints) to use Automattic\Jetpack\Connection\Connection_Health_Tests, and registers Jetpack-specific tests via jetpack_connection_tests_loaded.
  • Adds package PHPUnit coverage and documentation for the new framework; deprecates the legacy Jetpack Site Health integration functions.

Other information

  • Generate changelog entries for this PR (using AI).

Related product discussion/links

Does this pull request change what data or activity we track or use?

No

Testing instructions

Confirm no errors/Warnings and ensure the following results match on trunk vs current branch (make sure to test with both failing and successful tests too):

  • Site Heath Status: Visit Tools -> Site Health and confirm the Jetpack tests and results match.
  • Site Heath Info (Jetpack plugin only): Visit Tools -> Site Health -> Info tab and confirm the Jetpack tests and results match under Jetpack.
  • Legacy Debugger page (Jetpack plugin only): Visit the legacy debugger page (wp-admin/admin.php?page=jetpack-debugger) and confirm the same
  • CLI (Jetpack plugin only): Run wp jetpack status and confirm results match on trunk vs current branch
  • REST API (Jetpack plugin only for now - needs follow up PR):
  • GET wp-json/jetpack/v4/connection/test?_wpnonce=REPLACE_ME

REPLACE_ME = wpApiSettings.nonce (in your browser console when logged-in)

Important: Test the above once more, but this time with Jetpack on latest stable and one Jetpack plugin active on this branch. Alternatively test on a WoA site by having only wpcomsh plugin on the current branch.

Test without the Jetpack plugin: Test with Jetpack Social or Jetpack Boost only active and confirm the Jetpack tests are visible in Site Heath Status. Note that in these cases reconnecting Jetpack via an action is not possible.

Example with Jetpack plugin active:
Screenshot 2026-04-02 at 12 11 52

Example with Jetpack plugin not active:
Screenshot 2026-04-02 at 12 12 40

@fgiannar fgiannar self-assigned this Mar 30, 2026
@fgiannar fgiannar requested a review from a team as a code owner March 30, 2026 11:30
@fgiannar fgiannar added [Status] In Progress [Package] Connection [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ labels Mar 30, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 30, 2026

Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.

  • To test on WoA, go to the Plugins menu on a WoA dev site. Click on the "Upload" button and follow the upgrade flow to be able to upload, install, and activate the Jetpack Beta plugin. Once the plugin is active, go to Jetpack > Jetpack Beta, select your plugin (Jetpack or WordPress.com Site Helper), and enable the update/migrate-cnx-health-tests-to-package branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack update/migrate-cnx-health-tests-to-package
bin/jetpack-downloader test jetpack-mu-wpcom-plugin update/migrate-cnx-health-tests-to-package

Interested in more tips and information?

  • In your local development environment, use the jetpack rsync command to sync your changes to a WoA dev blog.
  • Read more about our development workflow here: PCYsg-eg0-p2
  • Figure out when your changes will be shipped to customers here: PCYsg-eg5-p2

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 30, 2026

Thank you for your PR!

When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:

  • ✅ Include a description of your PR changes.
  • ✅ Add a "[Status]" label (In Progress, Needs Review, ...).
  • ✅ Add testing instructions.
  • ✅ Specify whether this PR includes any changes to data or privacy.
  • ✅ Add changelog entries to affected projects

This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖


Follow this PR Review Process:

  1. Ensure all required checks appearing at the bottom of this PR are passing.
  2. Make sure to test your changes on all platforms that it applies to. You're responsible for the quality of the code you ship.
  3. You can use GitHub's Reviewers functionality to request a review.
  4. When it's reviewed and merged, you will be pinged in Slack to deploy the changes to WordPress.com simple once the build is done.

If you have questions about anything, reach out in #jetpack-developers for guidance!


Jetpack plugin:

No scheduled milestone found for this plugin.

If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack.

@jp-launch-control
Copy link
Copy Markdown

jp-launch-control bot commented Mar 30, 2026

Code Coverage Summary

Coverage changed in 6 files. Only the first 5 are listed here.

File Coverage Δ% Δ Uncovered
projects/plugins/jetpack/_inc/lib/debugger.php 0/28 (0.00%) 0.00% 18 💔
projects/packages/connection/src/class-external-storage.php 34/70 (48.57%) -1.43% 1 ❤️‍🩹
projects/packages/connection/src/class-manager.php 608/1015 (59.90%) -0.06% 1 ❤️‍🩹
projects/plugins/jetpack/_inc/lib/debugger/class-jetpack-cxn-tests.php 0/38 (0.00%) 0.00% -351 💚
projects/plugins/jetpack/_inc/lib/debugger/debug-functions.php 0/0 (—%) 100.00% -62 💚

3 files are newly checked for coverage.

File Coverage
projects/packages/connection/src/health/class-connection-health-tests.php 194/320 (60.62%) 💚
projects/packages/connection/src/class-site-health.php 54/72 (75.00%) 💚
projects/packages/connection/src/health/class-connection-health-test-base.php 204/239 (85.36%) 💚

Full summary · PHP report · JS report

Coverage check overridden by I don't care about code coverage for this PR Use this label to ignore the check for insufficient code coveage. .

@fgiannar fgiannar requested a review from a team as a code owner April 1, 2026 11:34
@fgiannar fgiannar removed the request for review from a team April 1, 2026 12:44
@github-actions github-actions bot added the Docs label Apr 2, 2026
@fgiannar fgiannar requested a review from Copilot April 2, 2026 08:58
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Migrates Jetpack connection health / Site Health tests out of the Jetpack plugin into the automattic/jetpack-connection package, while keeping Jetpack-specific tests (e.g., Sync health) extensible via hooks.

Changes:

  • Introduces a connection-package health testing framework (Connection_Health_Test_Base, Connection_Health_Tests) and Site Health integration (Site_Health), and wires it into Manager::configure().
  • Updates Jetpack plugin surfaces (CLI, legacy debugger page, REST endpoints) to use Automattic\Jetpack\Connection\Connection_Health_Tests, and registers Jetpack-specific tests via jetpack_connection_tests_loaded.
  • Adds package PHPUnit coverage and documentation for the new framework; deprecates the legacy Jetpack Site Health integration functions.

Reviewed changes

Copilot reviewed 20 out of 20 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
projects/plugins/jetpack/class.jetpack-cli.php Switches CLI connection status output to the connection package test suite.
projects/plugins/jetpack/changelog/update-migrate-cnx-health-tests-to-package Adds Jetpack plugin changelog fragment for the migration.
projects/plugins/jetpack/.phan/baseline.php Updates Phan baseline counts and removes suppressions tied to removed legacy test classes.
projects/plugins/jetpack/_inc/lib/debugger/debug-functions.php Deprecates legacy Site Health functions and routes them to the package test suite.
projects/plugins/jetpack/_inc/lib/debugger/class-jetpack-debugger.php Updates legacy debugger UI to use the package test suite for pass/fail display.
projects/plugins/jetpack/_inc/lib/debugger/class-jetpack-debug-data.php Updates debug info gathering to instantiate the package test suite.
projects/plugins/jetpack/_inc/lib/debugger/class-jetpack-cxn-tests.php Refactors Jetpack-specific tests to extend the package base and register onto a target suite.
projects/plugins/jetpack/_inc/lib/debugger/class-jetpack-cxn-test-base.php Converts legacy base class into a thin deprecated alias of the package base.
projects/plugins/jetpack/_inc/lib/debugger.php Removes legacy Site Health registrations; adds filters/actions to integrate with the package.
projects/plugins/jetpack/_inc/lib/class.core-rest-api-endpoints.php Updates REST endpoints to use the package test suite.
projects/packages/connection/tests/php/Site_Health_Test.php Adds tests for the new Site_Health integration behavior and legacy Jetpack deferral.
projects/packages/connection/tests/php/Connection_Health_Tests_Test.php Adds tests covering discovery and behavior of built-in connection tests.
projects/packages/connection/tests/php/Connection_Health_Test_Base_Test.php Adds tests for base framework helpers, output methods, filters, and extension patterns.
projects/packages/connection/src/health/class-connection-health-tests.php Introduces the package’s built-in connection health tests and extension hook.
projects/packages/connection/src/health/class-connection-health-test-base.php Introduces the reusable framework for registering/running tests and formatting outputs.
projects/packages/connection/src/class-site-health.php Implements package Site Health integration and defers when legacy Jetpack integration is detected.
projects/packages/connection/src/class-manager.php Initializes Site Health integration during connection Manager::configure().
projects/packages/connection/README.md Links to the new connection health tests documentation.
projects/packages/connection/docs/connection-health-tests.md Documents architecture, extension points, and how to run tests.
projects/packages/connection/changelog/update-migrate-cnx-health-tests-to-package Adds connection package changelog fragment for the migration.

Comment thread projects/packages/connection/src/health/class-connection-health-test-base.php Outdated
Comment thread projects/packages/connection/src/health/class-connection-health-test-base.php Outdated
Comment thread projects/packages/connection/src/health/class-connection-health-test-base.php Outdated
Comment thread projects/plugins/jetpack/changelog/update-migrate-cnx-health-tests-to-package Outdated
Comment thread projects/packages/connection/changelog/update-migrate-cnx-health-tests-to-package Outdated
Comment thread projects/plugins/jetpack/_inc/lib/debugger/class-jetpack-cxn-tests.php Outdated
Comment thread projects/plugins/jetpack/_inc/lib/debugger/class-jetpack-cxn-tests.php Outdated
Comment thread projects/packages/connection/docs/connection-health-tests.md Outdated
@fgiannar fgiannar added [Status] Needs Review This PR is ready for review. I don't care about code coverage for this PR Use this label to ignore the check for insufficient code coveage. and removed [Status] In Progress labels Apr 2, 2026
darssen
darssen previously approved these changes Apr 2, 2026
Copy link
Copy Markdown
Contributor

@darssen darssen left a comment

Choose a reason for hiding this comment

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

Hi @fgiannar many thanks for moving the tests to the Connection Package and for the added docs 👍

From a pure testing perspective, everything looked fine in my tests.

I tested all of the environments you described, but only tested connection failing with a couple of scenarios.

coder-karen
coder-karen previously approved these changes Apr 6, 2026
Copy link
Copy Markdown
Contributor

@coder-karen coder-karen left a comment

Choose a reason for hiding this comment

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

Thanks for working on this!

Also tested, though not much of connection failing scenarios.

Looks good, just left a question above, not a blocker.

Comment thread projects/packages/connection/src/class-site-health.php
@fgiannar fgiannar dismissed stale reviews from coder-karen and darssen via 12cb448 April 7, 2026 12:40
@fgiannar fgiannar added the DO NOT MERGE don't merge it! label Apr 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

DO NOT MERGE don't merge it! Docs I don't care about code coverage for this PR Use this label to ignore the check for insufficient code coveage. [Package] Connection [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Status] Needs Review This PR is ready for review. [Tests] Includes Tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants