Add Acceptance Tests (which found an error)
Tests for populating category and tags Added acceptance tests for populating the Username and Category through the Advanced Search UI (will work on the other fields later) Give the combo-box elements ids Add acceptance tests for the rest of the advanced search UI (except for Tags, tags are evil)
This commit is contained in:
parent
4b71fd253b
commit
a7507dad63
|
@ -1,6 +1,6 @@
|
|||
import { on, observes, default as computed } from 'ember-addons/ember-computed-decorators';
|
||||
|
||||
const REGEXP_FILTER_PREFIXES = /(user:|@|category:|#|group:|badge:|tags?:|in:|status:|posts_count:|(before|after):)/ig;
|
||||
const REGEXP_FILTER_PREFIXES = /\s?(user:|@|category:|#|group:|badge:|tags?:|in:|status:|posts_count:|(before|after):)/ig;
|
||||
|
||||
const REGEXP_USERNAME_PREFIX = /\s?(user:|@)/ig;
|
||||
const REGEXP_CATEGORY_PREFIX = /\s?(category:|#)/ig;
|
||||
|
@ -65,6 +65,9 @@ export default Em.Component.extend({
|
|||
},
|
||||
|
||||
findSearchTerm(EXPRESSION, searchTerm) {
|
||||
if (!searchTerm)
|
||||
return "";
|
||||
|
||||
const expression_location = searchTerm.search(EXPRESSION);
|
||||
if (expression_location === -1)
|
||||
return "";
|
||||
|
|
|
@ -48,13 +48,13 @@
|
|||
<div class="control-group pull-left">
|
||||
<label class="control-label" for="search-in-options">{{i18n "search.advanced.filters.label"}}</label>
|
||||
<div class="controls">
|
||||
{{combo-box valueAttribute="value" content=inOptions value=searchedTerms.in none="user.locale.any"}}
|
||||
{{combo-box id="in" valueAttribute="value" content=inOptions value=searchedTerms.in none="user.locale.any"}}
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group pull-left">
|
||||
<label class="control-label" for="search-status-options">{{i18n "search.advanced.statuses.label"}}</label>
|
||||
<div class="controls">
|
||||
{{combo-box valueAttribute="value" content=statusOptions value=searchedTerms.status none="user.locale.any"}}
|
||||
{{combo-box id="status" valueAttribute="value" content=statusOptions value=searchedTerms.status none="user.locale.any"}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -63,7 +63,7 @@
|
|||
<div class="control-group pull-left">
|
||||
<label class="control-label" for="search-post-date">{{i18n "search.advanced.post.time.label"}}</label>
|
||||
<div class="controls">
|
||||
{{combo-box valueAttribute="value" content=postTimeOptions value=searchedTerms.time.when}}
|
||||
{{combo-box id="post-time" valueAttribute="value" content=postTimeOptions value=searchedTerms.time.when}}
|
||||
{{input type="text" value=searchedTerms.time.days class="input-small" id='search-post-date'}}
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -1,5 +1,43 @@
|
|||
import { acceptance } from "helpers/qunit-helpers";
|
||||
acceptance("Search - Full Page");
|
||||
import { acceptance, waitFor } from "helpers/qunit-helpers";
|
||||
acceptance("Search - Full Page", {
|
||||
settings: {tagging_enabled: true},
|
||||
setup() {
|
||||
const response = (object) => {
|
||||
return [
|
||||
200,
|
||||
{"Content-Type": "application/json"},
|
||||
object
|
||||
];
|
||||
};
|
||||
|
||||
server.get('/tags/filter/search', () => { //eslint-disable-line
|
||||
return response({results: [{text: 'monkey', count: 1}]});
|
||||
});
|
||||
|
||||
server.get('/users/search/users', () => { //eslint-disable-line
|
||||
return response({users: [{username: "admin", name: "admin",
|
||||
avatar_template: "/letter_avatar_proxy/v2/letter/a/3ec8ea/{size}.png"}]});
|
||||
});
|
||||
|
||||
server.get('/admin/groups.json', () => { //eslint-disable-line
|
||||
return response([{id: 2, automatic: true, name: "moderators", user_count: 4, alias_level: 0,
|
||||
visible: true, automatic_membership_email_domains: null, automatic_membership_retroactive: false,
|
||||
primary_group: false, title: null, grant_trust_level: null, incoming_email: null,
|
||||
notification_level: null, has_messages: true, is_member: true, mentionable: false,
|
||||
flair_url: null, flair_bg_color: null, flair_color: null}]);
|
||||
});
|
||||
|
||||
server.get('/badges.json', () => { //eslint-disable-line
|
||||
return response({badge_types: [{id: 3, name: "Bronze", sort_order: 7}],
|
||||
badge_groupings: [{id: 1, name: "Getting Started", description: null, position: 10, system: true}],
|
||||
badges: [{id: 17, name: "Reader", description: "Read every reply in a topic with more than 100 replies",
|
||||
grant_count: 0, allow_title: false, multiple_grant: false, icon: "fa-certificate", image: null,
|
||||
listable: true, enabled: true, badge_grouping_id: 1, system: true,
|
||||
long_description: "This badge is granted the first time you read a long topic with more than 100 replies. Reading a conversation closely helps you follow the discussion, understand different viewpoints, and leads to more interesting conversations. The more you read, the better the conversation gets. As we like to say, Reading is Fundamental! :slight_smile:\n",
|
||||
slug: "reader", has_badge: false, badge_type_id: 3}]});
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
test("perform various searches", assert => {
|
||||
visit("/search");
|
||||
|
@ -9,13 +47,198 @@ test("perform various searches", assert => {
|
|||
assert.ok(find('.fps-topic').length === 0);
|
||||
});
|
||||
|
||||
fillIn('.search input', 'none');
|
||||
fillIn('.search input.full-page-search', 'none');
|
||||
click('.search .btn-primary');
|
||||
|
||||
andThen(() => assert.ok(find('.fps-topic').length === 0), 'has no results');
|
||||
|
||||
fillIn('.search input', 'posts');
|
||||
fillIn('.search input.full-page-search', 'posts');
|
||||
click('.search .btn-primary');
|
||||
|
||||
andThen(() => assert.ok(find('.fps-topic').length === 1, 'has one post'));
|
||||
});
|
||||
|
||||
test("open advanced search", assert => {
|
||||
visit("/search");
|
||||
|
||||
andThen(() => assert.ok(exists('.search .search-advanced'), 'shows advanced search panel'));
|
||||
|
||||
fillIn('.search input.full-page-search', 'none');
|
||||
click('.search-advanced h3.panel-title');
|
||||
|
||||
andThen(() => assert.ok(visible('.search-advanced .search-options'), '"search-options" is visible'));
|
||||
});
|
||||
|
||||
test("validate population of advanced search", assert => {
|
||||
visit("/search");
|
||||
fillIn('.search input.full-page-search', 'test user:admin #bug group:moderators badge:Reader tags:monkey in:likes status:open after:5 posts_count:10');
|
||||
click('.search-advanced h3.panel-title');
|
||||
|
||||
andThen(() => {
|
||||
assert.ok(exists('.search-options span:contains("admin")'), 'has "admin" pre-populated');
|
||||
assert.ok(exists('.search-options .category-combobox .select2-choice .select2-chosen:contains("bug")'), 'has "bug" pre-populated');
|
||||
assert.ok(exists('.search-options span:contains("moderators")'), 'has "moderators" pre-populated');
|
||||
assert.ok(exists('.search-options span:contains("Reader")'), 'has "Reader" pre-populated');
|
||||
assert.ok(exists('.search-options .tag-chooser .tag-monkey'), 'has "monkey" pre-populated');
|
||||
assert.ok(exists('.search-options .combobox .select2-choice .select2-chosen:contains("I liked")'), 'has "I liked" pre-populated');
|
||||
assert.ok(exists('.search-options .combobox .select2-choice .select2-chosen:contains("are open")'), 'has "are open" pre-populated');
|
||||
assert.ok(exists('.search-options .combobox .select2-choice .select2-chosen:contains("after")'), 'has "after" pre-populated');
|
||||
assert.equal(find('.search-options #search-post-date').val(), "5", 'has "5" pre-populated');
|
||||
assert.equal(find('.search-options #search-posts-count').val(), "10", 'has "10" pre-populated');
|
||||
});
|
||||
});
|
||||
|
||||
test("update username through advanced search ui", assert => {
|
||||
visit("/search");
|
||||
fillIn('.search input.full-page-search', 'none');
|
||||
click('.search-advanced h3.panel-title');
|
||||
fillIn('.search-options .user-selector', 'admin');
|
||||
click('.search-options .user-selector');
|
||||
keyEvent('.search-options .user-selector', 'keydown', 8);
|
||||
|
||||
andThen(() => {
|
||||
waitFor(() => {
|
||||
assert.ok(visible('.search-options .autocomplete'), '"autocomplete" popup is visible');
|
||||
assert.ok(exists('.search-options .autocomplete ul li a span.username:contains("admin")'), '"autocomplete" popup has an entry for "admin"');
|
||||
|
||||
click('.search-options .autocomplete ul li a:first');
|
||||
|
||||
andThen(() => {
|
||||
assert.ok(exists('.search-options span:contains("admin")'), 'has "admin" pre-populated');
|
||||
assert.equal(find('.search input.full-page-search').val(), "none user:admin", 'has updated search term to "none user:admin"');
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
test("update category through advanced search ui", assert => {
|
||||
visit("/search");
|
||||
fillIn('.search input.full-page-search', 'none');
|
||||
click('.search-advanced h3.panel-title');
|
||||
selectDropdown('.search-options .category-combobox', 4);
|
||||
click('.search-options'); // need to click off the combobox for the search-term to get updated
|
||||
|
||||
andThen(() => {
|
||||
assert.ok(exists('.search-options .category-combobox .select2-choice .select2-chosen:contains("faq")'), 'has "faq" populated');
|
||||
assert.equal(find('.search input.full-page-search').val(), "none #faq", 'has updated search term to "none #faq"');
|
||||
});
|
||||
});
|
||||
|
||||
test("update group through advanced search ui", assert => {
|
||||
visit("/search");
|
||||
fillIn('.search input.full-page-search', 'none');
|
||||
click('.search-advanced h3.panel-title');
|
||||
fillIn('.search-options .group-selector', 'moderators');
|
||||
click('.search-options .group-selector');
|
||||
keyEvent('.search-options .group-selector', 'keydown', 8);
|
||||
|
||||
andThen(() => {
|
||||
waitFor(() => {
|
||||
assert.ok(visible('.search-options .autocomplete'), '"autocomplete" popup is visible');
|
||||
assert.ok(exists('.search-options .autocomplete ul li a:contains("moderators")'), '"autocomplete" popup has an entry for "moderators"');
|
||||
|
||||
click('.search-options .autocomplete ul li a:first');
|
||||
|
||||
andThen(() => {
|
||||
assert.ok(exists('.search-options span:contains("moderators")'), 'has "moderators" pre-populated');
|
||||
assert.equal(find('.search input.full-page-search').val(), "none group:moderators", 'has updated search term to "none group:moderators"');
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
test("update badges through advanced search ui", assert => {
|
||||
visit("/search");
|
||||
fillIn('.search input.full-page-search', 'none');
|
||||
click('.search-advanced h3.panel-title');
|
||||
fillIn('.search-options .badge-names', 'Reader');
|
||||
click('.search-options .badge-names');
|
||||
keyEvent('.search-options .badge-names', 'keydown', 8);
|
||||
|
||||
andThen(() => {
|
||||
waitFor(() => {
|
||||
assert.ok(visible('.search-options .autocomplete'), '"autocomplete" popup is visible');
|
||||
assert.ok(exists('.search-options .autocomplete ul li a:contains("Reader")'), '"autocomplete" popup has an entry for "Reader"');
|
||||
|
||||
click('.search-options .autocomplete ul li a:first');
|
||||
|
||||
andThen(() => {
|
||||
assert.ok(exists('.search-options span:contains("Reader")'), 'has "Reader" pre-populated');
|
||||
assert.equal(find('.search input.full-page-search').val(), "none badge:Reader", 'has updated search term to "none badge:Reader"');
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// test("update tags through advanced search ui", assert => {
|
||||
// visit("/search");
|
||||
// fillIn('.search input.full-page-search', 'none');
|
||||
// click('.search-advanced h3.panel-title');
|
||||
//
|
||||
// keyEvent('.search-options .tag-chooser input.select2-input', 'keydown', 110);
|
||||
// fillIn('.search-options .tag-chooser input.select2-input', 'monkey');
|
||||
// keyEvent('.search-options .tag-chooser input.select2-input', 'keyup', 110);
|
||||
//
|
||||
// andThen(() => {
|
||||
// waitFor(() => {
|
||||
// click('li.select2-result-selectable:first');
|
||||
// andThen(() => {
|
||||
// assert.ok(exists('.search-options .tag-chooser .tag-monkey'), 'has "monkey" pre-populated');
|
||||
// assert.equal(find('.search input.full-page-search').val(), "none tags:monkey", 'has updated search term to "none tags:monkey"');
|
||||
// });
|
||||
// });
|
||||
// });
|
||||
// });
|
||||
|
||||
test("update in filter through advanced search ui", assert => {
|
||||
visit("/search");
|
||||
fillIn('.search input.full-page-search', 'none');
|
||||
click('.search-advanced h3.panel-title');
|
||||
selectDropdown('.search-options #s2id_in', 'likes');
|
||||
fillIn('.search-options #in', 'likes');
|
||||
|
||||
andThen(() => {
|
||||
assert.ok(exists('.search-options #s2id_in .select2-choice .select2-chosen:contains("I liked")'), 'has "I liked" populated');
|
||||
assert.equal(find('.search input.full-page-search').val(), "none in:likes", 'has updated search term to "none in:likes"');
|
||||
});
|
||||
});
|
||||
|
||||
test("update status through advanced search ui", assert => {
|
||||
visit("/search");
|
||||
fillIn('.search input.full-page-search', 'none');
|
||||
click('.search-advanced h3.panel-title');
|
||||
selectDropdown('.search-options #s2id_status', 'closed');
|
||||
fillIn('.search-options #status', 'closed');
|
||||
|
||||
andThen(() => {
|
||||
assert.ok(exists('.search-options #s2id_status .select2-choice .select2-chosen:contains("are closed")'), 'has "are closed" populated');
|
||||
assert.equal(find('.search input.full-page-search').val(), "none status:closed", 'has updated search term to "none status:closed"');
|
||||
});
|
||||
});
|
||||
|
||||
test("update post time through advanced search ui", assert => {
|
||||
visit("/search");
|
||||
fillIn('.search input.full-page-search', 'none');
|
||||
click('.search-advanced h3.panel-title');
|
||||
fillIn('#search-post-date', '5');
|
||||
selectDropdown('.search-options #s2id_postTime', 'after');
|
||||
fillIn('.search-options #postTime', 'after');
|
||||
|
||||
andThen(() => {
|
||||
assert.ok(exists('.search-options #s2id_postTime .select2-choice .select2-chosen:contains("after")'), 'has "after" populated');
|
||||
assert.equal(find('.search-options #search-post-date').val(), "5", 'has "5" populated');
|
||||
assert.equal(find('.search input.full-page-search').val(), "none after:5", 'has updated search term to "none after:5"');
|
||||
});
|
||||
});
|
||||
|
||||
test("update posts count through advanced search ui", assert => {
|
||||
visit("/search");
|
||||
fillIn('.search input.full-page-search', 'none');
|
||||
click('.search-advanced h3.panel-title');
|
||||
fillIn('#search-posts-count', '5');
|
||||
|
||||
andThen(() => {
|
||||
assert.equal(find('.search-options #search-posts-count').val(), "5", 'has "5" populated');
|
||||
assert.equal(find('.search input.full-page-search').val(), "none posts_count:5", 'has updated search term to "none posts_count:5"');
|
||||
});
|
||||
});
|
||||
|
|
|
@ -109,6 +109,15 @@ function blank(obj, text) {
|
|||
ok(Ember.isEmpty(obj), text);
|
||||
}
|
||||
|
||||
function waitFor(callback, timeout) {
|
||||
timeout = timeout || 500;
|
||||
stop();
|
||||
Ember.run.later(() => {
|
||||
callback();
|
||||
start();
|
||||
}, timeout);
|
||||
}
|
||||
|
||||
export { acceptance,
|
||||
controllerFor,
|
||||
asyncTestDiscourse,
|
||||
|
@ -116,4 +125,5 @@ export { acceptance,
|
|||
logIn,
|
||||
currentUser,
|
||||
blank,
|
||||
present };
|
||||
present,
|
||||
waitFor };
|
||||
|
|
Loading…
Reference in New Issue