@@ -12,48 +12,50 @@ export function validateMd5(data: Buffer, expectedHash: string) {
1212 ) ;
1313}
1414
15- test ( "index" , async ( { page } ) => {
16- await page . goto ( "/" ) ;
17- await expect ( page . getByText ( "Test misc Next features" ) ) . toBeVisible ( ) ;
18- } ) ;
15+ test . describe ( "playground/base" , ( ) => {
16+ test ( "index" , async ( { page } ) => {
17+ await page . goto ( "/" ) ;
18+ await expect ( page . getByText ( "Test misc Next features" ) ) . toBeVisible ( ) ;
19+ } ) ;
1920
20- test ( "the hello-world api GET route works as intended" , async ( { page } ) => {
21- const res = await page . request . get ( "/api/hello" ) ;
22- expect ( res . headers ( ) [ "content-type" ] ) . toContain ( "text/plain" ) ;
23- expect ( await res . text ( ) ) . toEqual ( "Hello World!" ) ;
24- } ) ;
21+ test ( "the hello-world api GET route works as intended" , async ( { page } ) => {
22+ const res = await page . request . get ( "/api/hello" ) ;
23+ expect ( res . headers ( ) [ "content-type" ] ) . toContain ( "text/plain" ) ;
24+ expect ( await res . text ( ) ) . toEqual ( "Hello World!" ) ;
25+ } ) ;
2526
26- test ( "returns a hello world string from the cloudflare context env" , async ( { page } ) => {
27- const res = await page . request . get ( "/api/hello" , {
28- headers : {
29- "from-cloudflare-context" : "true" ,
30- } ,
27+ test ( "returns a hello world string from the cloudflare context env" , async ( { page } ) => {
28+ const res = await page . request . get ( "/api/hello" , {
29+ headers : {
30+ "from-cloudflare-context" : "true" ,
31+ } ,
32+ } ) ;
33+ expect ( res . headers ( ) [ "content-type" ] ) . toContain ( "text/plain" ) ;
34+ expect ( await res . text ( ) ) . toEqual ( "Hello World from the cloudflare context!" ) ;
3135 } ) ;
32- expect ( res . headers ( ) [ "content-type" ] ) . toContain ( "text/plain" ) ;
33- expect ( await res . text ( ) ) . toEqual ( "Hello World from the cloudflare context!" ) ;
34- } ) ;
3536
36- test ( "the hello-world api POST route works as intended" , async ( { page } ) => {
37- const res = await page . request . post ( "/api/hello" , { data : "some body" } ) ;
38- expect ( res . headers ( ) [ "content-type" ] ) . toContain ( "text/plain" ) ;
39- await expect ( res . text ( ) ) . resolves . toEqual ( "Hello post-World! body=some body" ) ;
40- } ) ;
37+ test ( "the hello-world api POST route works as intended" , async ( { page } ) => {
38+ const res = await page . request . post ( "/api/hello" , { data : "some body" } ) ;
39+ expect ( res . headers ( ) [ "content-type" ] ) . toContain ( "text/plain" ) ;
40+ await expect ( res . text ( ) ) . resolves . toEqual ( "Hello post-World! body=some body" ) ;
41+ } ) ;
4142
42- test ( "sets environment variables from the Next.js env file" , async ( { page } ) => {
43- const res = await page . request . get ( "/api/env" ) ;
44- await expect ( res . json ( ) ) . resolves . toEqual ( expect . objectContaining ( { TEST_ENV_VAR : "TEST_VALUE" } ) ) ;
45- } ) ;
43+ test ( "sets environment variables from the Next.js env file" , async ( { page } ) => {
44+ const res = await page . request . get ( "/api/env" ) ;
45+ await expect ( res . json ( ) ) . resolves . toEqual ( expect . objectContaining ( { TEST_ENV_VAR : "TEST_VALUE" } ) ) ;
46+ } ) ;
4647
47- test ( "returns correct information about the request from a route handler" , async ( { page } ) => {
48- const res = await page . request . get ( "/api/request" ) ;
49- // Next.js can fall back to `localhost:3000` or `n` if it doesn't get the host - neither of these are expected.
50- const expectedURL = expect . stringMatching ( / h t t p s ? : \/ \/ l o c a l h o s t : (? ! 3 0 0 0 ) \d + \/ a p i \/ r e q u e s t / ) ;
51- await expect ( res . json ( ) ) . resolves . toEqual ( { nextUrl : expectedURL , url : expectedURL } ) ;
52- } ) ;
48+ test ( "returns correct information about the request from a route handler" , async ( { page } ) => {
49+ const res = await page . request . get ( "/api/request" ) ;
50+ // Next.js can fall back to `localhost:3000` or `n` if it doesn't get the host - neither of these are expected.
51+ const expectedURL = expect . stringMatching ( / h t t p s ? : \/ \/ l o c a l h o s t : (? ! 3 0 0 0 ) \d + \/ a p i \/ r e q u e s t / ) ;
52+ await expect ( res . json ( ) ) . resolves . toEqual ( { nextUrl : expectedURL , url : expectedURL } ) ;
53+ } ) ;
5354
54- test ( "generates an og image successfully" , async ( { page } ) => {
55- const res = await page . request . get ( "/og" ) ;
56- expect ( res . status ( ) ) . toEqual ( 200 ) ;
57- expect ( res . headers ( ) [ "content-type" ] ) . toEqual ( "image/png" ) ;
58- expect ( validateMd5 ( await res . body ( ) , OG_MD5 ) ) . toEqual ( true ) ;
55+ test ( "generates an og image successfully" , async ( { page } ) => {
56+ const res = await page . request . get ( "/og" ) ;
57+ expect ( res . status ( ) ) . toEqual ( 200 ) ;
58+ expect ( res . headers ( ) [ "content-type" ] ) . toEqual ( "image/png" ) ;
59+ expect ( validateMd5 ( await res . body ( ) , OG_MD5 ) ) . toEqual ( true ) ;
60+ } ) ;
5961} ) ;
0 commit comments