Commit ce9d3ee5 authored by Clement Ho's avatar Clement Ho

Backend review

parent 044a195b
......@@ -22,7 +22,8 @@ require('../window')(function(w){
debounceTrigger: function debounceTrigger(e) {
var NON_CHARACTER_KEYS = [16, 17, 18, 20, 37, 38, 39, 40, 91, 93];
var invalidKeyPressed = NON_CHARACTER_KEYS.indexOf(e.detail.which || e.detail.keyCode) > -1;
var focusEvent = false;
var focusEvent = e.type === 'focus';
if (invalidKeyPressed || this.loading) {
return;
}
......@@ -31,10 +32,6 @@ require('../window')(function(w){
clearTimeout(this.timeout);
}
if (e.type === 'focus') {
focusEvent = true;
}
this.timeout = setTimeout(this.trigger.bind(this, focusEvent), 200);
},
......@@ -66,7 +63,7 @@ require('../window')(function(w){
searchValue = '';
}
if (searchValue === config.searchKey) {
if (config.searchKey === searchValue) {
return this.list.show();
}
......
......@@ -39,26 +39,31 @@ describe 'Dropdown assignee', js: true, feature: true do
describe 'behavior' do
it 'opens when the search bar has assignee:' do
filtered_search.set('assignee:')
expect(page).to have_css(js_dropdown_assignee, visible: true)
end
it 'closes when the search bar is unfocused' do
find('body').click()
expect(page).to have_css(js_dropdown_assignee, visible: false)
end
it 'should show loading indicator when opened' do
filtered_search.set('assignee:')
expect(page).to have_css('#js-dropdown-assignee .filter-dropdown-loading', visible: true)
end
it 'should hide loading indicator when loaded' do
send_keys_to_filtered_search('assignee:')
expect(page).not_to have_css('#js-dropdown-assignee .filter-dropdown-loading')
end
it 'should load all the assignees when opened' do
send_keys_to_filtered_search('assignee:')
expect(dropdown_assignee_size).to eq(3)
end
end
......@@ -70,31 +75,37 @@ describe 'Dropdown assignee', js: true, feature: true do
it 'filters by name' do
send_keys_to_filtered_search('j')
expect(dropdown_assignee_size).to eq(2)
end
it 'filters by case insensitive name' do
send_keys_to_filtered_search('J')
expect(dropdown_assignee_size).to eq(2)
end
it 'filters by username with symbol' do
send_keys_to_filtered_search('@ot')
expect(dropdown_assignee_size).to eq(2)
end
it 'filters by case insensitive username with symbol' do
send_keys_to_filtered_search('@OT')
expect(dropdown_assignee_size).to eq(2)
end
it 'filters by username without symbol' do
send_keys_to_filtered_search('ot')
expect(dropdown_assignee_size).to eq(2)
end
it 'filters by case insensitive username without symbol' do
send_keys_to_filtered_search('OT')
expect(dropdown_assignee_size).to eq(2)
end
end
......@@ -106,6 +117,7 @@ describe 'Dropdown assignee', js: true, feature: true do
it 'fills in the assignee username when the assignee has not been filtered' do
click_assignee(user_jacob.name)
expect(page).to have_css(js_dropdown_assignee, visible: false)
expect(filtered_search.value).to eq("assignee:@#{user_jacob.username}")
end
......@@ -113,12 +125,14 @@ describe 'Dropdown assignee', js: true, feature: true do
it 'fills in the assignee username when the assignee has been filtered' do
send_keys_to_filtered_search('roo')
click_assignee(user.name)
expect(page).to have_css(js_dropdown_assignee, visible: false)
expect(filtered_search.value).to eq("assignee:@#{user.username}")
end
it 'selects `no assignee`' do
find('#js-dropdown-assignee .filter-dropdown-item', text: 'No Assignee').click
expect(page).to have_css(js_dropdown_assignee, visible: false)
expect(filtered_search.value).to eq("assignee:none")
end
......@@ -127,21 +141,25 @@ describe 'Dropdown assignee', js: true, feature: true do
describe 'input has existing content' do
it 'opens assignee dropdown with existing search term' do
filtered_search.set('searchTerm assignee:')
expect(page).to have_css(js_dropdown_assignee, visible: true)
end
it 'opens assignee dropdown with existing author' do
filtered_search.set('author:@user assignee:')
expect(page).to have_css(js_dropdown_assignee, visible: true)
end
it 'opens assignee dropdown with existing label' do
filtered_search.set('label:~bug assignee:')
expect(page).to have_css(js_dropdown_assignee, visible: true)
end
it 'opens assignee dropdown with existing milestone' do
filtered_search.set('milestone:%v1.0 assignee:')
expect(page).to have_css(js_dropdown_assignee, visible: true)
end
end
......
......@@ -39,26 +39,31 @@ describe 'Dropdown author', js: true, feature: true do
describe 'behavior' do
it 'opens when the search bar has author:' do
filtered_search.set('author:')
expect(page).to have_css(js_dropdown_author, visible: true)
end
it 'closes when the search bar is unfocused' do
find('body').click()
expect(page).to have_css(js_dropdown_author, visible: false)
end
it 'should show loading indicator when opened' do
filtered_search.set('author:')
expect(page).to have_css('#js-dropdown-author .filter-dropdown-loading', visible: true)
end
it 'should hide loading indicator when loaded' do
send_keys_to_filtered_search('author:')
expect(page).not_to have_css('#js-dropdown-author .filter-dropdown-loading')
end
it 'should load all the authors when opened' do
send_keys_to_filtered_search('author:')
expect(dropdown_author_size).to eq(3)
end
end
......@@ -71,26 +76,31 @@ describe 'Dropdown author', js: true, feature: true do
it 'filters by name' do
send_keys_to_filtered_search('ja')
expect(dropdown_author_size).to eq(1)
end
it 'filters by case insensitive name' do
send_keys_to_filtered_search('Ja')
expect(dropdown_author_size).to eq(1)
end
it 'filters by username with symbol' do
send_keys_to_filtered_search('@ot')
expect(dropdown_author_size).to eq(2)
end
it 'filters by username without symbol' do
send_keys_to_filtered_search('ot')
expect(dropdown_author_size).to eq(2)
end
it 'filters by case insensitive username without symbol' do
send_keys_to_filtered_search('OT')
expect(dropdown_author_size).to eq(2)
end
end
......@@ -103,12 +113,14 @@ describe 'Dropdown author', js: true, feature: true do
it 'fills in the author username when the author has not been filtered' do
click_author(user_jacob.name)
expect(page).to have_css(js_dropdown_author, visible: false)
expect(filtered_search.value).to eq("author:@#{user_jacob.username}")
end
it 'fills in the author username when the author has been filtered' do
click_author(user.name)
expect(page).to have_css(js_dropdown_author, visible: false)
expect(filtered_search.value).to eq("author:@#{user.username}")
end
......@@ -117,21 +129,25 @@ describe 'Dropdown author', js: true, feature: true do
describe 'input has existing content' do
it 'opens author dropdown with existing search term' do
filtered_search.set('searchTerm author:')
expect(page).to have_css(js_dropdown_author, visible: true)
end
it 'opens author dropdown with existing assignee' do
filtered_search.set('assignee:@user author:')
expect(page).to have_css(js_dropdown_author, visible: true)
end
it 'opens author dropdown with existing label' do
filtered_search.set('label:~bug author:')
expect(page).to have_css(js_dropdown_author, visible: true)
end
it 'opens author dropdown with existing milestone' do
filtered_search.set('milestone:%v1.0 author:')
expect(page).to have_css(js_dropdown_author, visible: true)
end
end
......
......@@ -36,6 +36,7 @@ describe 'Dropdown hint', js: true, feature: true do
it 'closes when the search bar is unfocused' do
find('body').click
expect(page).to have_css(js_dropdown_hint, visible: false)
end
end
......@@ -43,12 +44,14 @@ describe 'Dropdown hint', js: true, feature: true do
describe 'filtering' do
it 'does not filter `Keep typing and press Enter`' do
filtered_search.set('randomtext')
expect(page).to have_css(js_dropdown_hint, text: 'Keep typing and press Enter', visible: false)
expect(dropdown_hint_size).to eq(0)
end
it 'filters with text' do
filtered_search.set('a')
expect(dropdown_hint_size).to eq(3)
end
end
......@@ -60,6 +63,7 @@ describe 'Dropdown hint', js: true, feature: true do
it 'opens the author dropdown when you click on author' do
click_hint('author')
expect(page).to have_css(js_dropdown_hint, visible: false)
expect(page).to have_css('#js-dropdown-author', visible: true)
expect(filtered_search.value).to eq('author:')
......@@ -67,6 +71,7 @@ describe 'Dropdown hint', js: true, feature: true do
it 'opens the assignee dropdown when you click on assignee' do
click_hint('assignee')
expect(page).to have_css(js_dropdown_hint, visible: false)
expect(page).to have_css('#js-dropdown-assignee', visible: true)
expect(filtered_search.value).to eq('assignee:')
......@@ -74,6 +79,7 @@ describe 'Dropdown hint', js: true, feature: true do
it 'opens the milestone dropdown when you click on milestone' do
click_hint('milestone')
expect(page).to have_css(js_dropdown_hint, visible: false)
expect(page).to have_css('#js-dropdown-milestone', visible: true)
expect(filtered_search.value).to eq('milestone:')
......@@ -81,6 +87,7 @@ describe 'Dropdown hint', js: true, feature: true do
it 'opens the label dropdown when you click on label' do
click_hint('label')
expect(page).to have_css(js_dropdown_hint, visible: false)
expect(page).to have_css('#js-dropdown-label', visible: true)
expect(filtered_search.value).to eq('label:')
......@@ -91,6 +98,7 @@ describe 'Dropdown hint', js: true, feature: true do
it 'opens the author dropdown when you click on author' do
filtered_search.set('auth')
click_hint('author')
expect(page).to have_css(js_dropdown_hint, visible: false)
expect(page).to have_css('#js-dropdown-author', visible: true)
expect(filtered_search.value).to eq('author:')
......@@ -99,6 +107,7 @@ describe 'Dropdown hint', js: true, feature: true do
it 'opens the assignee dropdown when you click on assignee' do
filtered_search.set('assign')
click_hint('assignee')
expect(page).to have_css(js_dropdown_hint, visible: false)
expect(page).to have_css('#js-dropdown-assignee', visible: true)
expect(filtered_search.value).to eq('assignee:')
......@@ -107,6 +116,7 @@ describe 'Dropdown hint', js: true, feature: true do
it 'opens the milestone dropdown when you click on milestone' do
filtered_search.set('mile')
click_hint('milestone')
expect(page).to have_css(js_dropdown_hint, visible: false)
expect(page).to have_css('#js-dropdown-milestone', visible: true)
expect(filtered_search.value).to eq('milestone:')
......@@ -115,6 +125,7 @@ describe 'Dropdown hint', js: true, feature: true do
it 'opens the label dropdown when you click on label' do
filtered_search.set('lab')
click_hint('label')
expect(page).to have_css(js_dropdown_hint, visible: false)
expect(page).to have_css('#js-dropdown-label', visible: true)
expect(filtered_search.value).to eq('label:')
......
......@@ -43,26 +43,31 @@ describe 'Dropdown label', js: true, feature: true do
describe 'behavior' do
it 'opens when the search bar has label:' do
filtered_search.set('label:')
expect(page).to have_css(js_dropdown_label, visible: true)
end
it 'closes when the search bar is unfocused' do
find('body').click()
expect(page).to have_css(js_dropdown_label, visible: false)
end
it 'should show loading indicator when opened' do
filtered_search.set('label:')
expect(page).to have_css('#js-dropdown-label .filter-dropdown-loading', visible: true)
end
it 'should hide loading indicator when loaded' do
send_keys_to_filtered_search('label:')
expect(page).not_to have_css('#js-dropdown-label .filter-dropdown-loading')
end
it 'should load all the labels when opened' do
send_keys_to_filtered_search('label:')
expect(dropdown_label_size).to be > 0
end
end
......@@ -74,61 +79,73 @@ describe 'Dropdown label', js: true, feature: true do
it 'filters by name' do
send_keys_to_filtered_search(':b')
expect(dropdown_label_size).to eq(2)
end
it 'filters by case insensitive name' do
send_keys_to_filtered_search(':B')
expect(dropdown_label_size).to eq(2)
end
it 'filters by name with symbol' do
send_keys_to_filtered_search(':~bu')
expect(dropdown_label_size).to eq(2)
end
it 'filters by case insensitive name with symbol' do
send_keys_to_filtered_search(':~BU')
expect(dropdown_label_size).to eq(2)
end
it 'filters by multiple words' do
send_keys_to_filtered_search(':Hig')
expect(dropdown_label_size).to eq(1)
end
it 'filters by multiple words with symbol' do
send_keys_to_filtered_search(':~Hig')
expect(dropdown_label_size).to eq(1)
end
it 'filters by multiple words containing single quotes' do
send_keys_to_filtered_search(':won\'t')
expect(dropdown_label_size).to eq(1)
end
it 'filters by multiple words containing single quotes with symbol' do
send_keys_to_filtered_search(':~won\'t')
expect(dropdown_label_size).to eq(1)
end
it 'filters by multiple words containing double quotes' do
send_keys_to_filtered_search(':won"t')
expect(dropdown_label_size).to eq(1)
end
it 'filters by multiple words containing double quotes with symbol' do
send_keys_to_filtered_search(':~won"t')
expect(dropdown_label_size).to eq(1)
end
it 'filters by special characters' do
send_keys_to_filtered_search(':^+')
expect(dropdown_label_size).to eq(1)
end
it 'filters by special characters with symbol' do
send_keys_to_filtered_search(':~^+')
expect(dropdown_label_size).to eq(1)
end
end
......@@ -140,6 +157,7 @@ describe 'Dropdown label', js: true, feature: true do
it 'fills in the label name when the label has not been filled' do
click_label(bug_label.title)
expect(page).to have_css(js_dropdown_label, visible: false)
expect(filtered_search.value).to eq("label:~#{bug_label.title}")
end
......@@ -147,42 +165,49 @@ describe 'Dropdown label', js: true, feature: true do
it 'fills in the label name when the label is partially filled' do
send_keys_to_filtered_search('bu')
click_label(bug_label.title)
expect(page).to have_css(js_dropdown_label, visible: false)
expect(filtered_search.value).to eq("label:~#{bug_label.title}")
end
it 'fills in the label name that contains multiple words' do
click_label(two_words_label.title)
expect(page).to have_css(js_dropdown_label, visible: false)
expect(filtered_search.value).to eq("label:~\"#{two_words_label.title}\"")
end
it 'fills in the label name that contains multiple words and is very long' do
click_label(long_label.title)
expect(page).to have_css(js_dropdown_label, visible: false)
expect(filtered_search.value).to eq("label:~\"#{long_label.title}\"")
end
it 'fills in the label name that contains double quotes' do
click_label(wont_fix_label.title)
expect(page).to have_css(js_dropdown_label, visible: false)
expect(filtered_search.value).to eq("label:~'#{wont_fix_label.title}'")
end
it 'fills in the label name with the correct capitalization' do
click_label(uppercase_label.title)
expect(page).to have_css(js_dropdown_label, visible: false)
expect(filtered_search.value).to eq("label:~#{uppercase_label.title}")
end
it 'fills in the label name with special characters' do
click_label(special_label.title)
expect(page).to have_css(js_dropdown_label, visible: false)
expect(filtered_search.value).to eq("label:~#{special_label.title}")
end
it 'selects `no label`' do
find('#js-dropdown-label .filter-dropdown-item', text: 'No Label').click
expect(page).to have_css(js_dropdown_label, visible: false)
expect(filtered_search.value).to eq("label:none")
end
......
......@@ -47,26 +47,31 @@ describe 'Dropdown milestone', js: true, feature: true do
describe 'behavior' do
it 'opens when the search bar has milestone:' do
filtered_search.set('milestone:')
expect(page).to have_css(js_dropdown_milestone, visible: true)
end
it 'closes when the search bar is unfocused' do
find('body').click()
expect(page).to have_css(js_dropdown_milestone, visible: false)
end
it 'should show loading indicator when opened' do
filtered_search.set('milestone:')
expect(page).to have_css('#js-dropdown-milestone .filter-dropdown-loading', visible: true)
end
it 'should hide loading indicator when loaded' do
send_keys_to_filtered_search('milestone:')
expect(page).not_to have_css('#js-dropdown-milestone .filter-dropdown-loading')
end
it 'should load all the milestones when opened' do
send_keys_to_filtered_search('milestone:')
expect(dropdown_milestone_size).to be > 0
end
end
......@@ -78,31 +83,37 @@ describe 'Dropdown milestone', js: true, feature: true do
it 'filters by name' do
send_keys_to_filtered_search(':v1')
expect(dropdown_milestone_size).to eq(1)
end
it 'filters by case insensitive name' do
send_keys_to_filtered_search(':V1')
expect(dropdown_milestone_size).to eq(1)
end
it 'filters by name with symbol' do
send_keys_to_filtered_search(':%v1')
expect(dropdown_milestone_size).to eq(1)
end
it 'filters by case insensitive name with symbol' do
send_keys_to_filtered_search(':%V1')
expect(dropdown_milestone_size).to eq(1)
end
it 'filters by special characters' do
send_keys_to_filtered_search(':(+')
expect(dropdown_milestone_size).to eq(1)
end
it 'filters by special characters with symbol' do
send_keys_to_filtered_search(':%(+')
expect(dropdown_milestone_size).to eq(1)
end
end
......@@ -114,6 +125,7 @@ describe 'Dropdown milestone', js: true, feature: true do
it 'fills in the milestone name when the milestone has not been filled' do
click_milestone(milestone.title)
expect(page).to have_css(js_dropdown_milestone, visible: false)
expect(filtered_search.value).to eq("milestone:%#{milestone.title}")
end
......@@ -121,48 +133,56 @@ describe 'Dropdown milestone', js: true, feature: true do
it 'fills in the milestone name when the milestone is partially filled' do
send_keys_to_filtered_search('v')
click_milestone(milestone.title)
expect(page).to have_css(js_dropdown_milestone, visible: false)
expect(filtered_search.value).to eq("milestone:%#{milestone.title}")
end
it 'fills in the milestone name that contains multiple words' do
click_milestone(two_words_milestone.title)
expect(page).to have_css(js_dropdown_milestone, visible: false)
expect(filtered_search.value).to eq("milestone:%\"#{two_words_milestone.title}\"")
end
it 'fills in the milestone name that contains multiple words and is very long' do
click_milestone(long_milestone.title)
expect(page).to have_css(js_dropdown_milestone, visible: false)
expect(filtered_search.value).to eq("milestone:%\"#{long_milestone.title}\"")
end
it 'fills in the milestone name that contains double quotes' do
click_milestone(wont_fix_milestone.title)
expect(page).to have_css(js_dropdown_milestone, visible: false)
expect(filtered_search.value).to eq("milestone:%'#{wont_fix_milestone.title}'")
end
it 'fills in the milestone name with the correct capitalization' do
click_milestone(uppercase_milestone.title)
expect(page).to have_css(js_dropdown_milestone, visible: false)
expect(filtered_search.value).to eq("milestone:%#{uppercase_milestone.title}")
end
it 'fills in the milestone name with special characters' do
click_milestone(special_milestone.title)
expect(page).to have_css(js_dropdown_milestone, visible: false)
expect(filtered_search.value).to eq("milestone:%#{special_milestone.title}")
end
it 'selects `no milestone`' do
click_static_milestone('No Milestone')
expect(page).to have_css(js_dropdown_milestone, visible: false)
expect(filtered_search.value).to eq("milestone:none")
end
it 'selects `upcoming milestone`' do
click_static_milestone('Upcoming')
expect(page).to have_css(js_dropdown_milestone, visible: false)
expect(filtered_search.value).to eq("milestone:upcoming")
end
......@@ -171,26 +191,31 @@ describe 'Dropdown milestone', js: true, feature: true do
describe 'input has existing content' do
it 'opens milestone dropdown with existing search term' do
filtered_search.set('searchTerm milestone:')
expect(page).to have_css(js_dropdown_milestone, visible: true)
end
it 'opens milestone dropdown with existing author' do
filtered_search.set('author:@john milestone:')
expect(page).to have_css(js_dropdown_milestone, visible: true)
end
it 'opens milestone dropdown with existing assignee' do
filtered_search.set('assignee:@john milestone:')
expect(page).to have_css(js_dropdown_milestone, visible: true)
end
it 'opens milestone dropdown with existing label' do
filtered_search.set('label:~important milestone:')
expect(page).to have_css(js_dropdown_milestone, visible: true)
end
it 'opens milestone dropdown with existing milestone' do
filtered_search.set('milestone:%100 milestone:')
expect(page).to have_css(js_dropdown_milestone, visible: true)
end
end
......
......@@ -101,15 +101,18 @@ describe 'Filter issues', js: true, feature: true do
context 'only author' do
it 'filters issues by searched author' do
input_filtered_search("author:@#{user.username}")
expect_issues_list_count(5)
end
it 'filters issues by invalid author' do
# YOLO
pending('to be tested, issue #26546')
fail
end
it 'filters issues by multiple authors' do
# YOLO
pending('to be tested, issue #26546')
fail
end
end
......@@ -117,6 +120,7 @@ describe 'Filter issues', js: true, feature: true do
it 'filters issues by searched author and text' do
search = "author:@#{user.username} issue"
input_filtered_search(search)
expect_issues_list_count(3)
expect_filtered_search_input(search)
end
......@@ -124,6 +128,7 @@ describe 'Filter issues', js: true, feature: true do
it 'filters issues by searched author, assignee and text' do
search = "author:@#{user.username} assignee:@#{user.username} issue"
input_filtered_search(search)
expect_issues_list_count(3)
expect_filtered_search_input(search)
end
......@@ -131,6 +136,7 @@ describe 'Filter issues', js: true, feature: true do
it 'filters issues by searched author, assignee, label, and text' do
search = "author:@#{user.username} assignee:@#{user.username} label:~#{caps_sensitive_label.title} issue"
input_filtered_search(search)
expect_issues_list_count(1)
expect_filtered_search_input(search)
end
......@@ -138,13 +144,15 @@ describe 'Filter issues', js: true, feature: true do
it 'filters issues by searched author, assignee, label, milestone and text' do
search = "author:@#{user.username} assignee:@#{user.username} label:~#{caps_sensitive_label.title} milestone:%#{milestone.title} issue"
input_filtered_search(search)
expect_issues_list_count(1)
expect_filtered_search_input(search)
end
end
context 'sorting' do
# TODO
it 'sorting' do
pending('to be tested, issue #26546')
fail
end
end
......@@ -153,6 +161,7 @@ describe 'Filter issues', js: true, feature: true do
it 'filters issues by searched assignee' do
search = "assignee:@#{user.username}"
input_filtered_search(search)
expect_issues_list_count(5)
expect_filtered_search_input(search)
end
......@@ -160,16 +169,19 @@ describe 'Filter issues', js: true, feature: true do
it 'filters issues by no assignee' do
search = "assignee:none"
input_filtered_search(search)
expect_issues_list_count(8, 1)
expect_filtered_search_input(search)
end
it 'filters issues by invalid assignee' do
# YOLO
pending('to be tested, issue #26546')
fail
end
it 'filters issues by multiple assignees' do
# YOLO
pending('to be tested, issue #26546')
fail
end
end
......@@ -177,6 +189,7 @@ describe 'Filter issues', js: true, feature: true do
it 'filters issues by searched assignee and text' do
search = "assignee:@#{user.username} searchTerm"
input_filtered_search(search)
expect_issues_list_count(2)
expect_filtered_search_input(search)
end
......@@ -184,6 +197,7 @@ describe 'Filter issues', js: true, feature: true do
it 'filters issues by searched assignee, author and text' do
search = "assignee:@#{user.username} author:@#{user.username} searchTerm"
input_filtered_search(search)
expect_issues_list_count(2)
expect_filtered_search_input(search)
end
......@@ -191,6 +205,7 @@ describe 'Filter issues', js: true, feature: true do
it 'filters issues by searched assignee, author, label, text' do
search = "assignee:@#{user.username} author:@#{user.username} label:~#{caps_sensitive_label.title} searchTerm"
input_filtered_search(search)
expect_issues_list_count(1)
expect_filtered_search_input(search)
end
......@@ -198,13 +213,17 @@ describe 'Filter issues', js: true, feature: true do
it 'filters issues by searched assignee, author, label, milestone and text' do
search = "assignee:@#{user.username} author:@#{user.username} label:~#{caps_sensitive_label.title} milestone:%#{milestone.title} searchTerm"
input_filtered_search(search)
expect_issues_list_count(1)
expect_filtered_search_input(search)
end
end
context 'sorting' do
# TODO
it 'sorts' do
pending('to be tested, issue #26546')
fail
end
end
end
......@@ -213,6 +232,7 @@ describe 'Filter issues', js: true, feature: true do
it 'filters issues by searched label' do
search = "label:~#{bug_label.title}"
input_filtered_search(search)
expect_issues_list_count(2)
expect_filtered_search_input(search)
end
......@@ -220,17 +240,20 @@ describe 'Filter issues', js: true, feature: true do
it 'filters issues by no label' do
search = "label:none"
input_filtered_search(search)
expect_issues_list_count(9, 1)
expect_filtered_search_input(search)
end
it 'filters issues by invalid label' do
# YOLO
pending('to be tested, issue #26546')
fail
end
it 'filters issues by multiple labels' do
search = "label:~#{bug_label.title} label:~#{caps_sensitive_label.title}"
input_filtered_search(search)
expect_issues_list_count(1)
expect_filtered_search_input(search)
end
......@@ -242,6 +265,7 @@ describe 'Filter issues', js: true, feature: true do
search = "label:~#{special_label.title}"
input_filtered_search(search)
expect_issues_list_count(1)
expect_filtered_search_input(search)
end
......@@ -251,6 +275,7 @@ describe 'Filter issues', js: true, feature: true do
search = "label:~#{new_label.title}"
input_filtered_search(search)
expect_no_issues_list()
expect_filtered_search_input(search)
end
......@@ -264,6 +289,7 @@ describe 'Filter issues', js: true, feature: true do
search = "label:~'#{special_multiple_label.title}'"
input_filtered_search(search)
expect_issues_list_count(1)
# filtered search defaults quotations to double quotes
......@@ -273,14 +299,15 @@ describe 'Filter issues', js: true, feature: true do
it 'single quotes' do
search = "label:~'#{multiple_words_label.title}'"
input_filtered_search(search)
expect_issues_list_count(1)
expect_issues_list_count(1)
expect_filtered_search_input("label:~\"#{multiple_words_label.title}\"")
end
it 'double quotes' do
search = "label:~\"#{multiple_words_label.title}\""
input_filtered_search(search)
expect_issues_list_count(1)
expect_filtered_search_input(search)
end
......@@ -292,6 +319,7 @@ describe 'Filter issues', js: true, feature: true do
search = "label:~'#{double_quotes_label.title}'"
input_filtered_search(search)
expect_issues_list_count(1)
expect_filtered_search_input(search)
end
......@@ -303,6 +331,7 @@ describe 'Filter issues', js: true, feature: true do
search = "label:~\"#{single_quotes_label.title}\""
input_filtered_search(search)
expect_issues_list_count(1)
expect_filtered_search_input(search)
end
......@@ -312,6 +341,7 @@ describe 'Filter issues', js: true, feature: true do
it 'filters issues by searched label and text' do
search = "label:~#{caps_sensitive_label.title} bug"
input_filtered_search(search)
expect_issues_list_count(1)
expect_filtered_search_input(search)
end
......@@ -319,6 +349,7 @@ describe 'Filter issues', js: true, feature: true do
it 'filters issues by searched label, author and text' do
search = "label:~#{caps_sensitive_label.title} author:@#{user.username} bug"
input_filtered_search(search)
expect_issues_list_count(1)
expect_filtered_search_input(search)
end
......@@ -326,6 +357,7 @@ describe 'Filter issues', js: true, feature: true do
it 'filters issues by searched label, author, assignee and text' do
search = "label:~#{caps_sensitive_label.title} author:@#{user.username} assignee:@#{user.username} bug"
input_filtered_search(search)
expect_issues_list_count(1)
expect_filtered_search_input(search)
end
......@@ -333,6 +365,7 @@ describe 'Filter issues', js: true, feature: true do
it 'filters issues by searched label, author, assignee, milestone and text' do
search = "label:~#{caps_sensitive_label.title} author:@#{user.username} assignee:@#{user.username} milestone:%#{milestone.title} bug"
input_filtered_search(search)
expect_issues_list_count(1)
expect_filtered_search_input(search)
end
......@@ -342,6 +375,7 @@ describe 'Filter issues', js: true, feature: true do
it 'filters issues by searched label, label2, and text' do
search = "label:~#{bug_label.title} label:~#{caps_sensitive_label.title} bug"
input_filtered_search(search)
expect_issues_list_count(1)
expect_filtered_search_input(search)
end
......@@ -349,6 +383,7 @@ describe 'Filter issues', js: true, feature: true do
it 'filters issues by searched label, label2, author and text' do
search = "label:~#{bug_label.title} label:~#{caps_sensitive_label.title} author:@#{user.username} bug"
input_filtered_search(search)
expect_issues_list_count(1)
expect_filtered_search_input(search)
end
......@@ -356,6 +391,7 @@ describe 'Filter issues', js: true, feature: true do
it 'filters issues by searched label, label2, author, assignee and text' do
search = "label:~#{bug_label.title} label:~#{caps_sensitive_label.title} author:@#{user.username} assignee:@#{user.username} bug"
input_filtered_search(search)
expect_issues_list_count(1)
expect_filtered_search_input(search)
end
......@@ -363,6 +399,7 @@ describe 'Filter issues', js: true, feature: true do
it 'filters issues by searched label, label2, author, assignee, milestone and text' do
search = "label:~#{bug_label.title} label:~#{caps_sensitive_label.title} author:@#{user.username} assignee:@#{user.username} milestone:%#{milestone.title} bug"
input_filtered_search(search)
expect_issues_list_count(1)
expect_filtered_search_input(search)
end
......@@ -384,7 +421,10 @@ describe 'Filter issues', js: true, feature: true do
end
context 'sorting' do
# TODO
it 'sorts' do
pending('to be tested, issue #26546')
fail
end
end
end
......@@ -392,25 +432,30 @@ describe 'Filter issues', js: true, feature: true do
context 'only milestone' do
it 'filters issues by searched milestone' do
input_filtered_search("milestone:%#{milestone.title}")
expect_issues_list_count(5)
end
it 'filters issues by no milestone' do
input_filtered_search("milestone:none")
expect_issues_list_count(7, 1)
end
it 'filters issues by upcoming milestones' do
input_filtered_search("milestone:upcoming")
expect_issues_list_count(1)
end
it 'filters issues by invalid milestones' do
# YOLO
pending('to be tested, issue #26546')
fail
end
it 'filters issues by multiple milestones' do
# YOLO
pending('to be tested, issue #26546')
fail
end
it 'filters issues by milestone containing special characters' do
......@@ -419,6 +464,7 @@ describe 'Filter issues', js: true, feature: true do
search = "milestone:%#{special_milestone.title}"
input_filtered_search(search)
expect_issues_list_count(1)
expect_filtered_search_input(search)
end
......@@ -428,6 +474,7 @@ describe 'Filter issues', js: true, feature: true do
search = "milestone:%#{new_milestone.title}"
input_filtered_search(search)
expect_no_issues_list()
expect_filtered_search_input(search)
end
......@@ -437,6 +484,7 @@ describe 'Filter issues', js: true, feature: true do
it 'filters issues by searched milestone and text' do
search = "milestone:%#{milestone.title} bug"
input_filtered_search(search)
expect_issues_list_count(2)
expect_filtered_search_input(search)
end
......@@ -444,6 +492,7 @@ describe 'Filter issues', js: true, feature: true do
it 'filters issues by searched milestone, author and text' do
search = "milestone:%#{milestone.title} author:@#{user.username} bug"
input_filtered_search(search)
expect_issues_list_count(2)
expect_filtered_search_input(search)
end
......@@ -451,6 +500,7 @@ describe 'Filter issues', js: true, feature: true do
it 'filters issues by searched milestone, author, assignee and text' do
search = "milestone:%#{milestone.title} author:@#{user.username} assignee:@#{user.username} bug"
input_filtered_search(search)
expect_issues_list_count(2)
expect_filtered_search_input(search)
end
......@@ -458,13 +508,17 @@ describe 'Filter issues', js: true, feature: true do
it 'filters issues by searched milestone, author, assignee, label and text' do
search = "milestone:%#{milestone.title} author:@#{user.username} assignee:@#{user.username} label:~#{bug_label.title} bug"
input_filtered_search(search)
expect_issues_list_count(2)
expect_filtered_search_input(search)
end
end
context 'sorting' do
# TODO
it 'sorts' do
pending('to be tested, issue #26546')
fail
end
end
end
......@@ -473,6 +527,7 @@ describe 'Filter issues', js: true, feature: true do
it 'filters issues by searched text' do
search = 'Bug'
input_filtered_search(search)
expect_issues_list_count(4, 1)
expect_filtered_search_input(search)
end
......@@ -480,6 +535,7 @@ describe 'Filter issues', js: true, feature: true do
it 'filters issues by multiple searched text' do
search = 'Bug report'
input_filtered_search(search)
expect_issues_list_count(3)
expect_filtered_search_input(search)
end
......@@ -487,6 +543,7 @@ describe 'Filter issues', js: true, feature: true do
it 'filters issues by case insensitive searched text' do
search = 'bug report'
input_filtered_search(search)
expect_issues_list_count(3)
expect_filtered_search_input(search)
end
......@@ -494,6 +551,7 @@ describe 'Filter issues', js: true, feature: true do
it 'filters issues by searched text containing single quotes' do
search = '\'single quotes\''
input_filtered_search(search)
expect_issues_list_count(1)
expect_filtered_search_input(search)
end
......@@ -501,6 +559,7 @@ describe 'Filter issues', js: true, feature: true do
it 'filters issues by searched text containing double quotes' do
search = '"double quotes"'
input_filtered_search(search)
expect_issues_list_count(1)
expect_filtered_search_input(search)
end
......@@ -508,6 +567,7 @@ describe 'Filter issues', js: true, feature: true do
it 'filters issues by searched text containing special characters' do
search = '!@#{$%^&*()-+'
input_filtered_search(search)
expect_issues_list_count(1)
expect_filtered_search_input(search)
end
......@@ -515,6 +575,7 @@ describe 'Filter issues', js: true, feature: true do
it 'does not show any issues' do
search = 'testing'
input_filtered_search(search)
expect_no_issues_list()
expect_filtered_search_input(search)
end
......@@ -523,66 +584,77 @@ describe 'Filter issues', js: true, feature: true do
context 'searched text with other filters' do
it 'filters issues by searched text and author' do
input_filtered_search("bug author:@#{user.username}")
expect_issues_list_count(2)
expect_filtered_search_input("author:@#{user.username} bug")
end
it 'filters issues by searched text, author and more text' do
input_filtered_search("bug author:@#{user.username} report")
expect_issues_list_count(1)
expect_filtered_search_input("author:@#{user.username} bug report")
end
it 'filters issues by searched text, author and assignee' do
input_filtered_search("bug author:@#{user.username} assignee:@#{user.username}")
expect_issues_list_count(2)
expect_filtered_search_input("author:@#{user.username} assignee:@#{user.username} bug")
end
it 'filters issues by searched text, author, more text and assignee' do
input_filtered_search("bug author:@#{user.username} report assignee:@#{user.username}")
expect_issues_list_count(1)
expect_filtered_search_input("author:@#{user.username} assignee:@#{user.username} bug report")
end
it 'filters issues by searched text, author, more text, assignee and even more text' do
input_filtered_search("bug author:@#{user.username} report assignee:@#{user.username} with")
expect_issues_list_count(1)
expect_filtered_search_input("author:@#{user.username} assignee:@#{user.username} bug report with")
end
it 'filters issues by searched text, author, assignee and label' do
input_filtered_search("bug author:@#{user.username} assignee:@#{user.username} label:~#{bug_label.title}")
expect_issues_list_count(2)
expect_filtered_search_input("author:@#{user.username} assignee:@#{user.username} label:~#{bug_label.title} bug")
end
it 'filters issues by searched text, author, text, assignee, text, label and text' do
input_filtered_search("bug author:@#{user.username} report assignee:@#{user.username} with label:~#{bug_label.title} everything")
expect_issues_list_count(1)
expect_filtered_search_input("author:@#{user.username} assignee:@#{user.username} label:~#{bug_label.title} bug report with everything")
end
it 'filters issues by searched text, author, assignee, label and milestone' do
input_filtered_search("bug author:@#{user.username} assignee:@#{user.username} label:~#{bug_label.title} milestone:%#{milestone.title}")
expect_issues_list_count(2)
expect_filtered_search_input("author:@#{user.username} assignee:@#{user.username} label:~#{bug_label.title} milestone:%#{milestone.title} bug")
end
it 'filters issues by searched text, author, text, assignee, text, label, text, milestone and text' do
input_filtered_search("bug author:@#{user.username} report assignee:@#{user.username} with label:~#{bug_label.title} everything milestone:%#{milestone.title} you")
expect_issues_list_count(1)
expect_filtered_search_input("author:@#{user.username} assignee:@#{user.username} label:~#{bug_label.title} milestone:%#{milestone.title} bug report with everything you")
end
it 'filters issues by searched text, author, assignee, multiple labels and milestone' do
input_filtered_search("bug author:@#{user.username} assignee:@#{user.username} label:~#{bug_label.title} label:~#{caps_sensitive_label.title} milestone:%#{milestone.title}")
expect_issues_list_count(1)
expect_filtered_search_input("author:@#{user.username} assignee:@#{user.username} label:~#{bug_label.title} label:~#{caps_sensitive_label.title} milestone:%#{milestone.title} bug")
end
it 'filters issues by searched text, author, text, assignee, text, label1, text, label2, text, milestone and text' do
input_filtered_search("bug author:@#{user.username} report assignee:@#{user.username} with label:~#{bug_label.title} everything label:~#{caps_sensitive_label.title} you milestone:%#{milestone.title} thought")
expect_issues_list_count(1)
expect_filtered_search_input("author:@#{user.username} assignee:@#{user.username} label:~#{bug_label.title} label:~#{caps_sensitive_label.title} milestone:%#{milestone.title} bug report with everything you thought")
end
......@@ -605,6 +677,7 @@ describe 'Filter issues', js: true, feature: true do
updated_at: 5.days.ago)
input_filtered_search('days ago')
expect_issues_list_count(2)
sort_toggle = find('.filtered-search-container .dropdown-toggle')
......@@ -639,6 +712,7 @@ describe 'Filter issues', js: true, feature: true do
it 'closed state' do
find('.issues-state-filters a', text: 'Closed').click
wait_for_ajax
expect(page).to have_selector('.issues-list .issue', count: 1)
expect(find('.issues-list .issue:first-of-type .issue-title-text a')).to have_content(closed_issue.title)
end
......@@ -646,6 +720,7 @@ describe 'Filter issues', js: true, feature: true do
it 'all state' do
find('.issues-state-filters a', text: 'All').click
wait_for_ajax
expect(page).to have_selector('.issues-list .issue', count: 5)
end
end
......@@ -657,6 +732,7 @@ describe 'Filter issues', js: true, feature: true do
params = CGI.parse(URI.parse(link[:href]).query)
auto_discovery_link = find('link[type="application/atom+xml"]', visible: false)
auto_discovery_params = CGI.parse(URI.parse(auto_discovery_link[:href]).query)
expect(params).to include('private_token' => [user.private_token])
expect(params).to include('milestone_title' => [milestone.title])
expect(params).to include('assignee_id' => [user.id.to_s])
......@@ -671,6 +747,7 @@ describe 'Filter issues', js: true, feature: true do
params = CGI.parse(URI.parse(link[:href]).query)
auto_discovery_link = find('link[type="application/atom+xml"]', visible: false)
auto_discovery_params = CGI.parse(URI.parse(auto_discovery_link[:href]).query)
expect(params).to include('private_token' => [user.private_token])
expect(params).to include('milestone_title' => [milestone.title])
expect(params).to include('assignee_id' => [user.id.to_s])
......
......@@ -27,6 +27,7 @@ describe 'Search bar', js: true, feature: true do
expect(filtered_search.value).to eq(search_text)
find('.filtered-search-input-container .clear-search').click
expect(filtered_search.value).to eq('')
end
......@@ -37,12 +38,14 @@ describe 'Search bar', js: true, feature: true do
it 'hides after clicked' do
filtered_search.set('a')
find('.filtered-search-input-container .clear-search').click
expect(page).to have_css('.clear-search', visible: false)
end
it 'hides when there is no text' do
filtered_search.set('a')
filtered_search.set('')
expect(page).to have_css('.clear-search', visible: false)
end
......@@ -57,10 +60,12 @@ describe 'Search bar', js: true, feature: true do
original_size = page.all('#js-dropdown-hint .filter-dropdown .filter-dropdown-item').size
filtered_search.set('author')
expect(page.all('#js-dropdown-hint .filter-dropdown .filter-dropdown-item').size).to eq(1)
find('.filtered-search-input-container .clear-search').click
filtered_search.click
expect(page.all('#js-dropdown-hint .filter-dropdown .filter-dropdown-item').size).to eq(original_size)
end
......@@ -70,10 +75,12 @@ describe 'Search bar', js: true, feature: true do
hint_offset = get_left_style(hint_style)
filtered_search.set('author:')
expect(page.all('#js-dropdown-hint .filter-dropdown .filter-dropdown-item').size).to eq(0)
find('.filtered-search-input-container .clear-search').click
filtered_search.click
expect(page.all('#js-dropdown-hint .filter-dropdown .filter-dropdown-item').size).to be > 0
expect(get_left_style(page.find('#js-dropdown-hint')['style'])).to eq(hint_offset)
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment