11import { expect , test } from "@playwright/test" ;
2- import { validateMd5 } from "../../utils" ;
3-
4- /*
5- * `curl -s https://opennext.js.org/share.png | md5sum`
6- * This is the MD5 hash of the image. It is used to validate the image content.
7- */
8- const OPENNEXT_PNG_MD5 = "405f45cc3397b09717a13ebd6f1e027b" ;
92
103test ( "Middleware Redirect" , async ( { page, context } ) => {
114 await page . goto ( "/" ) ;
@@ -25,23 +18,3 @@ test("Middleware Redirect", async ({ page, context }) => {
2518 el = page . getByText ( "Redirect Destination" , { exact : true } ) ;
2619 await expect ( el ) . toBeVisible ( ) ;
2720} ) ;
28-
29- test ( "Middleware Rewrite External Image" , async ( { page } ) => {
30- await page . goto ( "/rewrite-external" ) ;
31- page . on ( "response" , async ( response ) => {
32- expect ( response . status ( ) ) . toBe ( 200 ) ;
33- expect ( response . headers ( ) [ "content-type" ] ) . toBe ( "image/png" ) ;
34- expect ( response . headers ( ) [ "cache-control" ] ) . toBe ( "max-age=600" ) ;
35- const bodyBuffer = await response . body ( ) ;
36- expect ( validateMd5 ( bodyBuffer , OPENNEXT_PNG_MD5 ) ) . toBe ( true ) ;
37- } ) ;
38- } ) ;
39-
40- test ( "Middleware Rewrite Status Code" , async ( { page } ) => {
41- await page . goto ( "/rewrite-status-code" ) ;
42- const el = page . getByText ( "Rewritten Destination" , { exact : true } ) ;
43- await expect ( el ) . toBeVisible ( ) ;
44- page . on ( "response" , async ( response ) => {
45- expect ( response . status ( ) ) . toBe ( 403 ) ;
46- } ) ;
47- } ) ;
0 commit comments