Skip to content

Commit 70d9be6

Browse files
committed
implement e2e tests of login and register
1 parent 13600c4 commit 70d9be6

File tree

14 files changed

+238
-11
lines changed

14 files changed

+238
-11
lines changed

front-end/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ node_modules
33
/dist
44

55
/tests/e2e/reports/
6+
/tests/e2e/data/user.js
67
selenium-debug.log
78

89
# local env files

front-end/nightwatch.config.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
module.exports = {
2+
test_settings: {
3+
default: {
4+
launch_url: (process.env.LAUNCH_URL || process.env.VUE_DEV_SERVER_URL)
5+
},
6+
chrome: {
7+
desiredCapabilities: {
8+
browserName: "chrome",
9+
chromeOptions: {
10+
args: ["headless", "no-sandbox", "disable-gpu"]
11+
}
12+
}
13+
}
14+
},
15+
page_objects_path: 'tests/e2e/page-objects',
16+
}

front-end/package-lock.json

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

front-end/package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"lint": "vue-cli-service lint",
99
"test:unit": "vue-cli-service test:unit",
1010
"test:e2e": "vue-cli-service test:e2e",
11+
"test:integration": "vue-cli-service test:e2e --url http://localhost:8080/",
1112
"test": "npm run test:unit && npm run test:e2e"
1213
},
1314
"dependencies": {
@@ -30,8 +31,11 @@
3031
"@vue/test-utils": "^1.0.0-beta.24",
3132
"babel-core": "7.0.0-bridge.0",
3233
"babel-jest": "^23.0.1",
34+
"chance": "^1.0.16",
35+
"del": "^3.0.0",
3336
"moxios": "^0.4.0",
3437
"node-sass": "^4.9.0",
38+
"rw": "^1.3.3",
3539
"sass-loader": "^7.0.1",
3640
"vue-template-compiler": "^2.5.17"
3741
}

front-end/src/router.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import Vue from 'vue'
22
import Router from 'vue-router'
3+
import HomePage from '@/views/HomePage'
34
import LoginPage from '@/views/LoginPage'
45
import RegisterPage from '@/views/RegisterPage'
56

@@ -9,6 +10,10 @@ export default new Router({
910
mode: 'history',
1011
base: process.env.BASE_URL,
1112
routes: [{
13+
path: '/',
14+
name: 'HomePage',
15+
component: HomePage
16+
}, {
1217
path: '/login',
1318
name: 'LoginPage',
1419
component: LoginPage

front-end/src/views/HomePage.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template>
2-
<div>Home Page</div>
2+
<div><h1 class="page-title">Home Page</h1></div>
33
</template>
44

55
<script>

front-end/tests/e2e/data/.gitkeep

Whitespace-only changes.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
module.exports = {
2+
url: function () {
3+
return this.api.launchUrl
4+
},
5+
elements: {
6+
pageTitle: {
7+
selector: 'h1.page-title'
8+
}
9+
}
10+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
module.exports = {
2+
url: function () {
3+
return this.api.launchUrl + 'login'
4+
},
5+
elements: {
6+
app: '#app',
7+
logoImage: 'img.logo',
8+
usernameInput: '#username',
9+
passwordInput: '#password',
10+
submitButton: 'button[type=submit]',
11+
formError: '.failed'
12+
},
13+
commands: [{
14+
login: function (username, password) {
15+
this
16+
.setValue('@usernameInput', username)
17+
.setValue('@passwordInput', password)
18+
.click('@submitButton')
19+
}
20+
}]
21+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
module.exports = {
2+
url: function () {
3+
return this.api.launchUrl + 'register'
4+
},
5+
elements: {
6+
app: {
7+
selector: '#app'
8+
},
9+
logoImage: {
10+
selector: 'img.logo'
11+
},
12+
usernameInput: {
13+
selector: '#username'
14+
},
15+
emailAddressInput: {
16+
selector: '#emailAddress'
17+
},
18+
passwordInput: {
19+
selector: '#password'
20+
},
21+
submitButton: {
22+
selector: 'button[type=submit]'
23+
},
24+
formError: {
25+
selector: '.failed'
26+
}
27+
},
28+
commands: [{
29+
register: function (username, emailAddress, password) {
30+
this
31+
.setValue('@usernameInput', username)
32+
.setValue('@emailAddressInput', emailAddress)
33+
.setValue('@passwordInput', password)
34+
.click('@submitButton')
35+
}
36+
}]
37+
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy