Skip to content

Commit 0aef272

Browse files
authored
Fix ie11 has rewrite test (#25342)
This updates the `rewrites-has-condition` tests to not rely on the `browser.log` method since it's not available with ie11 ## Bug - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added ## Feature - [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR. - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Documentation added - [ ] Telemetry added. In case of a feature if it's used or not. ## Documentation / Examples - [ ] Make sure the linting passes
1 parent 48cbb81 commit 0aef272

File tree

2 files changed

+39
-22
lines changed

2 files changed

+39
-22
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import Link from 'next/link'
2+
3+
export default function Page(props) {
4+
return (
5+
<>
6+
<p id="index">index page</p>
7+
<Link href="/rewrite-simple">
8+
<a id="to-simple">to /rewrite-simple</a>
9+
</Link>
10+
<br />
11+
12+
<Link href="/rewrite-with-has?hasQuery=true">
13+
<a id="to-has-rewrite">to /rewrite-with-has?hasQuery=true</a>
14+
</Link>
15+
<br />
16+
</>
17+
)
18+
}

test/integration/rewrites-has-condition/test/index.test.js

+21-22
Original file line numberDiff line numberDiff line change
@@ -18,33 +18,32 @@ let appPort
1818
let app
1919

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

24-
expect(await browser.waitForElementByCss('#another').text()).toBe(
25-
'another page'
26-
)
27-
28-
const browserLogs = await browser.log('browser')
29-
const errorLogs = browserLogs.filter((log) => {
30-
return log.level.name === 'SEVERE' && log.message.includes('Error:')
31-
})
32-
expect(errorLogs).toEqual([])
25+
await browser
26+
.elementByCss('#to-simple')
27+
.click()
28+
.waitForElementByCss('#another')
29+
expect(await browser.elementByCss('#pathname').text()).toBe('/another')
30+
expect(JSON.parse(await browser.elementByCss('#query').text())).toEqual({})
31+
expect(await browser.eval('window.beforeNav')).toBe(1)
3332
})
3433

35-
// Regression test for https://github.com/vercel/next.js/issues/25207
36-
it('should load page rewrite, with "has" condition, without browser errors', async () => {
37-
const browser = await webdriver(appPort, '/rewrite-with-has?hasQuery=123')
38-
39-
expect(await browser.waitForElementByCss('#another').text()).toBe(
40-
'another page'
41-
)
34+
it('should navigate to a has rewrite without error', async () => {
35+
const browser = await webdriver(appPort, '/')
36+
await browser.eval('window.beforeNav = 1')
4237

43-
const browserLogs = await browser.log('browser')
44-
const errorLogs = browserLogs.filter((log) => {
45-
return log.level.name === 'SEVERE' && log.message.includes('Error:')
38+
await browser
39+
.elementByCss('#to-has-rewrite')
40+
.click()
41+
.waitForElementByCss('#another')
42+
expect(await browser.elementByCss('#pathname').text()).toBe('/another')
43+
expect(JSON.parse(await browser.elementByCss('#query').text())).toEqual({
44+
hasQuery: 'true',
4645
})
47-
expect(errorLogs).toEqual([])
46+
expect(await browser.eval('window.beforeNav')).toBe(1)
4847
})
4948
}
5049

0 commit comments

Comments
 (0)