Skip to content

Commit

Permalink
Issue #24: Split up form validation tests and add one for valid images.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mike Taylor committed Aug 18, 2015
1 parent fa895e1 commit c1c70eb
Showing 1 changed file with 67 additions and 54 deletions.
121 changes: 67 additions & 54 deletions tests/functional/reporting.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ define([
.sleep(2000);
},

'validation works': function() {
'URL validation': function() {
return this.remote
.setFindTimeout(intern.config.wc.pageLoadTimeout)
.get(require.toUrl(url + '?open=1'))
Expand All @@ -78,8 +78,8 @@ define([
.end()
.findByCssSelector('#url').click()
.end()
// wait a second
.sleep(1000)
// wait a bit
.sleep(100)
.findByXpath('//*[@id="new-report"]/div/form/div[1]/div[2]/div[1]').getAttribute('class')
.then(function (className) {
assert.include(className, 'js-form-error');
Expand All @@ -88,20 +88,25 @@ define([
.end()
.findByCssSelector('#url').type('sup')
.end()
// wait a second
.sleep(1000)
// wait a bit
.sleep(100)
// xpath to the #url formGroup
.findByXpath('//*[@id="new-report"]/div/form/div[1]/div[2]/div[1]').getAttribute('class')
.then(function (className) {
assert.include(className, 'js-no-error');
assert.notInclude(className, 'js-form-error');
})
.end()
// click in the textarea to trigger validation for radios
.end();
},

'Problem type validation': function() {
return this.remote
.setFindTimeout(intern.config.wc.pageLoadTimeout)
.get(require.toUrl(url + '?open=1'))
.findByCssSelector('#description').click()
.end()
// wait a second
.sleep(1000)
// wait a bit
.sleep(100)
.findByXpath('//*[@id="new-report"]/div/form/div[1]/div[1]/fieldset').getAttribute('class')
.then(function (className) {
assert.include(className, 'js-form-error');
Expand All @@ -111,65 +116,73 @@ define([
// pick a problem type
.findByCssSelector('#problem_category-0').click()
.end()
// wait a second
.sleep(1000)
// wait a bit
.sleep(100)
// validation message should be removed now
.findByXpath('//*[@id="new-report"]/div/form/div[1]/div[1]/fieldset').getAttribute('class')
.then(function (className) {
assert.include(className, 'js-no-error');
assert.notInclude(className, 'js-form-error');
})
.end();
},

'Image extension validation': function() {
return this.remote
.setFindTimeout(intern.config.wc.pageLoadTimeout)
.get(require.toUrl(url + '?open=1'))
.findByCssSelector('#image').type('/path/to/foo.hacks')
.end()
// wait a bit
.sleep(100)
.findByXpath('//*[@id="new-report"]/div/form/div[2]/div[2]').getAttribute('class')
.then(function (className) {
assert.include(className, 'js-form-error');
assert.notInclude(className, 'js-no-error');
})
.end()
// pick a valid file type
.findByCssSelector('#image').type('/path/to/foo.jpg')
.end()
// wait a bit
.sleep(100)
// validation message should be removed now
.findByXpath('//*[@id="new-report"]/div/form/div[2]/div[2]').getAttribute('class')
.then(function (className) {
assert.include(className, 'js-no-error');
assert.notInclude(className, 'js-form-error');
})
.end();
},

'Submits are enabled': function() {
return this.remote
.setFindTimeout(intern.config.wc.pageLoadTimeout)
.get(require.toUrl(url + '?open=1'))
// pick a valid file type
.findByCssSelector('#image').type('/path/to/foo.png')
.end()
// now make sure the buttons aren't disabled anymore
.findByCssSelector('#url').type('http://coolguy.biz')
.end()
// pick a problem type
.findByCssSelector('#problem_category-0').click()
.end()
.findByCssSelector('#description').click()
.end()
// wait a bit
.sleep(100)
// now make sure the buttons aren't disabled anymore
.findByCssSelector('#submitanon').getAttribute('class')
.then(function (className) {
assert.notInclude(className, 'is-disabled');
})
.end()
// now make sure the buttons aren't disabled anymore
.findByCssSelector('#submitgithub').getAttribute('class')
.then(function (className) {
assert.notInclude(className, 'is-disabled');
});
},

// 'anonymous report': function () {
// var issueNumber;

// return this.remote
// .setFindTimeout(intern.config.wc.pageLoadTimeout)
// .get(require.toUrl(url + "?open=1"))
// .findByCssSelector('#url').type('some broken URL')
// .end()
// .findByCssSelector('#summary').type('this site doesnt work ' + Math.random())
// .end()
// .findByCssSelector('#submitanon').click()
// .end()
// .findByCssSelector('.wc-content--body h2').getVisibleText()
// .then(function (text) {
// // Make sure we got to the /thanks/<number> route
// assert.equal(text, 'Thank you.');
// })
// .end()
// .findByCssSelector('.wc-content--body a').getVisibleText()
// .then(function (text) {
// // Grab the issue number from the end of the URL link
// issueNumber = text.split('/').pop();
// })
// .end()
// .findByCssSelector('.wc-content--body a').getVisibleText().click()
// .end()
// .findByCssSelector('.js-issue-title').getVisibleText()
// .then(function (text) {
// // Make sure GitHub has the correct title
// assert.include(text, 'some broken URL - this site doesnt work');
// })
// .end()
// .findByCssSelector('.gh-header-number').getVisibleText()
// .then(function (text) {
// // Make sure GitHub has the correct issue number
// assert.equal(text, '#' + issueNumber);
// })
// }

})
.end();
}
});
});

0 comments on commit c1c70eb

Please sign in to comment.