From b99e021375cbbffd7ae242d37f9255c64bf885a8 Mon Sep 17 00:00:00 2001 From: Joe Haddad Date: Tue, 14 Jan 2020 22:22:08 -0500 Subject: [PATCH 1/6] Test Query String Behavior --- .../query-trailing-space/pages/another.js | 15 ++++ .../query-trailing-space/pages/index.js | 7 ++ .../query-trailing-space/test/index.test.js | 85 +++++++++++++++++++ 3 files changed, 107 insertions(+) create mode 100644 test/integration/query-trailing-space/pages/another.js create mode 100644 test/integration/query-trailing-space/pages/index.js create mode 100644 test/integration/query-trailing-space/test/index.test.js diff --git a/test/integration/query-trailing-space/pages/another.js b/test/integration/query-trailing-space/pages/another.js new file mode 100644 index 000000000000000..5c988ec39709997 --- /dev/null +++ b/test/integration/query-trailing-space/pages/another.js @@ -0,0 +1,15 @@ +import Link from 'next/link' + +const Another = () => ( +
+ + Hello Space + +
+ + Hello Complex + +
+) + +export default Another diff --git a/test/integration/query-trailing-space/pages/index.js b/test/integration/query-trailing-space/pages/index.js new file mode 100644 index 000000000000000..5abbac3c14b81af --- /dev/null +++ b/test/integration/query-trailing-space/pages/index.js @@ -0,0 +1,7 @@ +const Index = ({ query }) => ( +
{JSON.stringify(query)}
+) + +Index.getInitialProps = ({ query }) => ({ query }) + +export default Index diff --git a/test/integration/query-trailing-space/test/index.test.js b/test/integration/query-trailing-space/test/index.test.js new file mode 100644 index 000000000000000..96a8ef934573fed --- /dev/null +++ b/test/integration/query-trailing-space/test/index.test.js @@ -0,0 +1,85 @@ +/* eslint-env jest */ +/* global jasmine */ +import { + nextBuild, + nextServer, + startApp, + stopApp, + waitFor, +} from 'next-test-utils' +import webdriver from 'next-webdriver' +import { join } from 'path' + +jasmine.DEFAULT_TIMEOUT_INTERVAL = 1000 * 60 * 2 + +const appDir = join(__dirname, '..') + +let appPort +let app +let server + +describe('Trailing Space in Query', () => { + beforeAll(async () => { + await nextBuild(appDir) + app = nextServer({ + dir: join(__dirname, '../'), + dev: false, + quiet: true, + }) + + server = await startApp(app) + appPort = server.address().port + }) + afterAll(() => stopApp(server)) + + it('should have correct query on SSR', async () => { + const browser = await webdriver(appPort, '/?test=abc%20') + try { + const text = await browser.elementByCss('#query-content').text() + expect(text).toBe('{"test":"abc "}') + } finally { + await browser.close() + } + }) + + it('should have correct query on Router#push', async () => { + const browser = await webdriver(appPort, '/') + try { + await waitFor(2000) + await browser.eval( + `window.next.router.push({pathname:'/',query:{abc:'def '}})` + ) + await waitFor(1000) + const text = await browser.elementByCss('#query-content').text() + expect(text).toBe('{"abc":"def "}') + } finally { + await browser.close() + } + }) + + it('should have correct query on simple client-side ', async () => { + const browser = await webdriver(appPort, '/another') + try { + await waitFor(2000) + await browser.elementByCss('#hello-space').click() + await waitFor(1000) + const text = await browser.elementByCss('#query-content').text() + expect(text).toBe('{"another":"hello "}') + } finally { + await browser.close() + } + }) + + it('should have correct query on complex client-side ', async () => { + const browser = await webdriver(appPort, '/another') + try { + await waitFor(2000) + await browser.elementByCss('#hello-complex').click() + await waitFor(1000) + const text = await browser.elementByCss('#query-content').text() + expect(text).toBe('{"complex":"yes "}') + } finally { + await browser.close() + } + }) +}) From ed46d1ffc6f6f7ab3d6140b7dfd6d67af66dd0ca Mon Sep 17 00:00:00 2001 From: Joe Haddad Date: Tue, 14 Jan 2020 22:53:58 -0500 Subject: [PATCH 2/6] Test Query String with % --- .../query-with-percent/pages/another.js | 15 ++++ .../query-with-percent/pages/index.js | 7 ++ .../query-with-percent/test/index.test.js | 85 +++++++++++++++++++ 3 files changed, 107 insertions(+) create mode 100644 test/integration/query-with-percent/pages/another.js create mode 100644 test/integration/query-with-percent/pages/index.js create mode 100644 test/integration/query-with-percent/test/index.test.js diff --git a/test/integration/query-with-percent/pages/another.js b/test/integration/query-with-percent/pages/another.js new file mode 100644 index 000000000000000..293f399e3dad69c --- /dev/null +++ b/test/integration/query-with-percent/pages/another.js @@ -0,0 +1,15 @@ +import Link from 'next/link' + +const Another = () => ( +
+ + Hello % + +
+ + Hello Complex + +
+) + +export default Another diff --git a/test/integration/query-with-percent/pages/index.js b/test/integration/query-with-percent/pages/index.js new file mode 100644 index 000000000000000..5abbac3c14b81af --- /dev/null +++ b/test/integration/query-with-percent/pages/index.js @@ -0,0 +1,7 @@ +const Index = ({ query }) => ( +
{JSON.stringify(query)}
+) + +Index.getInitialProps = ({ query }) => ({ query }) + +export default Index diff --git a/test/integration/query-with-percent/test/index.test.js b/test/integration/query-with-percent/test/index.test.js new file mode 100644 index 000000000000000..b3958acf5b21ca7 --- /dev/null +++ b/test/integration/query-with-percent/test/index.test.js @@ -0,0 +1,85 @@ +/* eslint-env jest */ +/* global jasmine */ +import { + nextBuild, + nextServer, + startApp, + stopApp, + waitFor, +} from 'next-test-utils' +import webdriver from 'next-webdriver' +import { join } from 'path' + +jasmine.DEFAULT_TIMEOUT_INTERVAL = 1000 * 60 * 2 + +const appDir = join(__dirname, '..') + +let appPort +let app +let server + +describe('Trailing Space in Query', () => { + beforeAll(async () => { + await nextBuild(appDir) + app = nextServer({ + dir: join(__dirname, '../'), + dev: false, + quiet: true, + }) + + server = await startApp(app) + appPort = server.address().port + }) + afterAll(() => stopApp(server)) + + it('should have correct query on SSR', async () => { + const browser = await webdriver(appPort, '/?test=abc%25') + try { + const text = await browser.elementByCss('#query-content').text() + expect(text).toBe('{"test":"abc%"}') + } finally { + await browser.close() + } + }) + + it('should have correct query on Router#push', async () => { + const browser = await webdriver(appPort, '/') + try { + await waitFor(2000) + await browser.eval( + `window.next.router.push({pathname:'/',query:{abc:'def%'}})` + ) + await waitFor(1000) + const text = await browser.elementByCss('#query-content').text() + expect(text).toBe('{"abc":"def%"}') + } finally { + await browser.close() + } + }) + + it('should have correct query on simple client-side ', async () => { + const browser = await webdriver(appPort, '/another') + try { + await waitFor(2000) + await browser.elementByCss('#hello-percent').click() + await waitFor(1000) + const text = await browser.elementByCss('#query-content').text() + expect(text).toBe('{"another":"hello%"}') + } finally { + await browser.close() + } + }) + + it('should have correct query on complex client-side ', async () => { + const browser = await webdriver(appPort, '/another') + try { + await waitFor(2000) + await browser.elementByCss('#hello-complex').click() + await waitFor(1000) + const text = await browser.elementByCss('#query-content').text() + expect(text).toBe('{"complex":"yes%"}') + } finally { + await browser.close() + } + }) +}) From eabd75d8f3bdf1bdff89b2db5eb1b8f02d5cf1c6 Mon Sep 17 00:00:00 2001 From: Joe Haddad Date: Wed, 15 Jan 2020 10:52:32 -0500 Subject: [PATCH 3/6] Test Query String With LF --- .../query-with-newline/pages/another.js | 15 ++++ .../query-with-newline/pages/index.js | 7 ++ .../query-with-newline/test/index.test.js | 85 +++++++++++++++++++ 3 files changed, 107 insertions(+) create mode 100644 test/integration/query-with-newline/pages/another.js create mode 100644 test/integration/query-with-newline/pages/index.js create mode 100644 test/integration/query-with-newline/test/index.test.js diff --git a/test/integration/query-with-newline/pages/another.js b/test/integration/query-with-newline/pages/another.js new file mode 100644 index 000000000000000..f54a15a0ec78083 --- /dev/null +++ b/test/integration/query-with-newline/pages/another.js @@ -0,0 +1,15 @@ +import Link from 'next/link' + +const Another = () => ( +
+ + Hello LF + +
+ + Hello Complex + +
+) + +export default Another diff --git a/test/integration/query-with-newline/pages/index.js b/test/integration/query-with-newline/pages/index.js new file mode 100644 index 000000000000000..5abbac3c14b81af --- /dev/null +++ b/test/integration/query-with-newline/pages/index.js @@ -0,0 +1,7 @@ +const Index = ({ query }) => ( +
{JSON.stringify(query)}
+) + +Index.getInitialProps = ({ query }) => ({ query }) + +export default Index diff --git a/test/integration/query-with-newline/test/index.test.js b/test/integration/query-with-newline/test/index.test.js new file mode 100644 index 000000000000000..41bb8091046b5dd --- /dev/null +++ b/test/integration/query-with-newline/test/index.test.js @@ -0,0 +1,85 @@ +/* eslint-env jest */ +/* global jasmine */ +import { + nextBuild, + nextServer, + startApp, + stopApp, + waitFor, +} from 'next-test-utils' +import webdriver from 'next-webdriver' +import { join } from 'path' + +jasmine.DEFAULT_TIMEOUT_INTERVAL = 1000 * 60 * 2 + +const appDir = join(__dirname, '..') + +let appPort +let app +let server + +describe('New Line in Query', () => { + beforeAll(async () => { + await nextBuild(appDir) + app = nextServer({ + dir: join(__dirname, '../'), + dev: false, + quiet: true, + }) + + server = await startApp(app) + appPort = server.address().port + }) + afterAll(() => stopApp(server)) + + it('should have correct query on SSR', async () => { + const browser = await webdriver(appPort, '/?test=abc%0A') + try { + const text = await browser.elementByCss('#query-content').text() + expect(text).toBe('{"test":"abc\\n"}') + } finally { + await browser.close() + } + }) + + it('should have correct query on Router#push', async () => { + const browser = await webdriver(appPort, '/') + try { + await waitFor(2000) + await browser.eval( + `window.next.router.push({pathname:'/',query:{abc:'def\\n'}})` + ) + await waitFor(1000) + const text = await browser.elementByCss('#query-content').text() + expect(text).toBe('{"abc":"def\\n"}') + } finally { + await browser.close() + } + }) + + it('should have correct query on simple client-side ', async () => { + const browser = await webdriver(appPort, '/another') + try { + await waitFor(2000) + await browser.elementByCss('#hello-lf').click() + await waitFor(1000) + const text = await browser.elementByCss('#query-content').text() + expect(text).toBe('{"another":"hello\\n"}') + } finally { + await browser.close() + } + }) + + it('should have correct query on complex client-side ', async () => { + const browser = await webdriver(appPort, '/another') + try { + await waitFor(2000) + await browser.elementByCss('#hello-complex').click() + await waitFor(1000) + const text = await browser.elementByCss('#query-content').text() + expect(text).toBe('{"complex":"yes\\n"}') + } finally { + await browser.close() + } + }) +}) From 07951187351444d6348a56eadb5c75cffbb602fd Mon Sep 17 00:00:00 2001 From: Joe Haddad Date: Mon, 20 Jan 2020 15:06:21 -0500 Subject: [PATCH 4/6] Update test --- .../pages/index.js | 0 .../another.js => query-with-encoding/pages/newline.js} | 0 .../test/index.test.js | 6 +++--- 3 files changed, 3 insertions(+), 3 deletions(-) rename test/integration/{query-with-newline => query-with-encoding}/pages/index.js (100%) rename test/integration/{query-with-newline/pages/another.js => query-with-encoding/pages/newline.js} (100%) rename test/integration/{query-with-newline => query-with-encoding}/test/index.test.js (92%) diff --git a/test/integration/query-with-newline/pages/index.js b/test/integration/query-with-encoding/pages/index.js similarity index 100% rename from test/integration/query-with-newline/pages/index.js rename to test/integration/query-with-encoding/pages/index.js diff --git a/test/integration/query-with-newline/pages/another.js b/test/integration/query-with-encoding/pages/newline.js similarity index 100% rename from test/integration/query-with-newline/pages/another.js rename to test/integration/query-with-encoding/pages/newline.js diff --git a/test/integration/query-with-newline/test/index.test.js b/test/integration/query-with-encoding/test/index.test.js similarity index 92% rename from test/integration/query-with-newline/test/index.test.js rename to test/integration/query-with-encoding/test/index.test.js index 41bb8091046b5dd..f7d61e5f583a383 100644 --- a/test/integration/query-with-newline/test/index.test.js +++ b/test/integration/query-with-encoding/test/index.test.js @@ -18,7 +18,7 @@ let appPort let app let server -describe('New Line in Query', () => { +describe('Query String with Encoding', () => { beforeAll(async () => { await nextBuild(appDir) app = nextServer({ @@ -58,7 +58,7 @@ describe('New Line in Query', () => { }) it('should have correct query on simple client-side ', async () => { - const browser = await webdriver(appPort, '/another') + const browser = await webdriver(appPort, '/newline') try { await waitFor(2000) await browser.elementByCss('#hello-lf').click() @@ -71,7 +71,7 @@ describe('New Line in Query', () => { }) it('should have correct query on complex client-side ', async () => { - const browser = await webdriver(appPort, '/another') + const browser = await webdriver(appPort, '/newline') try { await waitFor(2000) await browser.elementByCss('#hello-complex').click() From 72658b69e6675846dd23eb34ba606d622219575d Mon Sep 17 00:00:00 2001 From: Joe Haddad Date: Mon, 20 Jan 2020 15:07:58 -0500 Subject: [PATCH 5/6] Consolidate --- .../query-trailing-space/pages/index.js | 7 - .../query-trailing-space/test/index.test.js | 85 ---------- .../pages/space.js} | 0 .../query-with-encoding/test/index.test.js | 145 ++++++++++++------ 4 files changed, 100 insertions(+), 137 deletions(-) delete mode 100644 test/integration/query-trailing-space/pages/index.js delete mode 100644 test/integration/query-trailing-space/test/index.test.js rename test/integration/{query-trailing-space/pages/another.js => query-with-encoding/pages/space.js} (100%) diff --git a/test/integration/query-trailing-space/pages/index.js b/test/integration/query-trailing-space/pages/index.js deleted file mode 100644 index 5abbac3c14b81af..000000000000000 --- a/test/integration/query-trailing-space/pages/index.js +++ /dev/null @@ -1,7 +0,0 @@ -const Index = ({ query }) => ( -
{JSON.stringify(query)}
-) - -Index.getInitialProps = ({ query }) => ({ query }) - -export default Index diff --git a/test/integration/query-trailing-space/test/index.test.js b/test/integration/query-trailing-space/test/index.test.js deleted file mode 100644 index 96a8ef934573fed..000000000000000 --- a/test/integration/query-trailing-space/test/index.test.js +++ /dev/null @@ -1,85 +0,0 @@ -/* eslint-env jest */ -/* global jasmine */ -import { - nextBuild, - nextServer, - startApp, - stopApp, - waitFor, -} from 'next-test-utils' -import webdriver from 'next-webdriver' -import { join } from 'path' - -jasmine.DEFAULT_TIMEOUT_INTERVAL = 1000 * 60 * 2 - -const appDir = join(__dirname, '..') - -let appPort -let app -let server - -describe('Trailing Space in Query', () => { - beforeAll(async () => { - await nextBuild(appDir) - app = nextServer({ - dir: join(__dirname, '../'), - dev: false, - quiet: true, - }) - - server = await startApp(app) - appPort = server.address().port - }) - afterAll(() => stopApp(server)) - - it('should have correct query on SSR', async () => { - const browser = await webdriver(appPort, '/?test=abc%20') - try { - const text = await browser.elementByCss('#query-content').text() - expect(text).toBe('{"test":"abc "}') - } finally { - await browser.close() - } - }) - - it('should have correct query on Router#push', async () => { - const browser = await webdriver(appPort, '/') - try { - await waitFor(2000) - await browser.eval( - `window.next.router.push({pathname:'/',query:{abc:'def '}})` - ) - await waitFor(1000) - const text = await browser.elementByCss('#query-content').text() - expect(text).toBe('{"abc":"def "}') - } finally { - await browser.close() - } - }) - - it('should have correct query on simple client-side ', async () => { - const browser = await webdriver(appPort, '/another') - try { - await waitFor(2000) - await browser.elementByCss('#hello-space').click() - await waitFor(1000) - const text = await browser.elementByCss('#query-content').text() - expect(text).toBe('{"another":"hello "}') - } finally { - await browser.close() - } - }) - - it('should have correct query on complex client-side ', async () => { - const browser = await webdriver(appPort, '/another') - try { - await waitFor(2000) - await browser.elementByCss('#hello-complex').click() - await waitFor(1000) - const text = await browser.elementByCss('#query-content').text() - expect(text).toBe('{"complex":"yes "}') - } finally { - await browser.close() - } - }) -}) diff --git a/test/integration/query-trailing-space/pages/another.js b/test/integration/query-with-encoding/pages/space.js similarity index 100% rename from test/integration/query-trailing-space/pages/another.js rename to test/integration/query-with-encoding/pages/space.js diff --git a/test/integration/query-with-encoding/test/index.test.js b/test/integration/query-with-encoding/test/index.test.js index f7d61e5f583a383..2329c9a18acc287 100644 --- a/test/integration/query-with-encoding/test/index.test.js +++ b/test/integration/query-with-encoding/test/index.test.js @@ -32,54 +32,109 @@ describe('Query String with Encoding', () => { }) afterAll(() => stopApp(server)) - it('should have correct query on SSR', async () => { - const browser = await webdriver(appPort, '/?test=abc%0A') - try { - const text = await browser.elementByCss('#query-content').text() - expect(text).toBe('{"test":"abc\\n"}') - } finally { - await browser.close() - } - }) + describe('new line', () => { + it('should have correct query on SSR', async () => { + const browser = await webdriver(appPort, '/?test=abc%0A') + try { + const text = await browser.elementByCss('#query-content').text() + expect(text).toBe('{"test":"abc\\n"}') + } finally { + await browser.close() + } + }) - it('should have correct query on Router#push', async () => { - const browser = await webdriver(appPort, '/') - try { - await waitFor(2000) - await browser.eval( - `window.next.router.push({pathname:'/',query:{abc:'def\\n'}})` - ) - await waitFor(1000) - const text = await browser.elementByCss('#query-content').text() - expect(text).toBe('{"abc":"def\\n"}') - } finally { - await browser.close() - } - }) + it('should have correct query on Router#push', async () => { + const browser = await webdriver(appPort, '/') + try { + await waitFor(2000) + await browser.eval( + `window.next.router.push({pathname:'/',query:{abc:'def\\n'}})` + ) + await waitFor(1000) + const text = await browser.elementByCss('#query-content').text() + expect(text).toBe('{"abc":"def\\n"}') + } finally { + await browser.close() + } + }) - it('should have correct query on simple client-side ', async () => { - const browser = await webdriver(appPort, '/newline') - try { - await waitFor(2000) - await browser.elementByCss('#hello-lf').click() - await waitFor(1000) - const text = await browser.elementByCss('#query-content').text() - expect(text).toBe('{"another":"hello\\n"}') - } finally { - await browser.close() - } + it('should have correct query on simple client-side ', async () => { + const browser = await webdriver(appPort, '/newline') + try { + await waitFor(2000) + await browser.elementByCss('#hello-lf').click() + await waitFor(1000) + const text = await browser.elementByCss('#query-content').text() + expect(text).toBe('{"another":"hello\\n"}') + } finally { + await browser.close() + } + }) + + it('should have correct query on complex client-side ', async () => { + const browser = await webdriver(appPort, '/newline') + try { + await waitFor(2000) + await browser.elementByCss('#hello-complex').click() + await waitFor(1000) + const text = await browser.elementByCss('#query-content').text() + expect(text).toBe('{"complex":"yes\\n"}') + } finally { + await browser.close() + } + }) }) - it('should have correct query on complex client-side ', async () => { - const browser = await webdriver(appPort, '/newline') - try { - await waitFor(2000) - await browser.elementByCss('#hello-complex').click() - await waitFor(1000) - const text = await browser.elementByCss('#query-content').text() - expect(text).toBe('{"complex":"yes\\n"}') - } finally { - await browser.close() - } + describe('trailing space', () => { + it('should have correct query on SSR', async () => { + const browser = await webdriver(appPort, '/?test=abc%20') + try { + const text = await browser.elementByCss('#query-content').text() + expect(text).toBe('{"test":"abc "}') + } finally { + await browser.close() + } + }) + + it('should have correct query on Router#push', async () => { + const browser = await webdriver(appPort, '/') + try { + await waitFor(2000) + await browser.eval( + `window.next.router.push({pathname:'/',query:{abc:'def '}})` + ) + await waitFor(1000) + const text = await browser.elementByCss('#query-content').text() + expect(text).toBe('{"abc":"def "}') + } finally { + await browser.close() + } + }) + + it('should have correct query on simple client-side ', async () => { + const browser = await webdriver(appPort, '/space') + try { + await waitFor(2000) + await browser.elementByCss('#hello-space').click() + await waitFor(1000) + const text = await browser.elementByCss('#query-content').text() + expect(text).toBe('{"another":"hello "}') + } finally { + await browser.close() + } + }) + + it('should have correct query on complex client-side ', async () => { + const browser = await webdriver(appPort, '/space') + try { + await waitFor(2000) + await browser.elementByCss('#hello-complex').click() + await waitFor(1000) + const text = await browser.elementByCss('#query-content').text() + expect(text).toBe('{"complex":"yes "}') + } finally { + await browser.close() + } + }) }) }) From c74f4aa2478f69512293e8a886afb9d3ae3c3f12 Mon Sep 17 00:00:00 2001 From: Joe Haddad Date: Mon, 20 Jan 2020 15:08:50 -0500 Subject: [PATCH 6/6] Consolidate --- .../pages/percent.js} | 0 .../query-with-encoding/test/index.test.js | 53 ++++++++++++ .../query-with-percent/pages/index.js | 7 -- .../query-with-percent/test/index.test.js | 85 ------------------- 4 files changed, 53 insertions(+), 92 deletions(-) rename test/integration/{query-with-percent/pages/another.js => query-with-encoding/pages/percent.js} (100%) delete mode 100644 test/integration/query-with-percent/pages/index.js delete mode 100644 test/integration/query-with-percent/test/index.test.js diff --git a/test/integration/query-with-percent/pages/another.js b/test/integration/query-with-encoding/pages/percent.js similarity index 100% rename from test/integration/query-with-percent/pages/another.js rename to test/integration/query-with-encoding/pages/percent.js diff --git a/test/integration/query-with-encoding/test/index.test.js b/test/integration/query-with-encoding/test/index.test.js index 2329c9a18acc287..32309b8a7331237 100644 --- a/test/integration/query-with-encoding/test/index.test.js +++ b/test/integration/query-with-encoding/test/index.test.js @@ -137,4 +137,57 @@ describe('Query String with Encoding', () => { } }) }) + + describe('percent', () => { + it('should have correct query on SSR', async () => { + const browser = await webdriver(appPort, '/?test=abc%25') + try { + const text = await browser.elementByCss('#query-content').text() + expect(text).toBe('{"test":"abc%"}') + } finally { + await browser.close() + } + }) + + it('should have correct query on Router#push', async () => { + const browser = await webdriver(appPort, '/') + try { + await waitFor(2000) + await browser.eval( + `window.next.router.push({pathname:'/',query:{abc:'def%'}})` + ) + await waitFor(1000) + const text = await browser.elementByCss('#query-content').text() + expect(text).toBe('{"abc":"def%"}') + } finally { + await browser.close() + } + }) + + it('should have correct query on simple client-side ', async () => { + const browser = await webdriver(appPort, '/percent') + try { + await waitFor(2000) + await browser.elementByCss('#hello-percent').click() + await waitFor(1000) + const text = await browser.elementByCss('#query-content').text() + expect(text).toBe('{"another":"hello%"}') + } finally { + await browser.close() + } + }) + + it('should have correct query on complex client-side ', async () => { + const browser = await webdriver(appPort, '/percent') + try { + await waitFor(2000) + await browser.elementByCss('#hello-complex').click() + await waitFor(1000) + const text = await browser.elementByCss('#query-content').text() + expect(text).toBe('{"complex":"yes%"}') + } finally { + await browser.close() + } + }) + }) }) diff --git a/test/integration/query-with-percent/pages/index.js b/test/integration/query-with-percent/pages/index.js deleted file mode 100644 index 5abbac3c14b81af..000000000000000 --- a/test/integration/query-with-percent/pages/index.js +++ /dev/null @@ -1,7 +0,0 @@ -const Index = ({ query }) => ( -
{JSON.stringify(query)}
-) - -Index.getInitialProps = ({ query }) => ({ query }) - -export default Index diff --git a/test/integration/query-with-percent/test/index.test.js b/test/integration/query-with-percent/test/index.test.js deleted file mode 100644 index b3958acf5b21ca7..000000000000000 --- a/test/integration/query-with-percent/test/index.test.js +++ /dev/null @@ -1,85 +0,0 @@ -/* eslint-env jest */ -/* global jasmine */ -import { - nextBuild, - nextServer, - startApp, - stopApp, - waitFor, -} from 'next-test-utils' -import webdriver from 'next-webdriver' -import { join } from 'path' - -jasmine.DEFAULT_TIMEOUT_INTERVAL = 1000 * 60 * 2 - -const appDir = join(__dirname, '..') - -let appPort -let app -let server - -describe('Trailing Space in Query', () => { - beforeAll(async () => { - await nextBuild(appDir) - app = nextServer({ - dir: join(__dirname, '../'), - dev: false, - quiet: true, - }) - - server = await startApp(app) - appPort = server.address().port - }) - afterAll(() => stopApp(server)) - - it('should have correct query on SSR', async () => { - const browser = await webdriver(appPort, '/?test=abc%25') - try { - const text = await browser.elementByCss('#query-content').text() - expect(text).toBe('{"test":"abc%"}') - } finally { - await browser.close() - } - }) - - it('should have correct query on Router#push', async () => { - const browser = await webdriver(appPort, '/') - try { - await waitFor(2000) - await browser.eval( - `window.next.router.push({pathname:'/',query:{abc:'def%'}})` - ) - await waitFor(1000) - const text = await browser.elementByCss('#query-content').text() - expect(text).toBe('{"abc":"def%"}') - } finally { - await browser.close() - } - }) - - it('should have correct query on simple client-side ', async () => { - const browser = await webdriver(appPort, '/another') - try { - await waitFor(2000) - await browser.elementByCss('#hello-percent').click() - await waitFor(1000) - const text = await browser.elementByCss('#query-content').text() - expect(text).toBe('{"another":"hello%"}') - } finally { - await browser.close() - } - }) - - it('should have correct query on complex client-side ', async () => { - const browser = await webdriver(appPort, '/another') - try { - await waitFor(2000) - await browser.elementByCss('#hello-complex').click() - await waitFor(1000) - const text = await browser.elementByCss('#query-content').text() - expect(text).toBe('{"complex":"yes%"}') - } finally { - await browser.close() - } - }) -})