Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Issue #563. Add tests for non-authed search.
  • Loading branch information
Mike Taylor committed Oct 1, 2015
commit 949d5f7ed9fc1e167541ad2be471d5b5095e9628
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ define([
};

registerSuite({
name: 'issue-list',
name: 'search (auth)',

setup: function () {
return this.remote
Expand Down
81 changes: 81 additions & 0 deletions tests/functional/search-non-auth.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

define([
'intern',
'intern!object',
'intern/chai!assert',
'require'
], function (intern, registerSuite, assert, require) {
'use strict';

var url = function (path) {
return intern.config.siteRoot + path;
};

registerSuite({
name: 'search (non-auth)',

'Pressing g inside of search input *doesnt* go to github issues': function() {
return this.remote
// set a short timeout, so we don't have to wait 10 seconds
// to realize we're not at GitHub.
.setFindTimeout(50)
.get(require.toUrl(url('/issues')))
.findByCssSelector('#IssueList-search-input').click()
.type('g')
.end()
.findByCssSelector('.repo-container .issues-listing')
.then(assert.fail, function(err) {
assert.isTrue(/NoSuchElement/.test(String(err)));
})
.end();
},

'Results are loaded from the query params': function() {
var params = '?q=vladvlad';
return this.remote
.setFindTimeout(intern.config.wc.pageLoadTimeout)
.get(require.toUrl(url('/issues') + params))
.findByCssSelector('.wc-IssueItem:nth-of-type(1) a').getVisibleText()
.then(function(text){
assert.include(text, 'vladvlad', 'The search query results show up on the page.');
})
.end()
.getCurrentUrl()
.then(function(currUrl){
assert.include(currUrl, 'q=vladvlad', 'Our params didn\'t go anywhere.');
})
.end();
},

'Search input is visible': function() {
return this.remote
.get(require.toUrl(url('/issues')))
.findByCssSelector('.js-issuelist-search').isDisplayed()
.then(function (isDisplayed) {
assert.equal(isDisplayed, true, 'Search input is visible for non-authed users.');
})
.end();
},

'Search works': function() {
return this.remote
.setFindTimeout(intern.config.wc.pageLoadTimeout)
.get(require.toUrl(url('/issues')))
.findByCssSelector('.js-issuelist-search input')
.type('vladvlad')
.end()
.findByCssSelector('.js-issuelist-search button').click()
.end()
// this is lame, but we gotta wait on search results.
.sleep(3000)
.findByCssSelector('.wc-IssueItem:nth-of-type(1) a').getVisibleText()
.then(function(text){
assert.include(text, 'vladvlad', 'The search results show up on the page.');
})
.end();
}
});
});