1
+ /* eslint-disable max-lines-per-function */
1
2
describe ( 'Static Routing' , ( ) => {
2
3
it ( 'renders correct page via SSR on a static route' , ( ) => {
3
- cy . request ( '/getServerSideProps/static/' ) . then ( ( res ) => {
4
+ cy . request ( { url : '/getServerSideProps/static/' , headers : { 'x-nf-debug-logging' : '1' } } ) . then ( ( res ) => {
4
5
expect ( res . status ) . to . eq ( 200 )
5
6
expect ( res . headers ) . to . have . property ( 'x-nf-render-mode' , 'ssr' )
6
7
expect ( res . body ) . to . contain ( 'Sleepy Hollow' )
7
8
} )
8
9
} )
9
10
it ( 'serves correct static file on a static route' , ( ) => {
10
- cy . request ( '/getStaticProps/static/' ) . then ( ( res ) => {
11
+ cy . request ( { url : '/getStaticProps/static/' , headers : { 'x-nf-debug-logging' : '1' } } ) . then ( ( res ) => {
11
12
expect ( res . status ) . to . eq ( 200 )
12
13
expect ( res . headers ) . to . not . have . property ( 'x-nf-render-mode' )
13
14
expect ( res . body ) . to . contain ( 'Dancing with the Stars' )
14
15
} )
15
16
} )
16
17
it ( 'renders correct page via ODB on a static route' , ( ) => {
17
- cy . request ( '/getStaticProps/with-revalidate/' ) . then ( ( res ) => {
18
+ cy . request ( { url : '/getStaticProps/with-revalidate/' , headers : { 'x-nf-debug-logging' : '1' } } ) . then ( ( res ) => {
18
19
expect ( res . status ) . to . eq ( 200 )
19
- expect ( res . headers ) . to . have . property ( 'x-nf-render-mode' , 'odb ttl=60 ' )
20
+ expect ( res . headers ) . to . have . property ( 'x-nf-render-mode' , 'odb ttl=1 ' )
20
21
expect ( res . body ) . to . contain ( 'Dancing with the Stars' )
21
22
} )
22
23
} )
23
24
} )
24
25
25
26
describe ( 'Dynamic Routing' , ( ) => {
26
27
it ( 'renders correct page via SSR on a dynamic route' , ( ) => {
27
- cy . request ( '/getServerSideProps/1/' ) . then ( ( res ) => {
28
+ cy . request ( { url : '/getServerSideProps/1/' , headers : { 'x-nf-debug-logging' : '1' } } ) . then ( ( res ) => {
28
29
expect ( res . status ) . to . eq ( 200 )
29
30
expect ( res . headers ) . to . have . property ( 'x-nf-render-mode' , 'ssr' )
30
31
expect ( res . body ) . to . contain ( 'Under the Dome' )
31
32
} )
32
33
} )
33
34
it ( 'renders correct page via SSR on a dynamic catch-all route' , ( ) => {
34
- cy . request ( '/getServerSideProps/all/1/' ) . then ( ( res ) => {
35
+ cy . request ( { url : '/getServerSideProps/all/1/' , headers : { 'x-nf-debug-logging' : '1' } } ) . then ( ( res ) => {
35
36
expect ( res . status ) . to . eq ( 200 )
36
37
expect ( res . headers ) . to . have . property ( 'x-nf-render-mode' , 'ssr' )
37
38
expect ( res . body ) . to . contain ( 'Under the Dome' )
38
39
} )
39
40
} )
40
41
it ( 'serves correct static file on a prerendered dynamic route with fallback: false' , ( ) => {
41
- cy . request ( '/getStaticProps/1/' ) . then ( ( res ) => {
42
+ cy . request ( { url : '/getStaticProps/1/' , headers : { 'x-nf-debug-logging' : '1' } } ) . then ( ( res ) => {
42
43
expect ( res . status ) . to . eq ( 200 )
43
44
expect ( res . headers ) . to . not . have . property ( 'x-nf-render-mode' )
44
45
expect ( res . body ) . to . contain ( 'Under the Dome' )
45
46
} )
46
47
} )
47
48
it ( 'renders custom 404 on a non-prerendered dynamic route with fallback: false' , ( ) => {
48
- cy . request ( { url : '/getStaticProps/3/' , failOnStatusCode : false } ) . then ( ( res ) => {
49
- expect ( res . status ) . to . eq ( 404 )
50
- expect ( res . headers ) . to . have . property ( 'x-nf-render-mode' , 'odb' )
51
- expect ( res . body ) . to . contain ( 'Custom 404' )
52
- } )
49
+ cy . request ( { url : '/getStaticProps/3/' , headers : { 'x-nf-debug-logging' : '1' } , failOnStatusCode : false } ) . then (
50
+ ( res ) => {
51
+ expect ( res . status ) . to . eq ( 404 )
52
+ expect ( res . headers ) . to . have . property ( 'x-nf-render-mode' , 'odb' )
53
+ expect ( res . body ) . to . contain ( 'Custom 404' )
54
+ } ,
55
+ )
53
56
} )
54
57
it ( 'serves correct static file on a prerendered dynamic route with fallback: true' , ( ) => {
55
- cy . request ( '/getStaticProps/withFallback/1/' ) . then ( ( res ) => {
58
+ cy . request ( { url : '/getStaticProps/withFallback/1/' , headers : { 'x-nf-debug-logging' : '1' } } ) . then ( ( res ) => {
56
59
expect ( res . status ) . to . eq ( 200 )
57
60
expect ( res . headers ) . to . not . have . property ( 'x-nf-render-mode' )
58
61
expect ( res . body ) . to . contain ( 'Under the Dome' )
59
62
} )
60
63
} )
61
64
it ( 'renders fallback page via ODB on a non-prerendered dynamic route with fallback: true' , ( ) => {
62
- cy . request ( '/getStaticProps/withFallback/3/' ) . then ( ( res ) => {
65
+ cy . request ( { url : '/getStaticProps/withFallback/3/' , headers : { 'x-nf-debug-logging' : '1' } } ) . then ( ( res ) => {
63
66
expect ( res . status ) . to . eq ( 200 )
64
67
// expect 'odb' until https://github.com/netlify/pillar-runtime/issues/438 is fixed
65
68
expect ( res . headers ) . to . have . property ( 'x-nf-render-mode' , 'odb' )
@@ -68,60 +71,79 @@ describe('Dynamic Routing', () => {
68
71
} )
69
72
} )
70
73
it ( 'serves correct static file on a prerendered dynamic route with fallback: blocking' , ( ) => {
71
- cy . request ( '/getStaticProps/withFallbackBlocking/1/' ) . then ( ( res ) => {
72
- expect ( res . status ) . to . eq ( 200 )
73
- expect ( res . headers ) . to . not . have . property ( 'x-nf-render-mode' )
74
- expect ( res . body ) . to . contain ( 'Under the Dome' )
75
- } )
74
+ cy . request ( { url : '/getStaticProps/withFallbackBlocking/1/' , headers : { 'x-nf-debug-logging' : '1' } } ) . then (
75
+ ( res ) => {
76
+ expect ( res . status ) . to . eq ( 200 )
77
+ expect ( res . headers ) . to . not . have . property ( 'x-nf-render-mode' )
78
+ expect ( res . body ) . to . contain ( 'Under the Dome' )
79
+ } ,
80
+ )
76
81
} )
77
82
it ( 'renders correct page via ODB on a non-prerendered dynamic route with fallback: blocking' , ( ) => {
78
- cy . request ( '/getStaticProps/withFallbackBlocking/3/' ) . then ( ( res ) => {
79
- expect ( res . status ) . to . eq ( 200 )
80
- expect ( res . headers ) . to . have . property ( 'x-nf-render-mode' , 'odb' )
81
- expect ( res . body ) . to . contain ( 'Bitten' )
82
- } )
83
+ cy . request ( { url : '/getStaticProps/withFallbackBlocking/3/' , headers : { 'x-nf-debug-logging' : '1' } } ) . then (
84
+ ( res ) => {
85
+ expect ( res . status ) . to . eq ( 200 )
86
+ expect ( res . headers ) . to . have . property ( 'x-nf-render-mode' , 'odb' )
87
+ expect ( res . body ) . to . contain ( 'Bitten' )
88
+ } ,
89
+ )
83
90
} )
84
91
it ( 'renders correct page via ODB on a prerendered dynamic route with revalidate and fallback: false' , ( ) => {
85
- cy . request ( '/getStaticProps/withRevalidate/1/' ) . then ( ( res ) => {
92
+ cy . request ( { url : '/getStaticProps/withRevalidate/1/' , headers : { 'x-nf-debug-logging' : '1' } } ) . then ( ( res ) => {
86
93
expect ( res . status ) . to . eq ( 200 )
87
94
expect ( res . headers ) . to . have . property ( 'x-nf-render-mode' , 'odb ttl=60' )
88
95
expect ( res . body ) . to . contain ( 'Under the Dome' )
89
96
} )
90
97
} )
91
98
it ( 'renders custom 404 on a non-prerendered dynamic route with revalidate and fallback: false' , ( ) => {
92
- cy . request ( { url : '/getStaticProps/withRevalidate/3/' , failOnStatusCode : false } ) . then ( ( res ) => {
99
+ cy . request ( {
100
+ url : '/getStaticProps/withRevalidate/3/' ,
101
+ headers : { 'x-nf-debug-logging' : '1' } ,
102
+ failOnStatusCode : false ,
103
+ } ) . then ( ( res ) => {
93
104
expect ( res . status ) . to . eq ( 404 )
94
105
expect ( res . headers ) . to . have . property ( 'x-nf-render-mode' , 'odb' )
95
106
expect ( res . body ) . to . contain ( 'Custom 404' )
96
107
} )
97
108
} )
98
109
it ( 'renders correct page via ODB on a prerendered dynamic route with revalidate and fallback: true' , ( ) => {
99
- cy . request ( '/getStaticProps/withRevalidate/withFallback/1/' ) . then ( ( res ) => {
100
- expect ( res . status ) . to . eq ( 200 )
101
- expect ( res . headers ) . to . have . property ( 'x-nf-render-mode' , 'odb ttl=60' )
102
- expect ( res . body ) . to . contain ( 'Under the Dome' )
103
- } )
110
+ cy . request ( { url : '/getStaticProps/withRevalidate/withFallback/1/' , headers : { 'x-nf-debug-logging' : '1' } } ) . then (
111
+ ( res ) => {
112
+ expect ( res . status ) . to . eq ( 200 )
113
+ expect ( res . headers ) . to . have . property ( 'x-nf-render-mode' , 'odb ttl=60' )
114
+ expect ( res . body ) . to . contain ( 'Under the Dome' )
115
+ } ,
116
+ )
104
117
} )
105
118
it ( 'renders fallback page via ODB on a non-prerendered dynamic route with revalidate and fallback: true' , ( ) => {
106
- cy . request ( '/getStaticProps/withRevalidate/withFallback/3/' ) . then ( ( res ) => {
107
- expect ( res . status ) . to . eq ( 200 )
108
- expect ( res . headers ) . to . have . property ( 'x-nf-render-mode' , 'odb ttl=60' )
109
- // expect 'Bitten' until https://github.com/netlify/pillar-runtime/issues/438 is fixed
110
- expect ( res . body ) . to . contain ( 'Bitten' )
111
- } )
119
+ cy . request ( { url : '/getStaticProps/withRevalidate/withFallback/3/' , headers : { 'x-nf-debug-logging' : '1' } } ) . then (
120
+ ( res ) => {
121
+ expect ( res . status ) . to . eq ( 200 )
122
+ expect ( res . headers ) . to . have . property ( 'x-nf-render-mode' , 'odb ttl=60' )
123
+ // expect 'Bitten' until https://github.com/netlify/pillar-runtime/issues/438 is fixed
124
+ expect ( res . body ) . to . contain ( 'Bitten' )
125
+ } ,
126
+ )
112
127
} )
113
128
it ( 'renders correct page via ODB on a prerendered dynamic route with revalidate and fallback: blocking' , ( ) => {
114
- cy . request ( '/getStaticProps/withRevalidate/withFallbackBlocking/1/' ) . then ( ( res ) => {
129
+ cy . request ( {
130
+ url : '/getStaticProps/withRevalidate/withFallbackBlocking/1/' ,
131
+ headers : { 'x-nf-debug-logging' : '1' } ,
132
+ } ) . then ( ( res ) => {
115
133
expect ( res . status ) . to . eq ( 200 )
116
134
expect ( res . headers ) . to . have . property ( 'x-nf-render-mode' , 'odb ttl=60' )
117
135
expect ( res . body ) . to . contain ( 'Under the Dome' )
118
136
} )
119
137
} )
120
138
it ( 'renders correct page via ODB on a non-prerendered dynamic route with revalidate and fallback: blocking' , ( ) => {
121
- cy . request ( '/getStaticProps/withRevalidate/withFallbackBlocking/3/' ) . then ( ( res ) => {
139
+ cy . request ( {
140
+ url : '/getStaticProps/withRevalidate/withFallbackBlocking/3/' ,
141
+ headers : { 'x-nf-debug-logging' : '1' } ,
142
+ } ) . then ( ( res ) => {
122
143
expect ( res . status ) . to . eq ( 200 )
123
144
expect ( res . headers ) . to . have . property ( 'x-nf-render-mode' , 'odb ttl=60' )
124
145
expect ( res . body ) . to . contain ( 'Bitten' )
125
146
} )
126
147
} )
127
148
} )
149
+ /* eslint-enable max-lines-per-function */
0 commit comments