diff --git a/tests/functional/reporting.js b/tests/functional/reporting.js index aafeb8eaf..2dfb2f808 100644 --- a/tests/functional/reporting.js +++ b/tests/functional/reporting.js @@ -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')) @@ -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'); @@ -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'); @@ -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/ 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(); + } }); });