diff --git a/test/apps/with-basepath/src/routes/index.svelte b/test/apps/with-basepath/src/routes/index.svelte
index 0cc4b72..45bc3a3 100644
--- a/test/apps/with-basepath/src/routes/index.svelte
+++ b/test/apps/with-basepath/src/routes/index.svelte
@@ -1 +1,2 @@
-
Great success!
\ No newline at end of file
+Great success!
+redirect from
diff --git a/test/apps/with-basepath/src/routes/redirect-from.svelte b/test/apps/with-basepath/src/routes/redirect-from.svelte
new file mode 100644
index 0000000..45805e1
--- /dev/null
+++ b/test/apps/with-basepath/src/routes/redirect-from.svelte
@@ -0,0 +1,7 @@
+
+
+unredirected
\ No newline at end of file
diff --git a/test/apps/with-basepath/src/routes/redirect-to.svelte b/test/apps/with-basepath/src/routes/redirect-to.svelte
new file mode 100644
index 0000000..eeb0dfc
--- /dev/null
+++ b/test/apps/with-basepath/src/routes/redirect-to.svelte
@@ -0,0 +1 @@
+redirected
\ No newline at end of file
diff --git a/test/apps/with-basepath/test.ts b/test/apps/with-basepath/test.ts
index 5741d1b..bfb50d8 100644
--- a/test/apps/with-basepath/test.ts
+++ b/test/apps/with-basepath/test.ts
@@ -3,6 +3,8 @@ import * as puppeteer from 'puppeteer';
import * as api from '../../../api';
import { walk } from '../../utils';
import { AppRunner } from '../AppRunner';
+import { wait } from '../../utils';
+
describe('with-basepath', function() {
this.timeout(10000);
@@ -11,6 +13,10 @@ describe('with-basepath', function() {
let page: puppeteer.Page;
let base: string;
+ let start: () => Promise;
+ let prefetchRoutes: () => Promise;
+ let title: () => Promise;
+
// hooks
before(async () => {
await api.build({ cwd: __dirname });
@@ -21,7 +27,7 @@ describe('with-basepath', function() {
});
runner = new AppRunner(__dirname, '__sapper__/build/server/server.js');
- ({ base, page } = await runner.start());
+ ({ base, start, page, prefetchRoutes, title } = await runner.start());
});
after(() => runner.end());
@@ -56,8 +62,44 @@ describe('with-basepath', function() {
assert.deepEqual(non_client_assets, [
'custom-basepath/global.css',
'custom-basepath/index.html',
+ 'custom-basepath/redirect-from/index.html',
+ 'custom-basepath/redirect-to',
'custom-basepath/service-worker-index.html',
'custom-basepath/service-worker.js'
]);
});
+
+ it('redirects on server', async () => {
+ console.log('base', base)
+ await page.goto(`${base}/custom-basepath/redirect-from`);
+
+ assert.equal(
+ page.url(),
+ `${base}/custom-basepath/redirect-to`
+ );
+
+ assert.equal(
+ await title(),
+ 'redirected'
+ );
+ });
+
+ it('redirects in client', async () => {
+ await page.goto(`${base}/custom-basepath`);
+ await start();
+ await prefetchRoutes();
+
+ await page.click('[href="redirect-from"]');
+ await wait(50);
+
+ assert.equal(
+ page.url(),
+ `${base}/custom-basepath/redirect-to`
+ );
+
+ assert.equal(
+ await title(),
+ 'redirected'
+ );
+ });
});
\ No newline at end of file