Skip to content

Commit 415846d

Browse files
committed
Explicitly test variable-height embeds
1 parent 9169bca commit 415846d

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

plugins/embed-optimizer/tests/test-cases/single-twitter-embed-outside-viewport-on-mobile.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
<?php
22
return array(
33
'set_up' => static function ( Test_Embed_Optimizer_Optimization_Detective $test_case ): void {
4-
foreach ( array_merge( od_get_breakpoint_max_widths(), array( 1000 ) ) as $viewport_width ) {
4+
foreach ( array_merge( od_get_breakpoint_max_widths(), array( 1000 ) ) as $i => $viewport_width ) {
55
$elements = array(
66
array(
77
'xpath' => '/*[1][self::HTML]/*[2][self::BODY]/*[1][self::FIGURE]/*[1][self::DIV]',
88
'isLCP' => true,
9-
'resizedBoundingClientRect' => array_merge( $test_case->get_sample_dom_rect(), array( 'height' => 500 ) ),
9+
'resizedBoundingClientRect' => array_merge( $test_case->get_sample_dom_rect(), array( 'height' => 500 + $i * 100 ) ),
1010
),
1111
);
1212

@@ -17,7 +17,7 @@
1717
}
1818

1919
$sample_size = od_get_url_metrics_breakpoint_sample_size();
20-
for ( $i = 0; $i < $sample_size; $i++ ) {
20+
for ( $j = 0; $j < $sample_size; $j++ ) {
2121
OD_URL_Metrics_Post_Type::store_url_metric(
2222
od_get_url_metrics_slug( od_get_normalized_query_vars() ),
2323
$test_case->get_sample_url_metric(
@@ -53,9 +53,9 @@
5353
<title>...</title>
5454
<style>
5555
@media (max-width: 480px) { #embed-optimizer-a7659db28ecaa36ddee6ae66857dabd8 { min-height: 500px; } }
56-
@media (min-width: 481px) and (max-width: 600px) { #embed-optimizer-a7659db28ecaa36ddee6ae66857dabd8 { min-height: 500px; } }
57-
@media (min-width: 601px) and (max-width: 782px) { #embed-optimizer-a7659db28ecaa36ddee6ae66857dabd8 { min-height: 500px; } }
58-
@media (min-width: 783px) { #embed-optimizer-a7659db28ecaa36ddee6ae66857dabd8 { min-height: 500px; } }
56+
@media (min-width: 481px) and (max-width: 600px) { #embed-optimizer-a7659db28ecaa36ddee6ae66857dabd8 { min-height: 600px; } }
57+
@media (min-width: 601px) and (max-width: 782px) { #embed-optimizer-a7659db28ecaa36ddee6ae66857dabd8 { min-height: 700px; } }
58+
@media (min-width: 783px) { #embed-optimizer-a7659db28ecaa36ddee6ae66857dabd8 { min-height: 800px; } }
5959
</style>
6060
<link data-od-added-tag rel="preconnect" href="https://pbs.twimg.com" media="(min-width: 481px)">
6161
<link data-od-added-tag rel="preconnect" href="https://syndication.twitter.com" media="(min-width: 481px)">

plugins/embed-optimizer/tests/test-cases/single-wordpress-tv-embed-outside-viewport-on-mobile.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
<?php
22
return array(
33
'set_up' => static function ( Test_Embed_Optimizer_Optimization_Detective $test_case ): void {
4-
foreach ( array_merge( od_get_breakpoint_max_widths(), array( 1000 ) ) as $viewport_width ) {
4+
foreach ( array_merge( od_get_breakpoint_max_widths(), array( 1000 ) ) as $i => $viewport_width ) {
55
$elements = array(
66
array(
77
'xpath' => '/*[1][self::HTML]/*[2][self::BODY]/*[1][self::FIGURE]/*[1][self::DIV]',
88
'isLCP' => true,
9-
'resizedBoundingClientRect' => array_merge( $test_case->get_sample_dom_rect(), array( 'height' => 500 ) ),
9+
'resizedBoundingClientRect' => array_merge( $test_case->get_sample_dom_rect(), array( 'height' => 500 + $i * 100 ) ),
1010
),
1111
);
1212

@@ -50,9 +50,9 @@
5050
<title>...</title>
5151
<style>
5252
@media (max-width: 480px) { #embed-optimizer-a7659db28ecaa36ddee6ae66857dabd8 { min-height: 500px; } }
53-
@media (min-width: 481px) and (max-width: 600px) { #embed-optimizer-a7659db28ecaa36ddee6ae66857dabd8 { min-height: 500px; } }
54-
@media (min-width: 601px) and (max-width: 782px) { #embed-optimizer-a7659db28ecaa36ddee6ae66857dabd8 { min-height: 500px; } }
55-
@media (min-width: 783px) { #embed-optimizer-a7659db28ecaa36ddee6ae66857dabd8 { min-height: 500px; } }
53+
@media (min-width: 481px) and (max-width: 600px) { #embed-optimizer-a7659db28ecaa36ddee6ae66857dabd8 { min-height: 600px; } }
54+
@media (min-width: 601px) and (max-width: 782px) { #embed-optimizer-a7659db28ecaa36ddee6ae66857dabd8 { min-height: 700px; } }
55+
@media (min-width: 783px) { #embed-optimizer-a7659db28ecaa36ddee6ae66857dabd8 { min-height: 800px; } }
5656
</style>
5757
<link data-od-added-tag rel="preconnect" href="https://public-api.wordpress.com" media="(min-width: 481px)">
5858
<link data-od-added-tag rel="preconnect" href="https://v0.wordpress.com" media="(min-width: 481px)">

0 commit comments

Comments
 (0)