Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ie11 has rewrite test #25342

Merged
merged 2 commits into from
May 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions test/integration/rewrites-has-condition/pages/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import Link from 'next/link'

export default function Page(props) {
return (
<>
<p id="index">index page</p>
<Link href="/rewrite-simple">
<a id="to-simple">to /rewrite-simple</a>
</Link>
<br />

<Link href="/rewrite-with-has?hasQuery=true">
<a id="to-has-rewrite">to /rewrite-with-has?hasQuery=true</a>
</Link>
<br />
</>
)
}
43 changes: 21 additions & 22 deletions test/integration/rewrites-has-condition/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,33 +18,32 @@ let appPort
let app

const runTests = () => {
it('should load page rewrite without browser errors', async () => {
const browser = await webdriver(appPort, '/rewrite-simple')
it('should navigate to a simple rewrite without error', async () => {
const browser = await webdriver(appPort, '/')
await browser.eval('window.beforeNav = 1')

expect(await browser.waitForElementByCss('#another').text()).toBe(
'another page'
)

const browserLogs = await browser.log('browser')
const errorLogs = browserLogs.filter((log) => {
return log.level.name === 'SEVERE' && log.message.includes('Error:')
})
expect(errorLogs).toEqual([])
await browser
.elementByCss('#to-simple')
.click()
.waitForElementByCss('#another')
expect(await browser.elementByCss('#pathname').text()).toBe('/another')
expect(JSON.parse(await browser.elementByCss('#query').text())).toEqual({})
expect(await browser.eval('window.beforeNav')).toBe(1)
})

// Regression test for https://github.com/vercel/next.js/issues/25207
it('should load page rewrite, with "has" condition, without browser errors', async () => {
const browser = await webdriver(appPort, '/rewrite-with-has?hasQuery=123')

expect(await browser.waitForElementByCss('#another').text()).toBe(
'another page'
)
it('should navigate to a has rewrite without error', async () => {
const browser = await webdriver(appPort, '/')
await browser.eval('window.beforeNav = 1')

const browserLogs = await browser.log('browser')
const errorLogs = browserLogs.filter((log) => {
return log.level.name === 'SEVERE' && log.message.includes('Error:')
await browser
.elementByCss('#to-has-rewrite')
.click()
.waitForElementByCss('#another')
expect(await browser.elementByCss('#pathname').text()).toBe('/another')
expect(JSON.parse(await browser.elementByCss('#query').text())).toEqual({
hasQuery: 'true',
})
expect(errorLogs).toEqual([])
expect(await browser.eval('window.beforeNav')).toBe(1)
})
}

Expand Down