From b7af59e87c25158674b0f3af9efd59d6804ccfdb Mon Sep 17 00:00:00 2001 From: JJ Kasper Date: Fri, 21 May 2021 15:20:59 -0500 Subject: [PATCH] Fix ie11 has rewrite test --- .../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) }) }