Skip to content

Commit

Permalink
Add test for title and routeChangeComplete (#14132)
Browse files Browse the repository at this point in the history
This adds a test case for the `document.title` not being updated by the time `routeChangeComplete` is fired. This should have been made consistent with #13287 so should be able to be closed now

Closes: #6025
  • Loading branch information
ijjk authored Jun 12, 2020
1 parent 60d1ed2 commit 0a02efb
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
10 changes: 10 additions & 0 deletions test/integration/production/pages/with-title.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import Head from 'next/head'

export default () => (
<>
<Head>
<title>hello from title</title>
</Head>
<p id="with-title">hi</p>
</>
)
19 changes: 19 additions & 0 deletions test/integration/production/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,25 @@ describe('Production Usage', () => {
expect(text).toBe('Hello World')
await browser.close()
})

it('should set title by routeChangeComplete event', async () => {
const browser = await webdriver(appPort, '/')
await browser.eval(function setup() {
window.next.router.events.on('routeChangeComplete', function handler(
url
) {
window.routeChangeTitle = document.title
window.routeChangeUrl = url
})
window.next.router.push('/with-title')
})
await browser.waitForElementByCss('#with-title')

const title = await browser.eval(`window.routeChangeTitle`)
const url = await browser.eval(`window.routeChangeUrl`)
expect(title).toBe('hello from title')
expect(url).toBe('/with-title')
})
})

it('should navigate to external site and back', async () => {
Expand Down

0 comments on commit 0a02efb

Please sign in to comment.