diff --git a/test/integration/query-with-encoding/pages/plus.js b/test/integration/query-with-encoding/pages/plus.js new file mode 100644 index 000000000000000..9350fb3f5744b0e --- /dev/null +++ b/test/integration/query-with-encoding/pages/plus.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-encoding/test/index.test.js b/test/integration/query-with-encoding/test/index.test.js index 32309b8a7331237..2a78b7add8725a8 100644 --- a/test/integration/query-with-encoding/test/index.test.js +++ b/test/integration/query-with-encoding/test/index.test.js @@ -190,4 +190,57 @@ describe('Query String with Encoding', () => { } }) }) + + describe('plus', () => { + it('should have correct query on SSR', async () => { + const browser = await webdriver(appPort, '/?test=abc%2B') + 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, '/plus') + try { + await waitFor(2000) + await browser.elementByCss('#hello-plus').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, '/plus') + 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() + } + }) + }) })