@@ -19,14 +19,38 @@ test.describe("playground/cloudflare", () => {
19
19
await expect ( res . json ( ) ) . resolves . toEqual ( expect . objectContaining ( { PROCESS_ENV_VAR : "process.env" } ) ) ;
20
20
} ) ;
21
21
22
- test ( "fetch an image allowed by remotePatterns" , async ( { page } ) => {
23
- const res = await page . request . get ( "/_next/image?url=https://avatars.githubusercontent.com/u/248818" ) ;
24
- expect ( res . status ( ) ) . toBe ( 200 ) ;
25
- expect ( res . headers ( ) ) . toMatchObject ( { "content-type" : "image/jpeg" } ) ;
22
+ test . describe ( "remotePatterns" , ( ) => {
23
+ test ( "fetch an image allowed by remotePatterns" , async ( { page } ) => {
24
+ const res = await page . request . get ( "/_next/image?url=https://avatars.githubusercontent.com/u/248818" ) ;
25
+ expect ( res . status ( ) ) . toBe ( 200 ) ;
26
+ expect ( res . headers ( ) ) . toMatchObject ( { "content-type" : "image/jpeg" } ) ;
27
+ } ) ;
28
+
29
+ test ( "400 when fetching an image disallowed by remotePatterns" , async ( { page } ) => {
30
+ const res = await page . request . get ( "/_next/image?url=https://avatars.githubusercontent.com/u/248817" ) ;
31
+ expect ( res . status ( ) ) . toBe ( 400 ) ;
32
+ } ) ;
26
33
} ) ;
27
34
28
- test ( "404 when fetching an image disallowed by remotePatterns" , async ( { page } ) => {
29
- const res = await page . request . get ( "/_next/image?url=https://avatars.githubusercontent.com/u/248817" ) ;
30
- expect ( res . status ( ) ) . toBe ( 400 ) ;
35
+ test . describe ( "localPatterns" , ( ) => {
36
+ test ( "fetch an image allowed by localPatterns" , async ( { page } ) => {
37
+ const res = await page . request . get ( "/_next/image?url=/snipp/snipp.webp?iscute=yes" ) ;
38
+ expect ( res . status ( ) ) . toBe ( 200 ) ;
39
+ expect ( res . headers ( ) ) . toMatchObject ( { "content-type" : "image/webp" } ) ;
40
+ } ) ;
41
+
42
+ test ( "400 when fetching an image disallowed by localPatterns with wrong query parameter" , async ( {
43
+ page,
44
+ } ) => {
45
+ const res = await page . request . get ( "/_next/image?url=/snipp/snipp?iscute=no" ) ;
46
+ expect ( res . status ( ) ) . toBe ( 400 ) ;
47
+ } ) ;
48
+
49
+ test ( "400 when fetching an image disallowed by localPatterns without query parameter" , async ( {
50
+ page,
51
+ } ) => {
52
+ const res = await page . request . get ( "/_next/image?url=/snipp/snipp" ) ;
53
+ expect ( res . status ( ) ) . toBe ( 400 ) ;
54
+ } ) ;
31
55
} ) ;
32
56
} ) ;
0 commit comments