From 88a6678d32d97ea905cd4b82899ae204cf3f44a6 Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Thu, 17 Oct 2024 13:26:23 +0200 Subject: [PATCH] Add another test --- ...le-videos-with-desktop-metrics-missing.php | 83 +++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 plugins/image-prioritizer/tests/test-cases/multiple-videos-with-desktop-metrics-missing.php diff --git a/plugins/image-prioritizer/tests/test-cases/multiple-videos-with-desktop-metrics-missing.php b/plugins/image-prioritizer/tests/test-cases/multiple-videos-with-desktop-metrics-missing.php new file mode 100644 index 000000000..3e7aada3e --- /dev/null +++ b/plugins/image-prioritizer/tests/test-cases/multiple-videos-with-desktop-metrics-missing.php @@ -0,0 +1,83 @@ + static function ( Test_Image_Prioritizer_Helper $test_case ): void { + $breakpoint_max_widths = array( 480, 600, 782 ); + + add_filter( + 'od_breakpoint_max_widths', + static function () use ( $breakpoint_max_widths ) { + return $breakpoint_max_widths; + } + ); + + foreach ( $breakpoint_max_widths as $non_desktop_viewport_width ) { + OD_URL_Metrics_Post_Type::store_url_metric( + od_get_url_metrics_slug( od_get_normalized_query_vars() ), + $test_case->get_sample_url_metric( + array( + 'viewport_width' => $non_desktop_viewport_width, + 'elements' => array( + array( + 'isLCP' => true, + 'xpath' => '/*[1][self::HTML]/*[2][self::BODY]/*[1][self::VIDEO]', + 'boundingClientRect' => $test_case->get_sample_dom_rect(), + 'intersectionRatio' => 1.0, + ), + array( + 'isLCP' => false, + 'xpath' => '/*[1][self::HTML]/*[2][self::BODY]/*[2][self::VIDEO]', + 'boundingClientRect' => $test_case->get_sample_dom_rect(), + 'intersectionRatio' => 0.1, + ), + array( + 'isLCP' => false, + 'xpath' => '/*[1][self::HTML]/*[2][self::BODY]/*[3][self::VIDEO]', + 'boundingClientRect' => $test_case->get_sample_dom_rect(), + 'intersectionRatio' => 0.0, + ), + array( + 'isLCP' => false, + 'xpath' => '/*[1][self::HTML]/*[2][self::BODY]/*[4][self::VIDEO]', + 'boundingClientRect' => $test_case->get_sample_dom_rect(), + 'intersectionRatio' => 0.0, + ), + ), + ) + ) + ); + } + }, + 'buffer' => ' + + + + ... + + + + + + + + + + ', + 'expected' => ' + + + + ... + + + + + + + + + + + + + ', +);