Skip to content

Commit

Permalink
Fix test-cases for image-prioritizer
Browse files Browse the repository at this point in the history
  • Loading branch information
ShyamGadde committed Nov 27, 2024
1 parent 5287f79 commit 86023eb
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
'xpath' => '/*[1][self::HTML]/*[2][self::BODY]/*[1][self::DIV]',
'isLCP' => true,
),
)
),
'image-prioritizer/img,image-prioritizer/background-image,image-prioritizer/video'
);
},
'buffer' => '
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
$slug,
$test_case->get_sample_url_metric(
array(
'eTag' => 'image-prioritizer/img,image-prioritizer/background-image,image-prioritizer/video',
'viewport_width' => $viewport_width,
'elements' => array(
array(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
'xpath' => '/*[1][self::HTML]/*[2][self::BODY]/*[1][self::IMG]', // Note: This is intentionally not reflecting the IMG in the HTML below.
'isLCP' => true,
),
)
),
'image-prioritizer/img,image-prioritizer/background-image,image-prioritizer/video'
);
},
'buffer' => '
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
'isLCP' => true,
'xpath' => '/*[1][self::HTML]/*[2][self::BODY]/*[1][self::IMG]',
),
)
),
'image-prioritizer/img,image-prioritizer/background-image,image-prioritizer/video'
);
},
'buffer' => '
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
$slug,
$test_case->get_sample_url_metric(
array(
'eTag' => 'image-prioritizer/img,image-prioritizer/background-image,image-prioritizer/video',
'viewport_width' => $viewport_width,
'elements' => array(
array(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
'xpath' => '/*[1][self::HTML]/*[2][self::BODY]/*[1][self::H1]',
'isLCP' => true,
),
)
),
'image-prioritizer/img,image-prioritizer/background-image,image-prioritizer/video'
);
},
'buffer' => '
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +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',
'viewport_width' => $viewport_width,
'element' => array(
'xpath' => sprintf( '/*[1][self::HTML]/*[2][self::BODY]/*[%d][self::DIV]', $div_index + 1 ),
Expand Down
2 changes: 1 addition & 1 deletion plugins/image-prioritizer/tests/test-helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,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 ) );
$this->populate_url_metrics( array( $element_metrics ), 'image-prioritizer/img,image-prioritizer/background-image,image-prioritizer/video' );

$html_start_doc = '<html lang="en"><head><meta charset="utf-8"><title>...</title></head><body>';
$html_end_doc = '</body></html>';
Expand Down

0 comments on commit 86023eb

Please sign in to comment.