From 3020af7c38cc10b9578c9f56fcfcb13c052bfba9 Mon Sep 17 00:00:00 2001 From: Clark Du Date: Tue, 28 Nov 2017 17:10:44 +0800 Subject: [PATCH] test: redirect to external url --- test/basic.csr.test.js | 9 +++++++++ test/basic.ssr.test.js | 13 +++++++++++++ test/fixtures/basic/pages/redirect3.vue | 11 +++++++++++ 3 files changed, 33 insertions(+) create mode 100644 test/fixtures/basic/pages/redirect3.vue diff --git a/test/basic.csr.test.js b/test/basic.csr.test.js index da09e77a1b..3c58c37462 100644 --- a/test/basic.csr.test.js +++ b/test/basic.csr.test.js @@ -143,6 +143,15 @@ test('/redirect2', async t => { t.is(await page.$text('h1'), 'Index page') }) +test('/redirect3', async t => { + // New page for redirecting to external link. + const page = await browser.page(url('/')) + await page.nuxt.navigate('/redirect3', false) + await page.waitForFunction(() => window.location.href === 'https://nuxtjs.org/') + page.close() + t.pass() +}) + test('/no-ssr', async t => { await page.nuxt.navigate('/no-ssr') diff --git a/test/basic.ssr.test.js b/test/basic.ssr.test.js index e3dc4559b2..0ac2f77736 100755 --- a/test/basic.ssr.test.js +++ b/test/basic.ssr.test.js @@ -117,6 +117,19 @@ test('/redirect -> check redirected source', async t => { t.true(html.includes('

Index page

')) }) +test('/redirect -> external link', async t => { + const headers = {} + const { html } = await nuxt.renderRoute('/redirect3', { + res: { + setHeader(k, v) { + headers[k] = v + } + } + }) + t.is(headers.Location, 'https://nuxtjs.org') + t.true(html.includes('
redirecting.
')) +}) + test('/special-state -> check window.__NUXT__.test = true', async t => { const window = await nuxt.renderAndGetWindow(url('/special-state')) t.is(window.document.title, 'Nuxt.js') diff --git a/test/fixtures/basic/pages/redirect3.vue b/test/fixtures/basic/pages/redirect3.vue new file mode 100644 index 0000000000..1f587681d5 --- /dev/null +++ b/test/fixtures/basic/pages/redirect3.vue @@ -0,0 +1,11 @@ + + +