Skip to content
This repository has been archived by the owner on Dec 25, 2017. It is now read-only.

Commit

Permalink
💚 test(nightwatch): add e2e tests [ci skip]
Browse files Browse the repository at this point in the history
  • Loading branch information
kazupon committed Dec 12, 2016
1 parent fe87aa2 commit 193fbcd
Show file tree
Hide file tree
Showing 9 changed files with 110 additions and 13 deletions.
7 changes: 4 additions & 3 deletions examples/touch/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,18 @@
@focusin="$refs.validity.validate()"
@focusout="$refs.validity.touch()">
</validity>
<p class="touch" v-if="validation.result.touched">Touch!!</p>
<div class="errors">
<p v-if="validation.result.required">required username!!</p>
<p v-if="validation.result.minlength">too short username!!</p>
<p class="required" v-if="validation.result.required">required username!!</p>
<p class="minlength" v-if="validation.result.minlength">too short username!!</p>
</div>
<div class="result">
<p>validation result:</p>
<pre>{{validation.result}}</pre>
</div>
</div>
<script>
new Vue({
var vm = new Vue({
data: {
validation: {
result: {}
Expand Down
8 changes: 4 additions & 4 deletions examples/validation/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@
</div>
<input type="submit" value="send" v-if="valid">
<div class="errors">
<p v-if="usernameInvalid">Invalid yourname inputting !!</p>
<p v-if="passwordInvalid">Invalid password inputting !!</p>
<p v-if="confirmInvalid">Invalid confirm password inputting !!</p>
<p class="username-invalid" v-if="usernameInvalid">Invalid yourname inputting !!</p>
<p class="password-invalid" v-if="passwordInvalid">Invalid password inputting !!</p>
<p class="confirm-invalid" v-if="confirmInvalid">Invalid confirm password inputting !!</p>
</div>
<div class="debug">
<p>validation result info</p>
Expand All @@ -48,7 +48,7 @@
</validation>
</div>
<script>
new Vue({
var vm = new Vue({
// The validation result of validity component (instance) wrapped
// with validation component is managed it.
// Also, You can map the these validation result to computed properties
Expand Down
4 changes: 2 additions & 2 deletions examples/validity/event/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
<input type="text" @input="handleValidate" @focusout="handleValidate">
</validity>
<div class="errors">
<p v-if="result.required">required username!!</p>
<p v-if="result.minlength">too short username!!</p>
<p class="required" v-if="result.required">required username!!</p>
<p class="minlength" v-if="result.minlength">too short username!!</p>
</div>
</div>
<script>
Expand Down
4 changes: 2 additions & 2 deletions examples/validity/ref/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
<input type="text" @input="handleValidate" @focusout="handleValidate">
</validity>
<div class="errors">
<p v-if="result.required">required username!!</p>
<p v-if="result.minlength">too short username!!</p>
<p class="required" v-if="result.required">required username!!</p>
<p class="minlength" v-if="result.minlength">too short username!!</p>
</div>
</div>
<script>
Expand Down
29 changes: 29 additions & 0 deletions test/e2e/test/touch.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
module.exports = {
touch: function (browser) {
browser
.url('http://localhost:8080/examples/touch/')
// initial loaded
.waitForElementVisible('#app', 1000)
.waitForElementNotPresent('.errors .required', 1000)
.waitForElementNotPresent('.errors .minlength', 1000)
// minlength invalid
.setValue('input', 'foo')
.trigger('input', 'input')
.waitForElementNotPresent('.errors .required', 1000)
.waitForElementPresent('.errors .minlength', 1000)
// and required invalid
.clearValue('input')
.trigger('input', 'input')
.waitForElementPresent('.errors .required', 1000)
.waitForElementPresent('.errors .minlength', 1000)
// valid !!
.setValue('input', 'kazupon')
.trigger('input', 'input')
.waitForElementNotPresent('.errors .required', 1000)
.waitForElementNotPresent('.errors .minlength', 1000)
// manully touch
.moveToElement('.errors', 5, 5).mouseButtonClick() // focusout
.waitForElementPresent('.touch', 1000)
.end()
}
}
41 changes: 41 additions & 0 deletions test/e2e/test/validation.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
module.exports = {
validation: function (browser) {
browser
.url('http://localhost:8080/examples/validation/')
// initial loaded
.waitForElementVisible('#app', 1000)
.waitForElementNotPresent('.errors .username-invalid', 1000)
.waitForElementNotPresent('.errors .password-invalid', 1000)
.waitForElementNotPresent('.errors .confirm-invalid', 1000)
.waitForElementPresent('input[type="submit"]', 1000)
// input valid username
.enterValue('#username', 'kazupon')
.waitForElementNotPresent('.errors .username-invalid', 1000)
.waitForElementPresent('input[type="submit"]', 1000)
// input invalid username
.enterBackSpace('#username', 7)
.waitForElementPresent('.errors .username-invalid', 1000)
.waitForElementNotPresent('input[type="submit"]', 1000)

.enterValue('#username', 'kazupon')
.waitForElementPresent('input[type="submit"]', 1000)

// input invalid password
.enterValue('#password', 'test')
.waitForElementPresent('.errors .password-invalid', 1000)
.waitForElementNotPresent('input[type="submit"]', 1000)
// input valid password
.enterValue('#password', 'testtest')
.waitForElementNotPresent('.errors .password-invalid', 1000)
.waitForElementPresent('input[type="submit"]', 1000)
// input invalid confirm
.enterValue('#confirm', 'test')
.waitForElementPresent('.errors .confirm-invalid', 1000)
.waitForElementNotPresent('input[type="submit"]', 1000)
// input valid comfirm
.enterValue('#confirm', 'testtest')
.waitForElementNotPresent('.errors .confirm-invalid', 1000)
.waitForElementPresent('input[type="submit"]', 1000)
.end()
}
}
2 changes: 1 addition & 1 deletion test/e2e/test/validity_event.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module.exports = {
started: function (browser) {
validity_event: function (browser) {
browser
.url('http://localhost:8080/examples/validity/event/')
// initial loaded
Expand Down
26 changes: 26 additions & 0 deletions test/e2e/test/validity_model.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
module.exports = {
validity_model: function (browser) {
browser
.url('http://localhost:8080/examples/validity/model/')
// initial loaded
.waitForElementVisible('#app', 1000)
.waitForElementNotPresent('.errors .required', 1000)
.waitForElementNotPresent('.errors .minlength', 1000)
// minlength invalid
.setValue('input', 'foo')
.trigger('input', 'input')
.waitForElementNotPresent('.errors .required', 1000)
.waitForElementPresent('.errors .minlength', 1000)
// and required invalid
.clearValue('input')
.trigger('input', 'input')
.waitForElementPresent('.errors .required', 1000)
.waitForElementPresent('.errors .minlength', 1000)
// valid !!
.setValue('input', 'kazupon')
.trigger('input', 'input')
.waitForElementNotPresent('.errors .required', 1000)
.waitForElementNotPresent('.errors .minlength', 1000)
.end()
}
}
2 changes: 1 addition & 1 deletion test/e2e/test/validity_ref.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module.exports = {
started: function (browser) {
validity_ref: function (browser) {
browser
.url('http://localhost:8080/examples/validity/ref/')
// initial loaded
Expand Down

0 comments on commit 193fbcd

Please sign in to comment.