diff --git a/plugins/embed-optimizer/tests/test-cases/all-embeds-inside-viewport.php b/plugins/embed-optimizer/tests/test-cases/all-embeds-inside-viewport.php
new file mode 100644
index 000000000..a78cb962a
--- /dev/null
+++ b/plugins/embed-optimizer/tests/test-cases/all-embeds-inside-viewport.php
@@ -0,0 +1,262 @@
+ static function ( Test_Embed_Optimizer_Optimization_Detective $test_case ): void {
+
+ $element_data = array(
+ 'isLCP' => false,
+ 'intersectionRatio' => 1,
+ 'resizedBoundingClientRect' => array_merge( $test_case->get_sample_dom_rect(), array( 'height' => 500 ) ),
+ );
+
+ $elements = array();
+ for ( $i = 1; $i < 10; $i++ ) {
+ $elements[] = array_merge(
+ $element_data,
+ array(
+ 'xpath' => "/*[1][self::HTML]/*[2][self::BODY]/*[{$i}][self::FIGURE]/*[1][self::DIV]",
+ )
+ );
+ }
+
+ $test_case->populate_url_metrics( $elements );
+ },
+ 'buffer' => <<
+
+
+ ...
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+HTML
+ ,
+ 'expected' => <<
+
+
+ ...
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+HTML
+ ,
+);
diff --git a/plugins/embed-optimizer/tests/test-optimization-detective.php b/plugins/embed-optimizer/tests/test-optimization-detective.php
index 9994859e1..489c03f8e 100644
--- a/plugins/embed-optimizer/tests/test-optimization-detective.php
+++ b/plugins/embed-optimizer/tests/test-optimization-detective.php
@@ -118,8 +118,8 @@ static function ( $matches ) {
$buffer
);
$this->assertEquals(
- $this->remove_initial_tabs( $expected ),
- $this->remove_initial_tabs( $buffer ),
+ trim( $this->remove_initial_tabs( $expected ) ),
+ trim( $this->remove_initial_tabs( $buffer ) ),
"Buffer snapshot:\n$buffer"
);
}