From c6da26e1a025dbf40c887a025d92d3380472de17 Mon Sep 17 00:00:00 2001 From: Luke Edwards Date: Mon, 6 Aug 2018 20:29:28 -0700 Subject: [PATCH] =?UTF-8?q?add=20redirect=20test=20to=20root=20(=E2=80=9C/?= =?UTF-8?q?=E2=80=9C)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/app/routes/index.html | 1 + test/app/routes/redirect-root.html | 7 +++++++ test/common/test.js | 27 +++++++++++++++++++++++++++ 3 files changed, 35 insertions(+) create mode 100644 test/app/routes/redirect-root.html diff --git a/test/app/routes/index.html b/test/app/routes/index.html index cb37b8c..b695afe 100644 --- a/test/app/routes/index.html +++ b/test/app/routes/index.html @@ -8,6 +8,7 @@ about slow preload redirect +redirect (root) broken link error link credentials diff --git a/test/app/routes/redirect-root.html b/test/app/routes/redirect-root.html new file mode 100644 index 0000000..ddd4b49 --- /dev/null +++ b/test/app/routes/redirect-root.html @@ -0,0 +1,7 @@ + diff --git a/test/common/test.js b/test/common/test.js index c46751f..70bf890 100644 --- a/test/common/test.js +++ b/test/common/test.js @@ -436,6 +436,33 @@ function run({ mode, basepath = '' }) { }); }); + it('redirects on server (root)', () => { + return nightmare.goto(`${base}/redirect-root`) + .path() + .then(path => { + assert.equal(path, `${basepath}/`); + }) + .then(() => nightmare.page.title()) + .then(title => { + assert.equal(title, 'Great success!'); + }); + }); + + it('redirects in client (root)', () => { + return nightmare.goto(base) + .wait('[href="redirect-root"]') + .click('[href="redirect-root"]') + .wait(200) + .path() + .then(path => { + assert.equal(path, `${basepath}/`); + }) + .then(() => nightmare.page.title()) + .then(title => { + assert.equal(title, 'Great success!'); + }); + }); + it('handles 4xx error on server', () => { return nightmare.goto(`${base}/blog/nope`) .path()