1+ describe ( 'Static Routing' , ( ) => {
2+ it ( 'renders correct page via SSR on a static route' , ( ) => {
3+ cy . request ( '/getServerSideProps/static/' ) . then ( ( res ) => {
4+ expect ( res . status ) . to . eq ( 200 )
5+ expect ( res . headers ) . to . have . property ( 'x-render-mode' , 'ssr' )
6+ expect ( res . body ) . to . contain ( 'Sleepy Hollow' )
7+ } )
8+ } )
9+ it ( 'serves correct static file on a static route' , ( ) => {
10+ cy . request ( '/getStaticProps/static/' ) . then ( ( res ) => {
11+ expect ( res . status ) . to . eq ( 200 )
12+ expect ( res . headers ) . to . not . have . property ( 'x-render-mode' )
13+ expect ( res . body ) . to . contain ( 'Dancing with the Stars' )
14+ } )
15+ } )
16+ it ( 'renders correct page via ODB on a static route' , ( ) => {
17+ cy . request ( '/getStaticProps/with-revalidate/' ) . then ( ( res ) => {
18+ expect ( res . status ) . to . eq ( 200 )
19+ expect ( res . headers ) . to . have . property ( 'x-render-mode' , 'isr' )
20+ expect ( res . body ) . to . contain ( 'Dancing with the Stars' )
21+ } )
22+ } )
23+ } )
24+
125describe ( 'Dynamic Routing' , ( ) => {
2- it ( 'loads page' , ( ) => {
3- cy . visit ( '/shows/250' )
4- cy . findByRole ( 'heading' ) . should ( 'contain' , '250' )
5- cy . findByText ( 'Kirby Buckets' )
26+ it ( 'renders correct page via SSR on a dynamic route' , ( ) => {
27+ cy . request ( '/getServerSideProps/1/' ) . then ( ( res ) => {
28+ expect ( res . status ) . to . eq ( 200 )
29+ expect ( res . headers ) . to . have . property ( 'x-render-mode' , 'ssr' )
30+ expect ( res . body ) . to . contain ( 'Under the Dome' )
31+ } )
32+ } )
33+ it ( 'renders correct page via SSR on a dynamic catch-all route' , ( ) => {
34+ cy . request ( '/getServerSideProps/all/1/' ) . then ( ( res ) => {
35+ expect ( res . status ) . to . eq ( 200 )
36+ expect ( res . headers ) . to . have . property ( 'x-render-mode' , 'ssr' )
37+ expect ( res . body ) . to . contain ( 'Under the Dome' )
38+ } )
39+ } )
40+ it ( 'serves correct static file on a prerendered dynamic route with fallback: false' , ( ) => {
41+ cy . request ( '/getStaticProps/1/' ) . then ( ( res ) => {
42+ expect ( res . status ) . to . eq ( 200 )
43+ expect ( res . headers ) . to . not . have . property ( 'x-render-mode' )
44+ expect ( res . body ) . to . contain ( 'Under the Dome' )
45+ } )
46+ } )
47+ 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-render-mode' , 'odb' )
51+ expect ( res . body ) . to . contain ( 'Custom 404' )
52+ } )
53+ } )
54+ it ( 'serves correct static file on a prerendered dynamic route with fallback: true' , ( ) => {
55+ cy . request ( '/getStaticProps/withFallback/1/' ) . then ( ( res ) => {
56+ expect ( res . status ) . to . eq ( 200 )
57+ expect ( res . headers ) . to . not . have . property ( 'x-render-mode' )
58+ expect ( res . body ) . to . contain ( 'Under the Dome' )
59+ } )
60+ } )
61+ it ( 'renders fallback page via ODB on a non-prerendered dynamic route with fallback: true' , ( ) => {
62+ cy . request ( '/getStaticProps/withFallback/3/' ) . then ( ( res ) => {
63+ expect ( res . status ) . to . eq ( 200 )
64+ // expect 'odb' until https://github.com/netlify/pillar-runtime/issues/438 is fixed
65+ expect ( res . headers ) . to . have . property ( 'x-render-mode' , 'odb' )
66+ // expect 'Bitten' until the above is fixed and we can test for fallback 'Loading...' message
67+ expect ( res . body ) . to . contain ( 'Bitten' )
68+ } )
69+ } )
70+ 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-render-mode' )
74+ expect ( res . body ) . to . contain ( 'Under the Dome' )
75+ } )
76+ } )
77+ 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-render-mode' , 'odb' )
81+ expect ( res . body ) . to . contain ( 'Bitten' )
82+ } )
83+ } )
84+ it ( 'renders correct page via ODB on a prerendered dynamic route with revalidate and fallback: false' , ( ) => {
85+ cy . request ( '/getStaticProps/withRevalidate/1/' ) . then ( ( res ) => {
86+ expect ( res . status ) . to . eq ( 200 )
87+ expect ( res . headers ) . to . have . property ( 'x-render-mode' , 'isr' )
88+ expect ( res . body ) . to . contain ( 'Under the Dome' )
89+ } )
90+ } )
91+ 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 ) => {
93+ expect ( res . status ) . to . eq ( 404 )
94+ expect ( res . headers ) . to . have . property ( 'x-render-mode' , 'odb' )
95+ expect ( res . body ) . to . contain ( 'Custom 404' )
96+ } )
97+ } )
98+ 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-render-mode' , 'isr' )
102+ expect ( res . body ) . to . contain ( 'Under the Dome' )
103+ } )
104+ } )
105+ 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-render-mode' , 'isr' )
109+ // expect 'Bitten' until https://github.com/netlify/pillar-runtime/issues/438 is fixed
110+ expect ( res . body ) . to . contain ( 'Bitten' )
111+ } )
112+ } )
113+ 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 ) => {
115+ expect ( res . status ) . to . eq ( 200 )
116+ expect ( res . headers ) . to . have . property ( 'x-render-mode' , 'isr' )
117+ expect ( res . body ) . to . contain ( 'Under the Dome' )
118+ } )
119+ } )
120+ 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 ) => {
122+ expect ( res . status ) . to . eq ( 200 )
123+ expect ( res . headers ) . to . have . property ( 'x-render-mode' , 'isr' )
124+ expect ( res . body ) . to . contain ( 'Bitten' )
125+ } )
6126 } )
7- } )
127+ } )
0 commit comments