-
Notifications
You must be signed in to change notification settings - Fork 851
Add/unit tests to blaze controllers #46688
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
Conversation
|
Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.
Interested in more tips and information?
|
|
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
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:
If you have questions about anything, reach out in #jetpack-developers for guidance! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds comprehensive unit test coverage for the Dashboard_REST_Controller class in the Blaze package. The tests validate the functionality implemented in three previous PRs that handle local post data processing when Jetpack sync is not yet complete.
Changes:
- Added extensive test suite with 1481 lines covering all Dashboard_REST_Controller endpoints
- Introduced WooCommerce mocks to test product price functionality
- Modified Dashboard_REST_Controller to accept Connection_Manager via constructor for better testability
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| projects/packages/blaze/tests/php/Dashboard_REST_Controller_Test.php | Comprehensive test suite covering authentication, endpoint redirection, local post processing, and WooCommerce integration |
| projects/packages/blaze/tests/php/mocks/class-wc-product.php | Mock WC_Product classes for testing product price functionality |
| projects/packages/blaze/tests/php/mocks/woocommerce-functions.php | Mock WooCommerce functions for price formatting and product retrieval |
| projects/packages/blaze/tests/php/bootstrap.php | Updated to load WooCommerce mocks before test environment initialization |
| projects/packages/blaze/src/class-dashboard-rest-controller.php | Added constructor with optional Connection_Manager parameter for dependency injection |
| projects/packages/blaze/changelog/add-unit-tests-to-blaze-controllers | Changelog entry documenting test coverage addition |
projects/packages/blaze/src/class-dashboard-rest-controller.php
Outdated
Show resolved
Hide resolved
projects/packages/blaze/src/class-dashboard-rest-controller.php
Outdated
Show resolved
Hide resolved
projects/packages/blaze/changelog/add-unit-tests-to-blaze-controllers
Outdated
Show resolved
Hide resolved
projects/packages/blaze/tests/php/Dashboard_REST_Controller_Test.php
Outdated
Show resolved
Hide resolved
Code Coverage SummaryCoverage changed in 1 file.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
projects/packages/blaze/changelog/add-unit-tests-to-blaze-controllers
Outdated
Show resolved
Hide resolved
projects/packages/blaze/tests/php/Dashboard_REST_Controller_Test.php
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
projects/packages/blaze/tests/php/Dashboard_REST_Controller_Test.php
Outdated
Show resolved
Hide resolved
projects/packages/blaze/tests/php/Dashboard_REST_Controller_Test.php
Outdated
Show resolved
Hide resolved
projects/packages/blaze/tests/php/Dashboard_REST_Controller_Test.php
Outdated
Show resolved
Hide resolved
EkaterinaStancheva
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍 Thank you! I tested and it works as expected!
Part of ADS-626
Proposed changes:
This PR adds a coverage test for the Dashboard_REST_Controller. It should include the missing coverage from my last three PRs (#46642, #46623 and #46578)
The only noticeable change I made to the base class is allowing the connection manager to be sent in the constructor, so I can correctly test those controllers.
Other information:
Jetpack product discussion
N/A
Does this pull request change what data or activity we track or use?
No
Testing instructions: