@@ -2002,6 +2002,67 @@ describe('Prerender', () => {
2002
2002
} )
2003
2003
}
2004
2004
2005
+ if ( ! isDev ) {
2006
+ it ( 'should handle manual revalidate for fallback: blocking' , async ( ) => {
2007
+ const beforeRevalidate = Date . now ( )
2008
+ const res = await fetchViaHTTP (
2009
+ next . url ,
2010
+ '/blocking-fallback/test-manual-1'
2011
+ )
2012
+
2013
+ if ( ! isDeploy ) {
2014
+ await waitForCacheWrite (
2015
+ '/blocking-fallback/test-manual-1' ,
2016
+ beforeRevalidate
2017
+ )
2018
+ }
2019
+ const html = await res . text ( )
2020
+ const $ = cheerio . load ( html )
2021
+ const initialTime = $ ( '#time' ) . text ( )
2022
+ const cacheHeader = isDeploy ? 'x-vercel-cache' : 'x-nextjs-cache'
2023
+
2024
+ expect ( res . headers . get ( cacheHeader ) ) . toMatch ( / M I S S / )
2025
+ expect ( $ ( 'p' ) . text ( ) ) . toMatch ( / P o s t : .* ?t e s t - m a n u a l - 1 / )
2026
+
2027
+ if ( ! isDeploy ) {
2028
+ const res2 = await fetchViaHTTP (
2029
+ next . url ,
2030
+ '/blocking-fallback/test-manual-1'
2031
+ )
2032
+ const html2 = await res2 . text ( )
2033
+ const $2 = cheerio . load ( html2 )
2034
+
2035
+ expect ( res2 . headers . get ( cacheHeader ) ) . toMatch ( / ( H I T | S T A L E ) / )
2036
+ expect ( initialTime ) . toBe ( $2 ( '#time' ) . text ( ) )
2037
+ }
2038
+
2039
+ const res3 = await fetchViaHTTP (
2040
+ next . url ,
2041
+ '/api/manual-revalidate' ,
2042
+ {
2043
+ pathname : '/blocking-fallback/test-manual-1' ,
2044
+ } ,
2045
+ { redirect : 'manual' }
2046
+ )
2047
+
2048
+ expect ( res3 . status ) . toBe ( 200 )
2049
+ const revalidateData = await res3 . json ( )
2050
+ expect ( revalidateData . revalidated ) . toBe ( true )
2051
+
2052
+ await check ( async ( ) => {
2053
+ const res4 = await fetchViaHTTP (
2054
+ next . url ,
2055
+ '/blocking-fallback/test-manual-1'
2056
+ )
2057
+ const html4 = await res4 . text ( )
2058
+ const $4 = cheerio . load ( html4 )
2059
+ expect ( $4 ( '#time' ) . text ( ) ) . not . toBe ( initialTime )
2060
+ expect ( res4 . headers . get ( cacheHeader ) ) . toMatch ( / ( H I T | S T A L E ) / )
2061
+ return 'success'
2062
+ } , 'success' )
2063
+ } )
2064
+ }
2065
+
2005
2066
if ( ! isDev && ! isDeploy ) {
2006
2067
it ( 'should automatically reset cache TTL when an error occurs and build cache was available' , async ( ) => {
2007
2068
await next . patchFile ( 'error.txt' , 'yes' )
@@ -2056,56 +2117,6 @@ describe('Prerender', () => {
2056
2117
)
2057
2118
} )
2058
2119
2059
- it ( 'should handle manual revalidate for fallback: blocking' , async ( ) => {
2060
- const beforeRevalidate = Date . now ( )
2061
- const res = await fetchViaHTTP (
2062
- next . url ,
2063
- '/blocking-fallback/test-manual-1'
2064
- )
2065
- await waitForCacheWrite (
2066
- '/blocking-fallback/test-manual-1' ,
2067
- beforeRevalidate
2068
- )
2069
- const html = await res . text ( )
2070
- const $ = cheerio . load ( html )
2071
- const initialTime = $ ( '#time' ) . text ( )
2072
-
2073
- expect ( res . headers . get ( 'x-nextjs-cache' ) ) . toMatch ( / M I S S / )
2074
- expect ( $ ( 'p' ) . text ( ) ) . toMatch ( / P o s t : .* ?t e s t - m a n u a l - 1 / )
2075
-
2076
- const res2 = await fetchViaHTTP (
2077
- next . url ,
2078
- '/blocking-fallback/test-manual-1'
2079
- )
2080
- const html2 = await res2 . text ( )
2081
- const $2 = cheerio . load ( html2 )
2082
-
2083
- expect ( res2 . headers . get ( 'x-nextjs-cache' ) ) . toMatch ( / ( H I T | S T A L E ) / )
2084
- expect ( initialTime ) . toBe ( $2 ( '#time' ) . text ( ) )
2085
-
2086
- const res3 = await fetchViaHTTP (
2087
- next . url ,
2088
- '/api/manual-revalidate' ,
2089
- {
2090
- pathname : '/blocking-fallback/test-manual-1' ,
2091
- } ,
2092
- { redirect : 'manual' }
2093
- )
2094
-
2095
- expect ( res3 . status ) . toBe ( 200 )
2096
- const revalidateData = await res3 . json ( )
2097
- expect ( revalidateData . revalidated ) . toBe ( true )
2098
-
2099
- const res4 = await fetchViaHTTP (
2100
- next . url ,
2101
- '/blocking-fallback/test-manual-1'
2102
- )
2103
- const html4 = await res4 . text ( )
2104
- const $4 = cheerio . load ( html4 )
2105
- expect ( $4 ( '#time' ) . text ( ) ) . not . toBe ( initialTime )
2106
- expect ( res4 . headers . get ( 'x-nextjs-cache' ) ) . toMatch ( / ( H I T | S T A L E ) / )
2107
- } )
2108
-
2109
2120
it ( 'should not manual revalidate for fallback: blocking with onlyGenerated if not generated' , async ( ) => {
2110
2121
const res = await fetchViaHTTP (
2111
2122
next . url ,
0 commit comments