From e0559d92cf51d3db26fc3557d6a90a7748b09f95 Mon Sep 17 00:00:00 2001 From: JJ Kasper Date: Sat, 22 May 2021 12:06:39 -0500 Subject: [PATCH] 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 --- .../rewrites-has-condition/pages/index.js | 18 ++++++++ .../rewrites-has-condition/test/index.test.js | 43 +++++++++---------- 2 files changed, 39 insertions(+), 22 deletions(-) create mode 100644 test/integration/rewrites-has-condition/pages/index.js diff --git a/test/integration/rewrites-has-condition/pages/index.js b/test/integration/rewrites-has-condition/pages/index.js new file mode 100644 index 0000000000000..03d94c49cc653 --- /dev/null +++ b/test/integration/rewrites-has-condition/pages/index.js @@ -0,0 +1,18 @@ +import Link from 'next/link' + +export default function Page(props) { + return ( + <> +

index page

+ + to /rewrite-simple + +
+ + + to /rewrite-with-has?hasQuery=true + +
+ + ) +} diff --git a/test/integration/rewrites-has-condition/test/index.test.js b/test/integration/rewrites-has-condition/test/index.test.js index 8ada5130e3fb8..06464e1e3479b 100644 --- a/test/integration/rewrites-has-condition/test/index.test.js +++ b/test/integration/rewrites-has-condition/test/index.test.js @@ -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) }) }