@@ -163,7 +163,44 @@ describe('GS(S)P Server-Side Change Reloading', () => {
163
163
originalContent . replace ( 'count = 1' , 'count = 2' )
164
164
)
165
165
166
+ await check (
167
+ async ( ) =>
168
+ JSON . parse ( await browser . elementByCss ( '#props' ) . text ( ) ) . count + '' ,
169
+ '2'
170
+ )
171
+ expect ( await browser . eval ( 'window.beforeChange' ) ) . toBe ( 'hi' )
172
+ await next . patchFile ( page , originalContent )
173
+ } )
174
+
175
+ it ( 'should keep scroll position when updating from change in getStaticProps' , async ( ) => {
176
+ const browser = await webdriver ( next . url , '/another' )
177
+ await browser . eval (
178
+ 'document.getElementById("scroll-target").scrollIntoView()'
179
+ )
180
+ const scrollPosition = await browser . eval (
181
+ 'document.documentElement.scrollTop'
182
+ )
183
+ await browser . eval ( `window.beforeChange = 'hi'` )
184
+
185
+ const props = JSON . parse ( await browser . elementByCss ( '#props' ) . text ( ) )
186
+ expect ( props . count ) . toBe ( 1 )
187
+
188
+ const page = 'pages/another/index.js'
189
+ const originalContent = await next . readFile ( page )
190
+ await next . patchFile (
191
+ page ,
192
+ originalContent . replace ( 'count = 1' , 'count = 2' )
193
+ )
194
+
195
+ await check (
196
+ async ( ) =>
197
+ JSON . parse ( await browser . elementByCss ( '#props' ) . text ( ) ) . count + '' ,
198
+ '2'
199
+ )
166
200
expect ( await browser . eval ( 'window.beforeChange' ) ) . toBe ( 'hi' )
201
+ expect ( await browser . eval ( 'document.documentElement.scrollTop' ) ) . toBe (
202
+ scrollPosition
203
+ )
167
204
await next . patchFile ( page , originalContent )
168
205
} )
169
206
0 commit comments