Unverified Commit a72e136c authored by JJ Kasper's avatar JJ Kasper Committed by GitHub

Ensure history navigation is correct after query update (#38086)

parent edf4ea39
......@@ -903,6 +903,8 @@ export default class Router implements BaseRouter {
Object.assign<{}, TransitionOptions, TransitionOptions>({}, options, {
shallow: options.shallow && this._shallow,
locale: options.locale || this.defaultLocale,
// @ts-ignore internal value not exposed on types
_h: 0,
}),
forcedScroll
)
......
......@@ -50,6 +50,23 @@ describe('Middleware Rewrite', () => {
}, /Welcome Page A/)
})
it('should rewrite correctly when navigating via history after query update', async () => {
const browser = await webdriver(next.url, '/')
await browser.elementByCss('#override-with-internal-rewrite').click()
await check(() => {
return browser.eval('document.documentElement.innerHTML')
}, /Welcome Page A/)
await browser.refresh()
await browser.waitForCondition(`!!window.next.router.isReady`)
await browser.back()
await browser.waitForElementByCss('#override-with-internal-rewrite')
await browser.forward()
await check(() => {
return browser.eval('document.documentElement.innerHTML')
}, /Welcome Page A/)
})
it('should return HTML/data correctly for pre-rendered page', async () => {
for (const slug of [
'first',
......
......@@ -68,6 +68,26 @@ describe('Production Usage', () => {
await killApp(app)
})
it('should navigate through history after query update', async () => {
const browser = await webdriver(appPort, '/')
await browser.eval('window.next.router.push("/about?a=b")')
await browser.waitForElementByCss('.about-page')
await browser.waitForCondition(`!!window.next.router.isReady`)
await browser.refresh()
await browser.waitForCondition(`!!window.next.router.isReady`)
await browser.back()
await browser.waitForElementByCss('.index-page')
await browser.forward()
await browser.waitForElementByCss('.about-page')
await browser.back()
await browser.waitForElementByCss('.index-page')
await browser.refresh()
await browser.waitForCondition(`!!window.next.router.isReady`)
await browser.forward()
await browser.waitForElementByCss('.about-page')
})
it('should not show target deprecation warning', () => {
expect(output).not.toContain(
'The `target` config is deprecated and will be removed in a future version'
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment