Skip to content
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

Merged
merged 7 commits into from
Jul 26, 2024

Conversation

westonruter
Copy link
Member

@westonruter westonruter commented Jul 26, 2024

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:

  • Image Prioritizer
  • Embed Optimizer
  • Optimization Detective

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, and remove_initial_tabs methods to a new Optimization_Detective_Test_Helpers helper trait.

@westonruter westonruter added [Type] Enhancement A suggestion for improvement of an existing feature [Plugin] Optimization Detective Issues for the Optimization Detective plugin [Plugin] Embed Optimizer Issues for the Embed Optimizer plugin (formerly Auto Sizes) skip changelog PRs that should not be mentioned in changelogs [Plugin] Image Prioritizer Issues for the Image Prioritizer plugin (dependent on Optimization Detective) labels Jul 26, 2024
Base automatically changed from fix/incomplete-url-metrics-handling-of-fetchpriority to trunk July 26, 2024 15:31
@westonruter westonruter force-pushed the update/image-prioritizer-test-case-location branch from 83bf261 to 174a2a2 Compare July 26, 2024 16:33
@westonruter westonruter added the no milestone PRs that do not have a defined milestone for release label Jul 26, 2024
@westonruter westonruter changed the title Move test cases into separate files Move Optimization Detective test cases into separate files and add helper trait to reduce code duplication Jul 26, 2024
@westonruter westonruter marked this pull request as ready for review July 26, 2024 17:49
@westonruter westonruter requested a review from swissspidy July 26, 2024 17:49
Copy link

github-actions bot commented Jul 26, 2024

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 props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: westonruter <westonruter@git.wordpress.org>
Co-authored-by: swissspidy <swissspidy@git.wordpress.org>

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';
Copy link
Member

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 :-)

Copy link
Member Author

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)

Copy link
Member

@swissspidy swissspidy left a 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 👍

@westonruter
Copy link
Member Author

That's a lot of changed lines

Yeah, sorry. But it's almost entirely just moving code from one place to another.

Co-authored-by: Pascal Birchler <pascalb@google.com>
@westonruter westonruter merged commit 9533db2 into trunk Jul 26, 2024
13 checks passed
@westonruter westonruter deleted the update/image-prioritizer-test-case-location branch July 26, 2024 21:29
@westonruter westonruter mentioned this pull request Aug 5, 2024
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no milestone PRs that do not have a defined milestone for release [Plugin] Embed Optimizer Issues for the Embed Optimizer plugin (formerly Auto Sizes) [Plugin] Image Prioritizer Issues for the Image Prioritizer plugin (dependent on Optimization Detective) [Plugin] Optimization Detective Issues for the Optimization Detective plugin skip changelog PRs that should not be mentioned in changelogs [Type] Enhancement A suggestion for improvement of an existing feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants