@@ -123,6 +123,10 @@ const runTests = () => {
123
123
window.next.router.push('/gssp-blog/redirect-dest-_another')
124
124
})()` )
125
125
await browser . waitForElementByCss ( '#another' )
126
+
127
+ const text = await browser . elementByCss ( '#another' ) . text ( )
128
+
129
+ expect ( text ) . toEqual ( 'another Page' )
126
130
} )
127
131
128
132
it ( 'should apply redirect when GSSP page is navigated to client-side (external)' , async ( ) => {
@@ -149,6 +153,10 @@ const runTests = () => {
149
153
window.next.router.push('/gsp-blog/redirect-dest-_another')
150
154
})()` )
151
155
await browser . waitForElementByCss ( '#another' )
156
+
157
+ const text = await browser . elementByCss ( '#another' ) . text ( )
158
+
159
+ expect ( text ) . toEqual ( 'another Page' )
152
160
} )
153
161
154
162
it ( 'should apply redirect when GSP page is navigated to client-side (external)' , async ( ) => {
@@ -167,6 +175,94 @@ const runTests = () => {
167
175
} ,
168
176
} )
169
177
} )
178
+
179
+ it ( 'should not replace history of the origin page when GSSP page is navigated to client-side (internal normal)' , async ( ) => {
180
+ const browser = await webdriver ( appPort , '/another?mark_as=root' )
181
+
182
+ await browser . eval ( `(function () {
183
+ window.location.href = '/'
184
+ })()` )
185
+ await browser . waitForElementByCss ( '#index' )
186
+
187
+ await browser . eval ( `(function () {
188
+ window.next.router.push('/gssp-blog/redirect-dest-_another')
189
+ })()` )
190
+ await browser . waitForElementByCss ( '#another' )
191
+
192
+ await browser . eval ( `(function () {
193
+ window.history.back()
194
+ })()` )
195
+
196
+ const curUrl = await browser . url ( )
197
+ const { path } = url . parse ( curUrl )
198
+ expect ( path ) . toEqual ( '/' )
199
+ } )
200
+
201
+ it ( 'should not replace history of the origin page when GSSP page is navigated to client-side (external)' , async ( ) => {
202
+ const browser = await webdriver ( appPort , '/another?mark_as=root' )
203
+
204
+ await browser . eval ( `(function () {
205
+ window.location.href = '/'
206
+ })()` )
207
+ await browser . waitForElementByCss ( '#index' )
208
+
209
+ await browser . eval ( `(function () {
210
+ window.next.router.push('/gssp-blog/redirect-dest-_gssp-blog_first')
211
+ })()` )
212
+ await browser . waitForElementByCss ( '#gssp' )
213
+
214
+ await browser . eval ( `(function () {
215
+ window.history.back()
216
+ })()` )
217
+
218
+ const curUrl = await browser . url ( )
219
+ const { path } = url . parse ( curUrl )
220
+ expect ( path ) . toEqual ( '/' )
221
+ } )
222
+
223
+ it ( 'should not replace history of the origin page when GSP page is navigated to client-side (internal)' , async ( ) => {
224
+ const browser = await webdriver ( appPort , '/another?mark_as=root' )
225
+
226
+ await browser . eval ( `(function () {
227
+ window.location.href = '/'
228
+ })()` )
229
+ await browser . waitForElementByCss ( '#index' )
230
+
231
+ await browser . eval ( `(function () {
232
+ window.next.router.push('/gsp-blog/redirect-dest-_another')
233
+ })()` )
234
+ await browser . waitForElementByCss ( '#another' )
235
+
236
+ await browser . eval ( `(function () {
237
+ window.history.back()
238
+ })()` )
239
+
240
+ const curUrl = await browser . url ( )
241
+ const { path } = url . parse ( curUrl )
242
+ expect ( path ) . toEqual ( '/' )
243
+ } )
244
+
245
+ it ( 'should not replace history of the origin page when GSP page is navigated to client-side (external)' , async ( ) => {
246
+ const browser = await webdriver ( appPort , '/another?mark_as=root' )
247
+
248
+ await browser . eval ( `(function () {
249
+ window.location.href = '/'
250
+ })()` )
251
+ await browser . waitForElementByCss ( '#index' )
252
+
253
+ await browser . eval ( `(function () {
254
+ window.next.router.push('/gsp-blog/redirect-dest-_gsp-blog_first')
255
+ })()` )
256
+ await browser . waitForElementByCss ( '#gsp' )
257
+
258
+ await browser . eval ( `(function () {
259
+ window.history.back()
260
+ })()` )
261
+
262
+ const curUrl = await browser . url ( )
263
+ const { path } = url . parse ( curUrl )
264
+ expect ( path ) . toEqual ( '/' )
265
+ } )
170
266
}
171
267
172
268
describe ( 'GS(S)P Redirect Support' , ( ) => {
0 commit comments