Skip to content

Commit

Permalink
Update query/hash test for safari (#38889)
Browse files Browse the repository at this point in the history
  • Loading branch information
ijjk committed Jul 21, 2022
1 parent 02c78a5 commit 89e572b
Showing 1 changed file with 34 additions and 29 deletions.
63 changes: 34 additions & 29 deletions test/integration/production/test/index.test.js
Expand Up @@ -88,36 +88,41 @@ describe('Production Usage', () => {
await browser.waitForElementByCss('.about-page')
})

it.each([
{ hash: '#hello?' },
{ hash: '#?' },
{ hash: '##' },
{ hash: '##?' },
{ hash: '##hello?' },
{ hash: '##hello' },
{ hash: '#hello?world' },
{ search: '?hello=world', hash: '#a', query: { hello: 'world' } },
{ search: '?hello', hash: '#a', query: { hello: '' } },
{ search: '?hello=', hash: '#a', query: { hello: '' } },
])(
'should handle query/hash correctly during query updating $hash $search',
async ({ hash, search, query }) => {
const browser = await webdriver(appPort, `/${search || ''}${hash || ''}`)
if (process.env.BROWSER_NAME !== 'safari') {
it.each([
{ hash: '#hello?' },
{ hash: '#?' },
{ hash: '##' },
{ hash: '##?' },
{ hash: '##hello?' },
{ hash: '##hello' },
{ hash: '#hello?world' },
{ search: '?hello=world', hash: '#a', query: { hello: 'world' } },
{ search: '?hello', hash: '#a', query: { hello: '' } },
{ search: '?hello=', hash: '#a', query: { hello: '' } },
])(
'should handle query/hash correctly during query updating $hash $search',
async ({ hash, search, query }) => {
const browser = await webdriver(
appPort,
`/${search || ''}${hash || ''}`
)

await check(
() =>
browser.eval('window.next.router.isReady ? "ready" : "not ready"'),
'ready'
)
expect(await browser.eval('window.location.pathname')).toBe('/')
expect(await browser.eval('window.location.hash')).toBe(hash || '')
expect(await browser.eval('window.location.search')).toBe(search || '')
expect(await browser.eval('next.router.pathname')).toBe('/')
expect(
JSON.parse(await browser.eval('JSON.stringify(next.router.query)'))
).toEqual(query || {})
}
)
await check(
() =>
browser.eval('window.next.router.isReady ? "ready" : "not ready"'),
'ready'
)
expect(await browser.eval('window.location.pathname')).toBe('/')
expect(await browser.eval('window.location.hash')).toBe(hash || '')
expect(await browser.eval('window.location.search')).toBe(search || '')
expect(await browser.eval('next.router.pathname')).toBe('/')
expect(
JSON.parse(await browser.eval('JSON.stringify(next.router.query)'))
).toEqual(query || {})
}
)
}

it('should not show target deprecation warning', () => {
expect(output).not.toContain(
Expand Down

0 comments on commit 89e572b

Please sign in to comment.