Skip to content

Commit 70692c3

Browse files
committed
test: test out-in nested transitions
1 parent e37e530 commit 70692c3

File tree

2 files changed

+51
-5
lines changed

2 files changed

+51
-5
lines changed

e2e/specs/transitions.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,20 @@ module.exports = {
5151

5252
.end()
5353
},
54+
55+
'out in transitions': function (browser) {
56+
browser
57+
.url('http://localhost:8080/transitions/')
58+
.waitForElementPresent('#app > *', 1000)
59+
.click('#toggle-transition')
60+
61+
.click('li:nth-child(7) a')
62+
.assert.containsText('.nested-view', 'foo')
63+
.click('li:nth-child(1) a')
64+
.waitForElementPresent('.view.home', 1000)
65+
.click('li:nth-child(7) a')
66+
.assert.containsText('.nested-view', 'foo')
67+
68+
.end()
69+
},
5470
}

e2e/transitions/index.ts

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { createRouter, createWebHistory, useRoute } from '../../src'
1+
import { createRouter, createWebHistory } from '../../src'
22
import { RouteComponent } from '../../src/types'
3-
import { createApp, nextTick } from 'vue'
3+
import { createApp, defineComponent, nextTick, ref } from 'vue'
44

55
const Home: RouteComponent = {
66
template: `
@@ -56,6 +56,16 @@ const Parent: RouteComponent = {
5656
`,
5757
}
5858

59+
const NestedTransition = defineComponent({
60+
template: `
61+
<router-view class="nested-view" mode="out-in" v-slot="{ Component }">
62+
<transition name="none">
63+
<component :is="Component" />
64+
</transition>
65+
</router-view>
66+
`,
67+
})
68+
5969
const Default: RouteComponent = {
6070
template: '<div class="default">default</div>',
6171
}
@@ -76,29 +86,49 @@ const router = createRouter({
7686
{ path: 'bar', component: Bar },
7787
],
7888
},
89+
90+
{
91+
path: '/nested',
92+
component: NestedTransition,
93+
children: [
94+
{ path: '', component: Default },
95+
{ path: 'foo', component: Foo },
96+
{ path: 'bar', component: Bar },
97+
],
98+
},
7999
],
80100
})
81101
const app = createApp({
82102
setup() {
103+
const transitionName = ref('fade')
104+
function toggleTransition() {
105+
transitionName.value = transitionName.value === 'fade' ? 'none' : 'fade'
106+
}
107+
83108
return {
84-
show: true,
85-
route: useRoute(),
109+
transitionName,
110+
toggleTransition,
86111
}
87112
},
88113

89114
template: `
90115
<div id="app">
91116
<h1>Transitions</h1>
92117
<pre>CI: ${__CI__}</pre>
118+
<button id="toggle-transition" @click="toggleTransition">Toggle Transition</button>
93119
<ul>
94120
<li><router-link to="/">/</router-link></li>
95121
<li><router-link to="/parent">/parent</router-link></li>
96122
<li><router-link to="/parent/foo">/parent/foo</router-link></li>
97123
<li><router-link to="/parent/bar">/parent/bar</router-link></li>
98124
<li><router-link to="/not-found">Not existing</router-link></li>
125+
126+
<li><router-link to="/nested">/nested</router-link></li>
127+
<li><router-link to="/nested/foo">/nested/foo</router-link></li>
128+
<li><router-link to="/nested/bar">/nested/bar</router-link></li>
99129
</ul>
100130
<router-view class="view" v-slot="{ Component }">
101-
<transition name="fade" mode="out-in">
131+
<transition :name="transitionName" mode="out-in">
102132
<component :is="Component" />
103133
</transition>
104134
</router-view>

0 commit comments

Comments
 (0)