-
Notifications
You must be signed in to change notification settings - Fork 110
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
Move Optimization Detective test cases into separate files and add helper trait to reduce code duplication #1405
Move Optimization Detective test cases into separate files and add helper trait to reduce code duplication #1405
Conversation
83bf261
to
174a2a2
Compare
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
@@ -5,7 +5,11 @@ | |||
* @package auto-sizes | |||
*/ | |||
|
|||
require_once __DIR__ . '/../../../tests/class-optimization-detective-test-helpers.php'; |
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.
We could load this just once in bootstrap, instead of in every test.
Or maybe an autoloader at some point :-)
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.
Yeah, adding it to the bootstrap is a good idea. I recall we did have an autoloader previously but it was removed as discussed in #1262 (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.
That's a lot of changed lines, but it makes the test cases definitely more manageable 👍
Yeah, sorry. But it's almost entirely just moving code from one place to another. |
Co-authored-by: Pascal Birchler <pascalb@google.com>
The test files are too large with the cases for testing Optimization Detective behavior. They need to be split into separate files to make this easier to work with. This has been done for:
It was overkill for Auto Sizes since the test data is smaller as it is only testing individual
img
tags not entire documents.This PR also removes a lot of duplication across plugin test suites by moving duplicated
populate_url_metrics
,get_validated_url_metric
, andremove_initial_tabs
methods to a newOptimization_Detective_Test_Helpers
helper trait.