From bcc34c934a78eaab4872f3bdb7239a966dff1a3b Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Sat, 30 Nov 2024 19:01:35 -0800 Subject: [PATCH] Temporarily work around errors related to non-hashes being supplied for ETag --- .../embed-optimizer/tests/test-cases/nested-figure-embed.php | 2 +- ...le-spotify-embed-outside-viewport-with-subsequent-script.php | 2 +- ...ingle-twitter-embed-inside-viewport-without-resized-data.php | 2 +- .../tests/test-cases/single-twitter-embed-inside-viewport.php | 2 +- .../single-twitter-embed-outside-viewport-on-mobile.php | 2 +- .../tests/test-cases/single-twitter-embed-outside-viewport.php | 2 +- .../test-cases/single-wordpress-tv-embed-inside-viewport.php | 2 +- .../test-cases/single-wordpress-tv-embed-outside-viewport.php | 2 +- .../tests/test-cases/single-youtube-embed-inside-viewport.php | 2 +- .../single-youtube-embed-outside-viewport-on-mobile.php | 2 +- .../tests/test-cases/single-youtube-embed-outside-viewport.php | 2 +- plugins/embed-optimizer/tests/test-cases/too-many-bookmarks.php | 2 +- ...on-lcp-background-image-with-fully-populated-sample-data.php | 2 +- ...-image-outside-viewport-with-fully-populated-sample-data.php | 2 +- .../test-cases/common-lcp-image-with-stale-sample-data.php | 2 +- ...ady-on-common-lcp-image-with-fully-populated-sample-data.php | 2 +- .../images-located-above-or-along-initial-viewport.php | 2 +- ...ground-image-outside-viewport-with-populated-url-metrics.php | 2 +- .../tests/test-cases/responsive-background-images.php | 2 +- plugins/image-prioritizer/tests/test-helper.php | 2 +- tests/class-optimization-detective-test-helpers.php | 2 +- 21 files changed, 21 insertions(+), 21 deletions(-) diff --git a/plugins/embed-optimizer/tests/test-cases/nested-figure-embed.php b/plugins/embed-optimizer/tests/test-cases/nested-figure-embed.php index 60c56b04ac..af194af46d 100644 --- a/plugins/embed-optimizer/tests/test-cases/nested-figure-embed.php +++ b/plugins/embed-optimizer/tests/test-cases/nested-figure-embed.php @@ -26,7 +26,7 @@ 'intersectionRatio' => 0, ), ), - false + null ); // This tests how the Embed Optimizer plugin plays along with other tag visitors. diff --git a/plugins/embed-optimizer/tests/test-cases/single-spotify-embed-outside-viewport-with-subsequent-script.php b/plugins/embed-optimizer/tests/test-cases/single-spotify-embed-outside-viewport-with-subsequent-script.php index 484b25cb2e..c384a05de9 100644 --- a/plugins/embed-optimizer/tests/test-cases/single-spotify-embed-outside-viewport-with-subsequent-script.php +++ b/plugins/embed-optimizer/tests/test-cases/single-spotify-embed-outside-viewport-with-subsequent-script.php @@ -10,7 +10,7 @@ 'resizedBoundingClientRect' => array_merge( $test_case->get_sample_dom_rect(), array( 'height' => 500 ) ), ), ), - false + null ); }, 'buffer' => ' diff --git a/plugins/embed-optimizer/tests/test-cases/single-twitter-embed-inside-viewport-without-resized-data.php b/plugins/embed-optimizer/tests/test-cases/single-twitter-embed-inside-viewport-without-resized-data.php index a477e65586..e8dd3bcfa9 100644 --- a/plugins/embed-optimizer/tests/test-cases/single-twitter-embed-inside-viewport-without-resized-data.php +++ b/plugins/embed-optimizer/tests/test-cases/single-twitter-embed-inside-viewport-without-resized-data.php @@ -10,7 +10,7 @@ // Intentionally omitting resizedBoundingClientRect here to test behavior when data isn't supplied. ), ), - 'embeds' + md5( 'embeds' ) ); }, 'buffer' => ' diff --git a/plugins/embed-optimizer/tests/test-cases/single-twitter-embed-inside-viewport.php b/plugins/embed-optimizer/tests/test-cases/single-twitter-embed-inside-viewport.php index bcf9d4d76d..fe9b4e04b1 100644 --- a/plugins/embed-optimizer/tests/test-cases/single-twitter-embed-inside-viewport.php +++ b/plugins/embed-optimizer/tests/test-cases/single-twitter-embed-inside-viewport.php @@ -10,7 +10,7 @@ 'resizedBoundingClientRect' => array_merge( $test_case->get_sample_dom_rect(), array( 'height' => 500 ) ), ), ), - 'embeds' + md5( 'embeds' ) ); }, 'buffer' => ' diff --git a/plugins/embed-optimizer/tests/test-cases/single-twitter-embed-outside-viewport-on-mobile.php b/plugins/embed-optimizer/tests/test-cases/single-twitter-embed-outside-viewport-on-mobile.php index abe89a61c8..e9c11ee495 100644 --- a/plugins/embed-optimizer/tests/test-cases/single-twitter-embed-outside-viewport-on-mobile.php +++ b/plugins/embed-optimizer/tests/test-cases/single-twitter-embed-outside-viewport-on-mobile.php @@ -22,7 +22,7 @@ od_get_url_metrics_slug( od_get_normalized_query_vars() ), $test_case->get_sample_url_metric( array( - 'etag' => 'embeds', + 'etag' => md5( 'embeds' ), 'viewport_width' => $viewport_width, 'elements' => $elements, ) diff --git a/plugins/embed-optimizer/tests/test-cases/single-twitter-embed-outside-viewport.php b/plugins/embed-optimizer/tests/test-cases/single-twitter-embed-outside-viewport.php index 36e2ea087d..ef63722773 100644 --- a/plugins/embed-optimizer/tests/test-cases/single-twitter-embed-outside-viewport.php +++ b/plugins/embed-optimizer/tests/test-cases/single-twitter-embed-outside-viewport.php @@ -10,7 +10,7 @@ 'resizedBoundingClientRect' => array_merge( $test_case->get_sample_dom_rect(), array( 'height' => 500 ) ), ), ), - 'embeds' + md5( 'embeds' ) ); }, 'buffer' => ' diff --git a/plugins/embed-optimizer/tests/test-cases/single-wordpress-tv-embed-inside-viewport.php b/plugins/embed-optimizer/tests/test-cases/single-wordpress-tv-embed-inside-viewport.php index 85a0e4e8e9..e8109f8155 100644 --- a/plugins/embed-optimizer/tests/test-cases/single-wordpress-tv-embed-inside-viewport.php +++ b/plugins/embed-optimizer/tests/test-cases/single-wordpress-tv-embed-inside-viewport.php @@ -10,7 +10,7 @@ 'resizedBoundingClientRect' => array_merge( $test_case->get_sample_dom_rect(), array( 'height' => 500 ) ), ), ), - false + null ); }, 'buffer' => ' diff --git a/plugins/embed-optimizer/tests/test-cases/single-wordpress-tv-embed-outside-viewport.php b/plugins/embed-optimizer/tests/test-cases/single-wordpress-tv-embed-outside-viewport.php index 7d3cd53df8..a9e56d9a71 100644 --- a/plugins/embed-optimizer/tests/test-cases/single-wordpress-tv-embed-outside-viewport.php +++ b/plugins/embed-optimizer/tests/test-cases/single-wordpress-tv-embed-outside-viewport.php @@ -10,7 +10,7 @@ 'resizedBoundingClientRect' => array_merge( $test_case->get_sample_dom_rect(), array( 'height' => 500 ) ), ), ), - false + null ); }, 'buffer' => ' diff --git a/plugins/embed-optimizer/tests/test-cases/single-youtube-embed-inside-viewport.php b/plugins/embed-optimizer/tests/test-cases/single-youtube-embed-inside-viewport.php index a6bb8384e0..5a96738bb0 100644 --- a/plugins/embed-optimizer/tests/test-cases/single-youtube-embed-inside-viewport.php +++ b/plugins/embed-optimizer/tests/test-cases/single-youtube-embed-inside-viewport.php @@ -10,7 +10,7 @@ 'resizedBoundingClientRect' => array_merge( $test_case->get_sample_dom_rect(), array( 'height' => 500 ) ), ), ), - 'embeds' + md5( 'embeds' ) ); }, 'buffer' => ' diff --git a/plugins/embed-optimizer/tests/test-cases/single-youtube-embed-outside-viewport-on-mobile.php b/plugins/embed-optimizer/tests/test-cases/single-youtube-embed-outside-viewport-on-mobile.php index 686be6ad15..7904d893b9 100644 --- a/plugins/embed-optimizer/tests/test-cases/single-youtube-embed-outside-viewport-on-mobile.php +++ b/plugins/embed-optimizer/tests/test-cases/single-youtube-embed-outside-viewport-on-mobile.php @@ -22,7 +22,7 @@ od_get_url_metrics_slug( od_get_normalized_query_vars() ), $test_case->get_sample_url_metric( array( - 'etag' => 'embeds', + 'etag' => md5( 'embeds' ), 'viewport_width' => $viewport_width, 'elements' => $elements, ) diff --git a/plugins/embed-optimizer/tests/test-cases/single-youtube-embed-outside-viewport.php b/plugins/embed-optimizer/tests/test-cases/single-youtube-embed-outside-viewport.php index 7f7de84cb4..bfd546ce7c 100644 --- a/plugins/embed-optimizer/tests/test-cases/single-youtube-embed-outside-viewport.php +++ b/plugins/embed-optimizer/tests/test-cases/single-youtube-embed-outside-viewport.php @@ -10,7 +10,7 @@ 'resizedBoundingClientRect' => array_merge( $test_case->get_sample_dom_rect(), array( 'height' => 500 ) ), ), ), - 'embeds' + md5( 'embeds' ) ); }, 'buffer' => ' diff --git a/plugins/embed-optimizer/tests/test-cases/too-many-bookmarks.php b/plugins/embed-optimizer/tests/test-cases/too-many-bookmarks.php index bd56e9c71d..ba36ecc4af 100644 --- a/plugins/embed-optimizer/tests/test-cases/too-many-bookmarks.php +++ b/plugins/embed-optimizer/tests/test-cases/too-many-bookmarks.php @@ -11,7 +11,7 @@ 'intersectionRatio' => 0.0, ), ), - false + null ); // Check what happens when there are too many bookmarks. diff --git a/plugins/image-prioritizer/tests/test-cases/common-lcp-background-image-with-fully-populated-sample-data.php b/plugins/image-prioritizer/tests/test-cases/common-lcp-background-image-with-fully-populated-sample-data.php index d7933e8eb9..c87e736fe9 100644 --- a/plugins/image-prioritizer/tests/test-cases/common-lcp-background-image-with-fully-populated-sample-data.php +++ b/plugins/image-prioritizer/tests/test-cases/common-lcp-background-image-with-fully-populated-sample-data.php @@ -8,7 +8,7 @@ 'isLCP' => true, ), ), - 'image-prioritizer/img,image-prioritizer/background-image,image-prioritizer/video' + md5( 'image-prioritizer/img,image-prioritizer/background-image,image-prioritizer/video' ) ); }, 'buffer' => ' diff --git a/plugins/image-prioritizer/tests/test-cases/common-lcp-image-and-lazy-loaded-image-outside-viewport-with-fully-populated-sample-data.php b/plugins/image-prioritizer/tests/test-cases/common-lcp-image-and-lazy-loaded-image-outside-viewport-with-fully-populated-sample-data.php index e1b84cb5d5..98eb86d890 100644 --- a/plugins/image-prioritizer/tests/test-cases/common-lcp-image-and-lazy-loaded-image-outside-viewport-with-fully-populated-sample-data.php +++ b/plugins/image-prioritizer/tests/test-cases/common-lcp-image-and-lazy-loaded-image-outside-viewport-with-fully-populated-sample-data.php @@ -15,7 +15,7 @@ $slug, $test_case->get_sample_url_metric( array( - 'etag' => 'image-prioritizer/img,image-prioritizer/background-image,image-prioritizer/video', + 'etag' => md5( 'image-prioritizer/img,image-prioritizer/background-image,image-prioritizer/video' ), 'viewport_width' => $viewport_width, 'elements' => array( array( diff --git a/plugins/image-prioritizer/tests/test-cases/common-lcp-image-with-stale-sample-data.php b/plugins/image-prioritizer/tests/test-cases/common-lcp-image-with-stale-sample-data.php index b542c00a0d..c90d5eed11 100644 --- a/plugins/image-prioritizer/tests/test-cases/common-lcp-image-with-stale-sample-data.php +++ b/plugins/image-prioritizer/tests/test-cases/common-lcp-image-with-stale-sample-data.php @@ -8,7 +8,7 @@ 'isLCP' => true, ), ), - 'image-prioritizer/img,image-prioritizer/background-image,image-prioritizer/video' + md5( 'image-prioritizer/img,image-prioritizer/background-image,image-prioritizer/video' ) ); }, 'buffer' => ' diff --git a/plugins/image-prioritizer/tests/test-cases/fetch-priority-high-already-on-common-lcp-image-with-fully-populated-sample-data.php b/plugins/image-prioritizer/tests/test-cases/fetch-priority-high-already-on-common-lcp-image-with-fully-populated-sample-data.php index c69565cc47..a59f1545d0 100644 --- a/plugins/image-prioritizer/tests/test-cases/fetch-priority-high-already-on-common-lcp-image-with-fully-populated-sample-data.php +++ b/plugins/image-prioritizer/tests/test-cases/fetch-priority-high-already-on-common-lcp-image-with-fully-populated-sample-data.php @@ -8,7 +8,7 @@ 'xpath' => '/*[1][self::HTML]/*[2][self::BODY]/*[1][self::IMG]', ), ), - 'image-prioritizer/img,image-prioritizer/background-image,image-prioritizer/video' + md5( 'image-prioritizer/img,image-prioritizer/background-image,image-prioritizer/video' ) ); }, 'buffer' => ' diff --git a/plugins/image-prioritizer/tests/test-cases/images-located-above-or-along-initial-viewport.php b/plugins/image-prioritizer/tests/test-cases/images-located-above-or-along-initial-viewport.php index b6885ded35..4e12bde38f 100644 --- a/plugins/image-prioritizer/tests/test-cases/images-located-above-or-along-initial-viewport.php +++ b/plugins/image-prioritizer/tests/test-cases/images-located-above-or-along-initial-viewport.php @@ -31,7 +31,7 @@ $slug, $test_case->get_sample_url_metric( array( - 'etag' => 'image-prioritizer/img,image-prioritizer/background-image,image-prioritizer/video', + 'etag' => md5( 'image-prioritizer/img,image-prioritizer/background-image,image-prioritizer/video' ), 'viewport_width' => $viewport_width, 'elements' => array( array( diff --git a/plugins/image-prioritizer/tests/test-cases/no-lcp-image-or-background-image-outside-viewport-with-populated-url-metrics.php b/plugins/image-prioritizer/tests/test-cases/no-lcp-image-or-background-image-outside-viewport-with-populated-url-metrics.php index bd60079243..507cefeca9 100644 --- a/plugins/image-prioritizer/tests/test-cases/no-lcp-image-or-background-image-outside-viewport-with-populated-url-metrics.php +++ b/plugins/image-prioritizer/tests/test-cases/no-lcp-image-or-background-image-outside-viewport-with-populated-url-metrics.php @@ -8,7 +8,7 @@ 'isLCP' => true, ), ), - 'image-prioritizer/img,image-prioritizer/background-image,image-prioritizer/video' + md5( 'image-prioritizer/img,image-prioritizer/background-image,image-prioritizer/video' ) ); }, 'buffer' => ' diff --git a/plugins/image-prioritizer/tests/test-cases/responsive-background-images.php b/plugins/image-prioritizer/tests/test-cases/responsive-background-images.php index 47f21a8753..3cc8e7747b 100644 --- a/plugins/image-prioritizer/tests/test-cases/responsive-background-images.php +++ b/plugins/image-prioritizer/tests/test-cases/responsive-background-images.php @@ -25,7 +25,7 @@ static function () use ( $mobile_breakpoint, $tablet_breakpoint ): array { $slug, $test_case->get_sample_url_metric( array( - 'etag' => 'image-prioritizer/img,image-prioritizer/background-image,image-prioritizer/video', + 'etag' => md5( 'image-prioritizer/img,image-prioritizer/background-image,image-prioritizer/video' ), 'viewport_width' => $viewport_width, 'element' => array( 'xpath' => sprintf( '/*[1][self::HTML]/*[2][self::BODY]/*[%d][self::DIV]', $div_index + 1 ), diff --git a/plugins/image-prioritizer/tests/test-helper.php b/plugins/image-prioritizer/tests/test-helper.php index 94614b68a3..c84b7202a2 100644 --- a/plugins/image-prioritizer/tests/test-helper.php +++ b/plugins/image-prioritizer/tests/test-helper.php @@ -207,7 +207,7 @@ public function data_provider_test_auto_sizes(): array { * @phpstan-param array{ xpath: string, isLCP: bool, intersectionRatio: int } $element_metrics */ public function test_auto_sizes( array $element_metrics, string $buffer, string $expected ): void { - $this->populate_url_metrics( array( $element_metrics ), 'image-prioritizer/img,image-prioritizer/background-image,image-prioritizer/video' ); + $this->populate_url_metrics( array( $element_metrics ), md5( 'image-prioritizer/img,image-prioritizer/background-image,image-prioritizer/video' ) ); $html_start_doc = '...'; $html_end_doc = ''; diff --git a/tests/class-optimization-detective-test-helpers.php b/tests/class-optimization-detective-test-helpers.php index 7f5fe4c36c..a0704a58ab 100644 --- a/tests/class-optimization-detective-test-helpers.php +++ b/tests/class-optimization-detective-test-helpers.php @@ -68,7 +68,7 @@ public function get_sample_dom_rect(): array { * Gets a sample URL metric. * * @phpstan-param array{ - * etag?: string, + * etag?: non-empty-string, * url?: string, * viewport_width?: int, * viewport_height?: int,