Skip to content

Commit

Permalink
Add test cases for auto ssr img with high fetchpriority in `OptimizeH…
Browse files Browse the repository at this point in the history
…eroImages::generateImg()`
  • Loading branch information
thelovekesh committed Oct 24, 2023
1 parent 997f03b commit 89707d0
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion tests/Optimizer/Transformer/OptimizeHeroImagesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -342,14 +342,27 @@ public function dataTransform()
),
],

'preserves fetchpriority attribute from noscript fallback img on prerendered image' => [
'preserves fetchpriority attribute from noscript fallback img' => [
$input(
'<amp-img width="500" height="400" src="/img1.png"><noscript><img src="/img1.png" width="500" height="400" fetchpriority="high"></noscript></amp-img>'
),
$output(
'<amp-img data-hero width="500" height="400" src="/img1.png" i-amphtml-ssr><img class="i-amphtml-fill-content i-amphtml-replaced-content" decoding="async" fetchpriority="high" src="/img1.png"></amp-img>'
),
],

'automatically ssr img element with high fetchpriority attribute from noscript fallback img' => [
$input(
'<amp-img width="500" height="400" src="/img1.png"><noscript><img src="/img1.png" width="500" height="400" fetchpriority="high"></noscript></amp-img>'
. '<amp-img width="500" height="400" src="/img2.png"><noscript><img src="/img2.png" width="500" height="400"></noscript></amp-img>'
. '<amp-img width="500" height="400" src="/img3.png"><noscript><img src="/img3.png" width="500" height="400" fetchpriority="high"></noscript></amp-img>'
),
$output(
'<amp-img data-hero width="500" height="400" src="/img1.png" i-amphtml-ssr><img class="i-amphtml-fill-content i-amphtml-replaced-content" decoding="async" fetchpriority="high" src="/img1.png"></amp-img>'
. '<amp-img width="500" height="400" src="/img2.png"><noscript><img src="/img2.png" width="500" height="400"></noscript></amp-img>'
. '<amp-img data-hero width="500" height="400" src="/img3.png" i-amphtml-ssr><img class="i-amphtml-fill-content i-amphtml-replaced-content" decoding="async" fetchpriority="high" src="/img3.png"></amp-img>'
),
],
];
}

Expand Down

0 comments on commit 89707d0

Please sign in to comment.