From: Eduardo San Martin Morote Date: Tue, 24 Nov 2020 11:55:08 +0000 (+0100) Subject: test(e2e): test for guards with named views X-Git-Tag: v4.0.0-rc.6~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6448a149a47db791665dd40d6cc9fe316041b564;p=thirdparty%2Fvuejs%2Frouter.git test(e2e): test for guards with named views --- diff --git a/e2e/guards-instances/index.ts b/e2e/guards-instances/index.ts index 70aa4afc..205efd8e 100644 --- a/e2e/guards-instances/index.ts +++ b/e2e/guards-instances/index.ts @@ -93,6 +93,8 @@ function createTestComponent(key: string) { } const Foo = createTestComponent('Foo') +const One = createTestComponent('One') +const Two = createTestComponent('Two') const Aux = createTestComponent('Aux') const webHistory = createWebHistory('/' + __dirname) @@ -108,6 +110,20 @@ const router = createRouter({ path: '/f/:id', component: Foo, }, + { + path: '/named-one', + components: { + default: One, + aux: Aux, + }, + }, + { + path: '/named-two', + components: { + default: Two, + aux: Aux, + }, + }, ], }) @@ -160,6 +176,9 @@ leaves: {{ state.leave }}
  • /f/2?bar=foo
  • /f/2?foo=key
  • /f/2?foo=key2
  • +
  • {{ route.fullPath }}
  • +
  • /named-one
  • +
  • /named-two
  • diff --git a/e2e/specs/guards-instances.js b/e2e/specs/guards-instances.js index 4f66ca0a..6b9db9ca 100644 --- a/e2e/specs/guards-instances.js +++ b/e2e/specs/guards-instances.js @@ -247,9 +247,39 @@ module.exports = { /** @type {import('nightwatch').NightwatchTest} */ 'guards + instances + named views': function (browser) { browser - .url('http://localhost:8080/guards-instances/') + .url('http://localhost:8080/guards-instances/named-one') .waitForElementPresent('#app > *', 1000) + browser + .click('li:nth-child(1) a') + .expect.element('#logs') + .text.to.equal( + [ + `One: enter / - /named-one`, + `Aux: enter / - /named-one`, + `One: leave /named-one - /`, + `Aux: leave /named-one - /`, + `One: setup:leave /named-one - /`, + `Aux: setup:leave /named-one - /`, + ].join('\n') + ) + + browser + .click('li:nth-child(9) a') + .click('#resetLogs') + .click('li:nth-child(10) a') + .expect.element('#logs') + .text.to.equal( + [ + `One: leave /named-one - /named-two`, + `Aux: leave /named-one - /named-two`, + `One: setup:leave /named-one - /named-two`, + `Aux: setup:leave /named-one - /named-two`, + `Two: enter /named-one - /named-two`, + `Aux: enter /named-one - /named-two`, + ].join('\n') + ) + browser.end() }, }