From ddd864fb27c1f967f07c032e1d685f2ae6c5be11 Mon Sep 17 00:00:00 2001 From: Eduardo San Martin Morote Date: Wed, 17 Apr 2019 10:32:23 +0200 Subject: [PATCH] test: add e2e test for onSuccess callback --- examples/basic/app.js | 16 +++++++++++++++- src/util/resolve-components.js | 2 +- test/e2e/specs/basic.js | 9 +++++++++ 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/examples/basic/app.js b/examples/basic/app.js index 3140f03cea..e1ae4dede5 100644 --- a/examples/basic/app.js +++ b/examples/basic/app.js @@ -29,6 +29,7 @@ const router = new VueRouter({ // Route components will be rendered inside . new Vue({ router, + data: () => ({ n: 0 }), template: `

Basic

@@ -43,9 +44,22 @@ new Vue({
  • /é?t=%ñ
  • /é#%25ñ
  • + +
    {{ n }}
    {{ $route.query.t }}
    {{ $route.hash }}
    - ` + `, + + methods: { + navigateAndIncrement () { + const increment = () => this.n++ + if (this.$route.path === '/') { + this.$router.push('/foo', increment) + } else { + this.$router.push('/', increment) + } + } + } }).$mount('#app') diff --git a/src/util/resolve-components.js b/src/util/resolve-components.js index 3f7608cd54..c6a2927c16 100644 --- a/src/util/resolve-components.js +++ b/src/util/resolve-components.js @@ -30,7 +30,7 @@ export function resolveAsyncComponents (matched: Array): Function { match.components[key] = resolvedDef pending-- if (pending <= 0) { - next() + next(to) } }) diff --git a/test/e2e/specs/basic.js b/test/e2e/specs/basic.js index ad2e5c00f0..850d8a049a 100644 --- a/test/e2e/specs/basic.js +++ b/test/e2e/specs/basic.js @@ -40,6 +40,15 @@ module.exports = { .url('http://localhost:8080/basic/%C3%A9') .waitForElementVisible('#app', 1000) .assert.containsText('.view', 'unicode') + + // regression onComplete + // https://github.com/vuejs/vue-router/issues/2721 + .assert.containsText('#counter', '0') + .click('#navigate-btn') + .assert.containsText('#counter', '1') + .click('#navigate-btn') + .assert.containsText('#counter', '2') + .end() } }