From dd655ffdf11d8df5113c956735818ad9232fe932 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 +++++++++++++++- test/e2e/specs/basic.js | 9 +++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/examples/basic/app.js b/examples/basic/app.js index 3140f03ce..e1ae4dede 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/test/e2e/specs/basic.js b/test/e2e/specs/basic.js index ad2e5c00f..850d8a049 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() } }