Skip to content

Commit

Permalink
Merge pull request #498 from /issues/270/2
Browse files Browse the repository at this point in the history
Fixes #270 - tests for comments.
  • Loading branch information
Mike Taylor committed Dec 18, 2014
2 parents 91808a9 + da23628 commit 2e4ebee
Show file tree
Hide file tree
Showing 4 changed files with 114 additions and 8 deletions.
2 changes: 1 addition & 1 deletion grunt-tasks/jshint.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ module.exports = function(grunt) {
}
},
tests: [
'tests/functional/lib/*.js'
'tests/functional/*.js'
],
beforeconcat: [
'<%= jsPath %>/lib/homepage.js',
Expand Down
1 change: 1 addition & 0 deletions tests/functional.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

define([
'./functional/index',
'./functional/comments',
'./functional/issue-list',
'./functional/issues',
'./functional/reporting',
Expand Down
116 changes: 112 additions & 4 deletions tests/functional/comments.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,129 @@ define([
registerSuite({
name: 'issues',

'Comments form visible when logged in': function () {
'Comments form visible when logged in': function() {
return this.remote
.setFindTimeout(intern.config.wc.pageLoadTimeout)
.get(require.toUrl(url(100)))
.sleep(1000)
.sleep(500)
.findByCssSelector('.Comment--form').isDisplayed()
.then(function (isDisplayed) {
assert.equal(isDisplayed, true, 'Comment form visible for logged in users.');
})
.end();
},

'Comment form not visible for logged out users': function() {
return this.remote
.setFindTimeout(intern.config.wc.pageLoadTimeout)
.get(require.toUrl(url(100)))
.findByCssSelector('.wc-Navbar-section--right .wc-Navbar-link').click()
.end()
.findByCssSelector('.Comment--form')
.then(function () {
assert.fail('comment form should not be present');
}, function (err) {
assert.strictEqual(err.name, 'NoSuchElement');
return true;
})
.end()
.findByCssSelector('.wc-Navbar-section--right .wc-Navbar-link').click()
.end()
.findAllByCssSelector('.Comment--form').isDisplayed()
.sleep(500)
.findByCssSelector('.Comment--form').isDisplayed()
.then(function (isDisplayed) {
assert.equal(isDisplayed, false, 'Comment form hidden visible for logged out users.');
assert.equal(isDisplayed, true, 'Comment form visible for logged in users.');
})
.end();
},

'empty vs non-empty comment button text (open issue)': function() {
return this.remote
.setFindTimeout(intern.config.wc.pageLoadTimeout)
.get(require.toUrl(url(100)))
.sleep(500)
.findByCssSelector('button.Button:nth-child(1)').getVisibleText()
.then(function(text){
assert.equal('Close Issue', text);
assert.notEqual('Close and comment', text);
})
.end()
.findByCssSelector('textarea.Comment-text')
.type('test comment')
.end()
.sleep(500)
.findByCssSelector('button.Button:nth-child(1)').getVisibleText()
.then(function(text){
assert.equal('Close and comment', text);
assert.notEqual('Close Issue', text);
});
},

'empty vs non-empty comment button text (closed issue)': function() {
return this.remote
.setFindTimeout(intern.config.wc.pageLoadTimeout)
.get(require.toUrl(url(101)))
.sleep(500)
.findByCssSelector('button.Button:nth-child(1)').getVisibleText()
.then(function(text){
assert.equal('Reopen Issue', text);
assert.notEqual('Reopen and comment', text);
})
.end()
.findByCssSelector('textarea.Comment-text')
.type('test comment')
.end()
.sleep(500)
.findByCssSelector('button.Button:nth-child(1)').getVisibleText()
.then(function(text){
assert.equal('Reopen and comment', text);
assert.notEqual('Reopen Issue', text);
});
},

'posting a comment': function() {
var originalCommentsLength, allCommentsLength;
return this.remote
.setFindTimeout(intern.config.wc.pageLoadTimeout)
.get(require.toUrl(url(100)))
.findAllByCssSelector('.Comment:not(.Comment--form)')
.then(function(elms){
originalCommentsLength = elms.length;
})
.end()
.findByCssSelector('textarea.Comment-text')
.type('Today\'s date is ' + new Date().toDateString())
.end()
.sleep(500)
// click the comment button
.findByCssSelector('button.Button:nth-child(2)').click()
.end()
.sleep(500)
.findAllByCssSelector('.Comment:not(.Comment--form)')
.then(function(elms){
allCommentsLength = elms.length;
assert(originalCommentsLength < allCommentsLength, 'Comment was successfully left.');
});
},

'posting an empty comment fails': function() {
var originalCommentsLength, allCommentsLength;
return this.remote
.setFindTimeout(intern.config.wc.pageLoadTimeout)
.get(require.toUrl(url(100)))
.findAllByCssSelector('.Comment:not(.Comment--form)')
.then(function(elms){
originalCommentsLength = elms.length;
})
.end()
// click the comment button
.findByCssSelector('button.Button:nth-child(2)').click()
.end()
.sleep(500)
.findAllByCssSelector('.Comment:not(.Comment--form)')
.then(function(elms){
allCommentsLength = elms.length;
assert(originalCommentsLength === allCommentsLength, 'Comment was not successfully left.');
});
}

Expand Down
3 changes: 0 additions & 3 deletions tests/functional/lib/helpers.js

This file was deleted.

0 comments on commit 2e4ebee

Please sign in to comment.