+
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
new file mode 100644
index 0000000000..113950c837
--- /dev/null
+++ b/plugins/embed-optimizer/tests/test-cases/single-twitter-embed-inside-viewport-without-resized-data.php
@@ -0,0 +1,49 @@
+ static function ( Test_Embed_Optimizer_Optimization_Detective $test_case ): void {
+ $test_case->populate_url_metrics(
+ array(
+ array(
+ 'xpath' => '/*[1][self::HTML]/*[2][self::BODY]/*[1][self::FIGURE]/*[1][self::DIV]',
+ 'isLCP' => true,
+ 'intersectionRatio' => 1,
+ // Intentionally omitting resizedBoundingClientRect here to test behavior when data isn't supplied.
+ ),
+ )
+ );
+ },
+ 'buffer' => '
+
+
+
+
...
+
+
+
+
+
+ ',
+ 'expected' => '
+
+
+
+
...
+
+
+
+
+
+
+
+ ',
+);
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 1336dcfcbd..1e7d455393 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
@@ -4,9 +4,10 @@
$test_case->populate_url_metrics(
array(
array(
- 'xpath' => '/*[1][self::HTML]/*[2][self::BODY]/*[1][self::FIGURE]',
- 'isLCP' => true,
- 'intersectionRatio' => 1,
+ 'xpath' => '/*[1][self::HTML]/*[2][self::BODY]/*[1][self::FIGURE]/*[1][self::DIV]',
+ 'isLCP' => true,
+ 'intersectionRatio' => 1,
+ 'resizedBoundingClientRect' => array_merge( $test_case->get_sample_dom_rect(), array( 'height' => 500 ) ),
),
)
);
@@ -32,11 +33,17 @@
...
+
-