add redirect test to root (“/“)

This commit is contained in:
Luke Edwards
2018-08-06 20:29:28 -07:00
parent aad87857ce
commit c6da26e1a0
3 changed files with 35 additions and 0 deletions

View File

@@ -8,6 +8,7 @@
<a href='about'>about</a>
<a href='slow-preload'>slow preload</a>
<a href='redirect-from'>redirect</a>
<a href='redirect-root'>redirect (root)</a>
<a href='blog/nope'>broken link</a>
<a href='blog/throw-an-error'>error link</a>
<a href='credentials?creds=include'>credentials</a>

View File

@@ -0,0 +1,7 @@
<script>
export default {
preload() {
this.redirect(301, '/');
}
};
</script>

View File

@@ -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()