@@ -19,7 +19,7 @@ describe('next/images', () => {
19
19
20
20
it ( 'should show image allow-listed with remotePatterns' , ( ) => {
21
21
cy . visit ( '/image' )
22
- cy . findByRole ( 'img' , { name : / t a w n y f r o g m o u t h / i } )
22
+ cy . findByRole ( 'img' , { name : / s h i b a i n u d o g l o o k s t h r o u g h a w i n d o w / i } )
23
23
. should ( 'be.visible' )
24
24
. and ( ( $img ) => {
25
25
// "naturalWidth" and "naturalHeight" are set when the image loads
@@ -28,11 +28,18 @@ describe('next/images', () => {
28
28
} )
29
29
30
30
it ( 'should show throw if an image is not on the domains or remotePatterns allowlist' , ( ) => {
31
- cy . request ( { url : '/broken-image' , failOnStatusCode : false } ) . then ( ( response ) => {
32
- expect ( response . status ) . to . be . eq ( 500 )
33
- expect ( response . body ) . to . include (
34
- `Invalid src prop (https://broken-domain/netlify/next-runtime/main/next-on-netlify.png)` ,
35
- )
31
+ cy . visit ( '/broken-image' )
32
+
33
+ // The image renders broken on the site
34
+ cy . findByRole ( 'img' , { name : / p i c t u r e o f t h e a u t h o r / i } ) . then ( ( $img ) => {
35
+ // eslint-disable-next-line promise/no-nesting
36
+ cy . request ( { url : $img [ 0 ] . src , failOnStatusCode : false } ) . then ( ( response ) => {
37
+ // Navigating to the image itself give a forbidden error with a message explaining why.
38
+ expect ( response . status ) . to . eq ( 403 )
39
+ expect ( response . body ) . to . include (
40
+ 'URL not on allowlist: https://broken-domain/netlify/next-runtime/main/next-on-netlify.png' ,
41
+ )
42
+ } )
36
43
} )
37
44
} )
38
45
} )
0 commit comments