Skip to content

Commit 1918aa0

Browse files
committed
e2e tests
1 parent 343dc4f commit 1918aa0

File tree

2 files changed

+102
-4
lines changed

2 files changed

+102
-4
lines changed

build/nightwatch.local.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"src_folders" : ["test/e2e"],
3-
"output_folder": "/dev/null",
3+
"output_folder": "coverage/e2e",
44

55
"selenium" : {
66
"start_process" : true,

test/e2e/test.js

Lines changed: 101 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,106 @@
1+
/* global router */
2+
3+
var base = 'http://localhost:8080'
4+
15
module.exports = {
2-
'Basic test': function (browser) {
6+
'vue-router e2e tests': function (browser) {
37
browser
4-
.url('http://localhost:8080/about')
5-
.waitForElementVisible('.view h2', 1000)
8+
// default 404
9+
.url(base)
10+
.waitForElementVisible('h1', 1000)
11+
.assert.containsText('.view', 'FOUR OH FOUR')
12+
13+
// /about
14+
.url(base + '/about')
15+
.waitForElementVisible('h1', 1000)
16+
.assert.containsText('.view h2', 'ABOUT US')
17+
.assert.cssClassPresent('a[href="/about"]', 'v-link-active')
18+
.assert.cssClassPresent('a[href="/about"]', 'v-link-active-exact')
19+
// should not be able to navigate to inbox
20+
.click('a[href^="/inbox"]')
21+
.pause(100)
22+
.getAlertText(function (text) {
23+
this.assert.ok(/navigate/.test(text.value))
24+
})
25+
.acceptAlert()
26+
// should not have changed
27+
.assert.containsText('.view h2', 'ABOUT US')
28+
.assert.cssClassPresent('a[href="/about"]', 'v-link-active')
29+
.assert.cssClassPresent('a[href="/about"]', 'v-link-active-exact')
30+
31+
// /user
32+
.url(base + '/user/1234/profile/what')
33+
.waitForElementVisible('h1', 1000)
34+
.assert.containsText('.view h2', 'User yo')
35+
.assert.containsText('.view h3', 'user profile')
36+
.assert.containsText('.view p', '1234 what')
37+
.assert.cssClassPresent('a[href^="/user"]', 'v-link-active')
38+
.assert.cssClassPresent('a[href^="/user"]', 'v-link-active-exact')
39+
// change params
40+
.execute(function () {
41+
router.go('/user/2345/profile/hey')
42+
})
43+
.assert.containsText('.view p', '2345 hey')
44+
// other routes
45+
.execute(function () {
46+
router.go('/user/2345/posts')
47+
})
48+
.assert.containsText('.view h3', 'user posts')
49+
.execute(function () {
50+
router.go('settings')
51+
})
52+
.assert.containsText('.view div', 'user settings')
53+
54+
// inbox
55+
.url(base + '/inbox')
56+
.waitForElementVisible('h1', 1000)
57+
.assert.elementNotPresent('.view h2')
58+
// wait for inbox's activation hook
59+
.pause(600)
60+
.assert.containsText('.view h2', 'inbox!')
61+
.assert.containsText('.view', 'default yo')
62+
63+
.url(base + '/inbox/message/123')
64+
.waitForElementVisible('h1', 1000)
65+
.assert.elementNotPresent('.view h2')
66+
.pause(600)
67+
.assert.containsText('.view h2', 'inbox!')
68+
.assert.containsText('.view div', 'Loading data')
69+
.pause(600)
70+
.assert.containsText('.view div', 'message #123: Hello this is a message')
71+
// confirm navigation
72+
.click('a[href^="/user"]')
73+
.pause(100)
74+
.getAlertText(function (text) {
75+
this.assert.ok(/Are you sure/.test(text.value))
76+
})
77+
// cancel navigation
78+
.dismissAlert()
79+
// wait for possible transition
80+
.pause(1000)
81+
.assert.containsText('.view div', 'message #123: Hello this is a message')
82+
// then do it again
83+
.click('a[href^="/about"]')
84+
.pause(100)
85+
.acceptAlert()
86+
.pause(1000)
87+
.assert.containsText('.view h2', 'ABOUT US')
88+
89+
// forbidden
90+
.url(base + '/forbidden')
91+
.waitForElementVisible('h1', 1000)
92+
.assert.visible('#app > p')
93+
.assert.containsText('#app > p', 'Authenticating')
94+
.pause(600)
95+
.getAlertText(function (text) {
96+
this.assert.ok(/forbidden by a global before hook/.test(text.value))
97+
})
98+
.acceptAlert()
99+
.assert.hidden('#app > p')
100+
101+
// redirect
102+
.url(base + '/info')
103+
.waitForElementVisible('h1', 1000)
6104
.assert.containsText('.view h2', 'ABOUT US')
7105
.assert.cssClassPresent('a[href="/about"]', 'v-link-active')
8106
.assert.cssClassPresent('a[href="/about"]', 'v-link-active-exact')

0 commit comments

Comments
 (0)