Skip to content

Commit 1f92b08

Browse files
committed
add auth-flow test
1 parent 19dab36 commit 1f92b08

File tree

2 files changed

+61
-1
lines changed

2 files changed

+61
-1
lines changed

examples/auth-flow/components/Login.vue

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<label><input v-model="email" placeholder="email"></label>
99
<label><input v-model="pass" placeholder="password" type="password"></label> (hint: password1)<br>
1010
<button type="submit">login</button>
11-
<p v-if="error" style="color:red">Bad login information</p>
11+
<p v-if="error" class="error">Bad login information</p>
1212
</form>
1313
</div>
1414
</template>
@@ -37,3 +37,9 @@ export default {
3737
}
3838
}
3939
</script>
40+
41+
<style>
42+
.error {
43+
color: red;
44+
}
45+
</style>

test/e2e/specs/auth-flow.js

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
module.exports = {
2+
'auth flow': function (browser) {
3+
browser
4+
.url('http://localhost:8080/auth-flow/')
5+
.waitForElementVisible('#app', 1000)
6+
.assert.containsText('#app p', 'You are logged out')
7+
8+
.click('li:nth-child(3) a')
9+
.assert.urlEquals('http://localhost:8080/auth-flow/login?redirect=%2Fdashboard')
10+
.assert.containsText('#app h2', 'Login')
11+
.assert.containsText('#app p', 'You need to login first.')
12+
13+
.click('button')
14+
.assert.urlEquals('http://localhost:8080/auth-flow/login?redirect=%2Fdashboard')
15+
.assert.elementPresent('.error')
16+
17+
.setValue('input[type=password]', 'password1')
18+
.click('button')
19+
.assert.urlEquals('http://localhost:8080/auth-flow/dashboard')
20+
.assert.containsText('#app h2', 'Dashboard')
21+
.assert.containsText('#app p', 'Yay you made it!')
22+
23+
// reload
24+
.url('http://localhost:8080/auth-flow/')
25+
.waitForElementVisible('#app', 1000)
26+
.assert.containsText('#app p', 'You are logged in')
27+
28+
// navigate when logged in
29+
.click('li:nth-child(3) a')
30+
.assert.urlEquals('http://localhost:8080/auth-flow/dashboard')
31+
.assert.containsText('#app h2', 'Dashboard')
32+
.assert.containsText('#app p', 'Yay you made it!')
33+
34+
// directly visit dashboard when logged in
35+
.url('http://localhost:8080/auth-flow/dashboard')
36+
.waitForElementVisible('#app', 1000)
37+
.assert.urlEquals('http://localhost:8080/auth-flow/dashboard')
38+
.assert.containsText('#app h2', 'Dashboard')
39+
.assert.containsText('#app p', 'Yay you made it!')
40+
41+
// log out
42+
.click('li:nth-child(1) a')
43+
.assert.urlEquals('http://localhost:8080/auth-flow/')
44+
.assert.containsText('#app p', 'You are logged out')
45+
46+
// directly visit dashboard when logged out
47+
.url('http://localhost:8080/auth-flow/dashboard')
48+
.waitForElementVisible('#app', 1000)
49+
.assert.urlEquals('http://localhost:8080/auth-flow/login?redirect=%2Fdashboard')
50+
.assert.containsText('#app h2', 'Login')
51+
.assert.containsText('#app p', 'You need to login first.')
52+
.end()
53+
}
54+
}

0 commit comments

Comments
 (0)