Commit ce9d3ee5 authored by Clement Ho's avatar Clement Ho

Backend review

parent 044a195b
...@@ -22,7 +22,8 @@ require('../window')(function(w){ ...@@ -22,7 +22,8 @@ require('../window')(function(w){
debounceTrigger: function debounceTrigger(e) { debounceTrigger: function debounceTrigger(e) {
var NON_CHARACTER_KEYS = [16, 17, 18, 20, 37, 38, 39, 40, 91, 93]; 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 invalidKeyPressed = NON_CHARACTER_KEYS.indexOf(e.detail.which || e.detail.keyCode) > -1;
var focusEvent = false; var focusEvent = e.type === 'focus';
if (invalidKeyPressed || this.loading) { if (invalidKeyPressed || this.loading) {
return; return;
} }
...@@ -31,10 +32,6 @@ require('../window')(function(w){ ...@@ -31,10 +32,6 @@ require('../window')(function(w){
clearTimeout(this.timeout); clearTimeout(this.timeout);
} }
if (e.type === 'focus') {
focusEvent = true;
}
this.timeout = setTimeout(this.trigger.bind(this, focusEvent), 200); this.timeout = setTimeout(this.trigger.bind(this, focusEvent), 200);
}, },
...@@ -66,7 +63,7 @@ require('../window')(function(w){ ...@@ -66,7 +63,7 @@ require('../window')(function(w){
searchValue = ''; searchValue = '';
} }
if (searchValue === config.searchKey) { if (config.searchKey === searchValue) {
return this.list.show(); return this.list.show();
} }
......
...@@ -39,26 +39,31 @@ describe 'Dropdown assignee', js: true, feature: true do ...@@ -39,26 +39,31 @@ describe 'Dropdown assignee', js: true, feature: true do
describe 'behavior' do describe 'behavior' do
it 'opens when the search bar has assignee:' do it 'opens when the search bar has assignee:' do
filtered_search.set('assignee:') filtered_search.set('assignee:')
expect(page).to have_css(js_dropdown_assignee, visible: true) expect(page).to have_css(js_dropdown_assignee, visible: true)
end end
it 'closes when the search bar is unfocused' do it 'closes when the search bar is unfocused' do
find('body').click() find('body').click()
expect(page).to have_css(js_dropdown_assignee, visible: false) expect(page).to have_css(js_dropdown_assignee, visible: false)
end end
it 'should show loading indicator when opened' do it 'should show loading indicator when opened' do
filtered_search.set('assignee:') filtered_search.set('assignee:')
expect(page).to have_css('#js-dropdown-assignee .filter-dropdown-loading', visible: true) expect(page).to have_css('#js-dropdown-assignee .filter-dropdown-loading', visible: true)
end end
it 'should hide loading indicator when loaded' do it 'should hide loading indicator when loaded' do
send_keys_to_filtered_search('assignee:') send_keys_to_filtered_search('assignee:')
expect(page).not_to have_css('#js-dropdown-assignee .filter-dropdown-loading') expect(page).not_to have_css('#js-dropdown-assignee .filter-dropdown-loading')
end end
it 'should load all the assignees when opened' do it 'should load all the assignees when opened' do
send_keys_to_filtered_search('assignee:') send_keys_to_filtered_search('assignee:')
expect(dropdown_assignee_size).to eq(3) expect(dropdown_assignee_size).to eq(3)
end end
end end
...@@ -70,31 +75,37 @@ describe 'Dropdown assignee', js: true, feature: true do ...@@ -70,31 +75,37 @@ describe 'Dropdown assignee', js: true, feature: true do
it 'filters by name' do it 'filters by name' do
send_keys_to_filtered_search('j') send_keys_to_filtered_search('j')
expect(dropdown_assignee_size).to eq(2) expect(dropdown_assignee_size).to eq(2)
end end
it 'filters by case insensitive name' do it 'filters by case insensitive name' do
send_keys_to_filtered_search('J') send_keys_to_filtered_search('J')
expect(dropdown_assignee_size).to eq(2) expect(dropdown_assignee_size).to eq(2)
end end
it 'filters by username with symbol' do it 'filters by username with symbol' do
send_keys_to_filtered_search('@ot') send_keys_to_filtered_search('@ot')
expect(dropdown_assignee_size).to eq(2) expect(dropdown_assignee_size).to eq(2)
end end
it 'filters by case insensitive username with symbol' do it 'filters by case insensitive username with symbol' do
send_keys_to_filtered_search('@OT') send_keys_to_filtered_search('@OT')
expect(dropdown_assignee_size).to eq(2) expect(dropdown_assignee_size).to eq(2)
end end
it 'filters by username without symbol' do it 'filters by username without symbol' do
send_keys_to_filtered_search('ot') send_keys_to_filtered_search('ot')
expect(dropdown_assignee_size).to eq(2) expect(dropdown_assignee_size).to eq(2)
end end
it 'filters by case insensitive username without symbol' do it 'filters by case insensitive username without symbol' do
send_keys_to_filtered_search('OT') send_keys_to_filtered_search('OT')
expect(dropdown_assignee_size).to eq(2) expect(dropdown_assignee_size).to eq(2)
end end
end end
...@@ -106,6 +117,7 @@ describe 'Dropdown assignee', js: true, feature: true do ...@@ -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 it 'fills in the assignee username when the assignee has not been filtered' do
click_assignee(user_jacob.name) click_assignee(user_jacob.name)
expect(page).to have_css(js_dropdown_assignee, visible: false) expect(page).to have_css(js_dropdown_assignee, visible: false)
expect(filtered_search.value).to eq("assignee:@#{user_jacob.username}") expect(filtered_search.value).to eq("assignee:@#{user_jacob.username}")
end end
...@@ -113,12 +125,14 @@ describe 'Dropdown assignee', js: true, feature: true do ...@@ -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 it 'fills in the assignee username when the assignee has been filtered' do
send_keys_to_filtered_search('roo') send_keys_to_filtered_search('roo')
click_assignee(user.name) click_assignee(user.name)
expect(page).to have_css(js_dropdown_assignee, visible: false) expect(page).to have_css(js_dropdown_assignee, visible: false)
expect(filtered_search.value).to eq("assignee:@#{user.username}") expect(filtered_search.value).to eq("assignee:@#{user.username}")
end end
it 'selects `no assignee`' do it 'selects `no assignee`' do
find('#js-dropdown-assignee .filter-dropdown-item', text: 'No Assignee').click find('#js-dropdown-assignee .filter-dropdown-item', text: 'No Assignee').click
expect(page).to have_css(js_dropdown_assignee, visible: false) expect(page).to have_css(js_dropdown_assignee, visible: false)
expect(filtered_search.value).to eq("assignee:none") expect(filtered_search.value).to eq("assignee:none")
end end
...@@ -127,21 +141,25 @@ describe 'Dropdown assignee', js: true, feature: true do ...@@ -127,21 +141,25 @@ describe 'Dropdown assignee', js: true, feature: true do
describe 'input has existing content' do describe 'input has existing content' do
it 'opens assignee dropdown with existing search term' do it 'opens assignee dropdown with existing search term' do
filtered_search.set('searchTerm assignee:') filtered_search.set('searchTerm assignee:')
expect(page).to have_css(js_dropdown_assignee, visible: true) expect(page).to have_css(js_dropdown_assignee, visible: true)
end end
it 'opens assignee dropdown with existing author' do it 'opens assignee dropdown with existing author' do
filtered_search.set('author:@user assignee:') filtered_search.set('author:@user assignee:')
expect(page).to have_css(js_dropdown_assignee, visible: true) expect(page).to have_css(js_dropdown_assignee, visible: true)
end end
it 'opens assignee dropdown with existing label' do it 'opens assignee dropdown with existing label' do
filtered_search.set('label:~bug assignee:') filtered_search.set('label:~bug assignee:')
expect(page).to have_css(js_dropdown_assignee, visible: true) expect(page).to have_css(js_dropdown_assignee, visible: true)
end end
it 'opens assignee dropdown with existing milestone' do it 'opens assignee dropdown with existing milestone' do
filtered_search.set('milestone:%v1.0 assignee:') filtered_search.set('milestone:%v1.0 assignee:')
expect(page).to have_css(js_dropdown_assignee, visible: true) expect(page).to have_css(js_dropdown_assignee, visible: true)
end end
end end
......
...@@ -39,26 +39,31 @@ describe 'Dropdown author', js: true, feature: true do ...@@ -39,26 +39,31 @@ describe 'Dropdown author', js: true, feature: true do
describe 'behavior' do describe 'behavior' do
it 'opens when the search bar has author:' do it 'opens when the search bar has author:' do
filtered_search.set('author:') filtered_search.set('author:')
expect(page).to have_css(js_dropdown_author, visible: true) expect(page).to have_css(js_dropdown_author, visible: true)
end end
it 'closes when the search bar is unfocused' do it 'closes when the search bar is unfocused' do
find('body').click() find('body').click()
expect(page).to have_css(js_dropdown_author, visible: false) expect(page).to have_css(js_dropdown_author, visible: false)
end end
it 'should show loading indicator when opened' do it 'should show loading indicator when opened' do
filtered_search.set('author:') filtered_search.set('author:')
expect(page).to have_css('#js-dropdown-author .filter-dropdown-loading', visible: true) expect(page).to have_css('#js-dropdown-author .filter-dropdown-loading', visible: true)
end end
it 'should hide loading indicator when loaded' do it 'should hide loading indicator when loaded' do
send_keys_to_filtered_search('author:') send_keys_to_filtered_search('author:')
expect(page).not_to have_css('#js-dropdown-author .filter-dropdown-loading') expect(page).not_to have_css('#js-dropdown-author .filter-dropdown-loading')
end end
it 'should load all the authors when opened' do it 'should load all the authors when opened' do
send_keys_to_filtered_search('author:') send_keys_to_filtered_search('author:')
expect(dropdown_author_size).to eq(3) expect(dropdown_author_size).to eq(3)
end end
end end
...@@ -71,26 +76,31 @@ describe 'Dropdown author', js: true, feature: true do ...@@ -71,26 +76,31 @@ describe 'Dropdown author', js: true, feature: true do
it 'filters by name' do it 'filters by name' do
send_keys_to_filtered_search('ja') send_keys_to_filtered_search('ja')
expect(dropdown_author_size).to eq(1) expect(dropdown_author_size).to eq(1)
end end
it 'filters by case insensitive name' do it 'filters by case insensitive name' do
send_keys_to_filtered_search('Ja') send_keys_to_filtered_search('Ja')
expect(dropdown_author_size).to eq(1) expect(dropdown_author_size).to eq(1)
end end
it 'filters by username with symbol' do it 'filters by username with symbol' do
send_keys_to_filtered_search('@ot') send_keys_to_filtered_search('@ot')
expect(dropdown_author_size).to eq(2) expect(dropdown_author_size).to eq(2)
end end
it 'filters by username without symbol' do it 'filters by username without symbol' do
send_keys_to_filtered_search('ot') send_keys_to_filtered_search('ot')
expect(dropdown_author_size).to eq(2) expect(dropdown_author_size).to eq(2)
end end
it 'filters by case insensitive username without symbol' do it 'filters by case insensitive username without symbol' do
send_keys_to_filtered_search('OT') send_keys_to_filtered_search('OT')
expect(dropdown_author_size).to eq(2) expect(dropdown_author_size).to eq(2)
end end
end end
...@@ -103,12 +113,14 @@ describe 'Dropdown author', js: true, feature: true do ...@@ -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 it 'fills in the author username when the author has not been filtered' do
click_author(user_jacob.name) click_author(user_jacob.name)
expect(page).to have_css(js_dropdown_author, visible: false) expect(page).to have_css(js_dropdown_author, visible: false)
expect(filtered_search.value).to eq("author:@#{user_jacob.username}") expect(filtered_search.value).to eq("author:@#{user_jacob.username}")
end end
it 'fills in the author username when the author has been filtered' do it 'fills in the author username when the author has been filtered' do
click_author(user.name) click_author(user.name)
expect(page).to have_css(js_dropdown_author, visible: false) expect(page).to have_css(js_dropdown_author, visible: false)
expect(filtered_search.value).to eq("author:@#{user.username}") expect(filtered_search.value).to eq("author:@#{user.username}")
end end
...@@ -117,21 +129,25 @@ describe 'Dropdown author', js: true, feature: true do ...@@ -117,21 +129,25 @@ describe 'Dropdown author', js: true, feature: true do
describe 'input has existing content' do describe 'input has existing content' do
it 'opens author dropdown with existing search term' do it 'opens author dropdown with existing search term' do
filtered_search.set('searchTerm author:') filtered_search.set('searchTerm author:')
expect(page).to have_css(js_dropdown_author, visible: true) expect(page).to have_css(js_dropdown_author, visible: true)
end end
it 'opens author dropdown with existing assignee' do it 'opens author dropdown with existing assignee' do
filtered_search.set('assignee:@user author:') filtered_search.set('assignee:@user author:')
expect(page).to have_css(js_dropdown_author, visible: true) expect(page).to have_css(js_dropdown_author, visible: true)
end end
it 'opens author dropdown with existing label' do it 'opens author dropdown with existing label' do
filtered_search.set('label:~bug author:') filtered_search.set('label:~bug author:')
expect(page).to have_css(js_dropdown_author, visible: true) expect(page).to have_css(js_dropdown_author, visible: true)
end end
it 'opens author dropdown with existing milestone' do it 'opens author dropdown with existing milestone' do
filtered_search.set('milestone:%v1.0 author:') filtered_search.set('milestone:%v1.0 author:')
expect(page).to have_css(js_dropdown_author, visible: true) expect(page).to have_css(js_dropdown_author, visible: true)
end end
end end
......
...@@ -36,6 +36,7 @@ describe 'Dropdown hint', js: true, feature: true do ...@@ -36,6 +36,7 @@ describe 'Dropdown hint', js: true, feature: true do
it 'closes when the search bar is unfocused' do it 'closes when the search bar is unfocused' do
find('body').click find('body').click
expect(page).to have_css(js_dropdown_hint, visible: false) expect(page).to have_css(js_dropdown_hint, visible: false)
end end
end end
...@@ -43,12 +44,14 @@ describe 'Dropdown hint', js: true, feature: true do ...@@ -43,12 +44,14 @@ describe 'Dropdown hint', js: true, feature: true do
describe 'filtering' do describe 'filtering' do
it 'does not filter `Keep typing and press Enter`' do it 'does not filter `Keep typing and press Enter`' do
filtered_search.set('randomtext') filtered_search.set('randomtext')
expect(page).to have_css(js_dropdown_hint, text: 'Keep typing and press Enter', visible: false) expect(page).to have_css(js_dropdown_hint, text: 'Keep typing and press Enter', visible: false)
expect(dropdown_hint_size).to eq(0) expect(dropdown_hint_size).to eq(0)
end end
it 'filters with text' do it 'filters with text' do
filtered_search.set('a') filtered_search.set('a')
expect(dropdown_hint_size).to eq(3) expect(dropdown_hint_size).to eq(3)
end end
end end
...@@ -60,6 +63,7 @@ describe 'Dropdown hint', js: true, feature: true do ...@@ -60,6 +63,7 @@ describe 'Dropdown hint', js: true, feature: true do
it 'opens the author dropdown when you click on author' do it 'opens the author dropdown when you click on author' do
click_hint('author') click_hint('author')
expect(page).to have_css(js_dropdown_hint, visible: false) expect(page).to have_css(js_dropdown_hint, visible: false)
expect(page).to have_css('#js-dropdown-author', visible: true) expect(page).to have_css('#js-dropdown-author', visible: true)
expect(filtered_search.value).to eq('author:') expect(filtered_search.value).to eq('author:')
...@@ -67,6 +71,7 @@ describe 'Dropdown hint', js: true, feature: true do ...@@ -67,6 +71,7 @@ describe 'Dropdown hint', js: true, feature: true do
it 'opens the assignee dropdown when you click on assignee' do it 'opens the assignee dropdown when you click on assignee' do
click_hint('assignee') click_hint('assignee')
expect(page).to have_css(js_dropdown_hint, visible: false) expect(page).to have_css(js_dropdown_hint, visible: false)
expect(page).to have_css('#js-dropdown-assignee', visible: true) expect(page).to have_css('#js-dropdown-assignee', visible: true)
expect(filtered_search.value).to eq('assignee:') expect(filtered_search.value).to eq('assignee:')
...@@ -74,6 +79,7 @@ describe 'Dropdown hint', js: true, feature: true do ...@@ -74,6 +79,7 @@ describe 'Dropdown hint', js: true, feature: true do
it 'opens the milestone dropdown when you click on milestone' do it 'opens the milestone dropdown when you click on milestone' do
click_hint('milestone') click_hint('milestone')
expect(page).to have_css(js_dropdown_hint, visible: false) expect(page).to have_css(js_dropdown_hint, visible: false)
expect(page).to have_css('#js-dropdown-milestone', visible: true) expect(page).to have_css('#js-dropdown-milestone', visible: true)
expect(filtered_search.value).to eq('milestone:') expect(filtered_search.value).to eq('milestone:')
...@@ -81,6 +87,7 @@ describe 'Dropdown hint', js: true, feature: true do ...@@ -81,6 +87,7 @@ describe 'Dropdown hint', js: true, feature: true do
it 'opens the label dropdown when you click on label' do it 'opens the label dropdown when you click on label' do
click_hint('label') click_hint('label')
expect(page).to have_css(js_dropdown_hint, visible: false) expect(page).to have_css(js_dropdown_hint, visible: false)
expect(page).to have_css('#js-dropdown-label', visible: true) expect(page).to have_css('#js-dropdown-label', visible: true)
expect(filtered_search.value).to eq('label:') expect(filtered_search.value).to eq('label:')
...@@ -91,6 +98,7 @@ describe 'Dropdown hint', js: true, feature: true do ...@@ -91,6 +98,7 @@ describe 'Dropdown hint', js: true, feature: true do
it 'opens the author dropdown when you click on author' do it 'opens the author dropdown when you click on author' do
filtered_search.set('auth') filtered_search.set('auth')
click_hint('author') click_hint('author')
expect(page).to have_css(js_dropdown_hint, visible: false) expect(page).to have_css(js_dropdown_hint, visible: false)
expect(page).to have_css('#js-dropdown-author', visible: true) expect(page).to have_css('#js-dropdown-author', visible: true)
expect(filtered_search.value).to eq('author:') expect(filtered_search.value).to eq('author:')
...@@ -99,6 +107,7 @@ describe 'Dropdown hint', js: true, feature: true do ...@@ -99,6 +107,7 @@ describe 'Dropdown hint', js: true, feature: true do
it 'opens the assignee dropdown when you click on assignee' do it 'opens the assignee dropdown when you click on assignee' do
filtered_search.set('assign') filtered_search.set('assign')
click_hint('assignee') click_hint('assignee')
expect(page).to have_css(js_dropdown_hint, visible: false) expect(page).to have_css(js_dropdown_hint, visible: false)
expect(page).to have_css('#js-dropdown-assignee', visible: true) expect(page).to have_css('#js-dropdown-assignee', visible: true)
expect(filtered_search.value).to eq('assignee:') expect(filtered_search.value).to eq('assignee:')
...@@ -107,6 +116,7 @@ describe 'Dropdown hint', js: true, feature: true do ...@@ -107,6 +116,7 @@ describe 'Dropdown hint', js: true, feature: true do
it 'opens the milestone dropdown when you click on milestone' do it 'opens the milestone dropdown when you click on milestone' do
filtered_search.set('mile') filtered_search.set('mile')
click_hint('milestone') click_hint('milestone')
expect(page).to have_css(js_dropdown_hint, visible: false) expect(page).to have_css(js_dropdown_hint, visible: false)
expect(page).to have_css('#js-dropdown-milestone', visible: true) expect(page).to have_css('#js-dropdown-milestone', visible: true)
expect(filtered_search.value).to eq('milestone:') expect(filtered_search.value).to eq('milestone:')
...@@ -115,6 +125,7 @@ describe 'Dropdown hint', js: true, feature: true do ...@@ -115,6 +125,7 @@ describe 'Dropdown hint', js: true, feature: true do
it 'opens the label dropdown when you click on label' do it 'opens the label dropdown when you click on label' do
filtered_search.set('lab') filtered_search.set('lab')
click_hint('label') click_hint('label')
expect(page).to have_css(js_dropdown_hint, visible: false) expect(page).to have_css(js_dropdown_hint, visible: false)
expect(page).to have_css('#js-dropdown-label', visible: true) expect(page).to have_css('#js-dropdown-label', visible: true)
expect(filtered_search.value).to eq('label:') expect(filtered_search.value).to eq('label:')
......
...@@ -43,26 +43,31 @@ describe 'Dropdown label', js: true, feature: true do ...@@ -43,26 +43,31 @@ describe 'Dropdown label', js: true, feature: true do
describe 'behavior' do describe 'behavior' do
it 'opens when the search bar has label:' do it 'opens when the search bar has label:' do
filtered_search.set('label:') filtered_search.set('label:')
expect(page).to have_css(js_dropdown_label, visible: true) expect(page).to have_css(js_dropdown_label, visible: true)
end end
it 'closes when the search bar is unfocused' do it 'closes when the search bar is unfocused' do
find('body').click() find('body').click()
expect(page).to have_css(js_dropdown_label, visible: false) expect(page).to have_css(js_dropdown_label, visible: false)
end end
it 'should show loading indicator when opened' do it 'should show loading indicator when opened' do
filtered_search.set('label:') filtered_search.set('label:')
expect(page).to have_css('#js-dropdown-label .filter-dropdown-loading', visible: true) expect(page).to have_css('#js-dropdown-label .filter-dropdown-loading', visible: true)
end end
it 'should hide loading indicator when loaded' do it 'should hide loading indicator when loaded' do
send_keys_to_filtered_search('label:') send_keys_to_filtered_search('label:')
expect(page).not_to have_css('#js-dropdown-label .filter-dropdown-loading') expect(page).not_to have_css('#js-dropdown-label .filter-dropdown-loading')
end end
it 'should load all the labels when opened' do it 'should load all the labels when opened' do
send_keys_to_filtered_search('label:') send_keys_to_filtered_search('label:')
expect(dropdown_label_size).to be > 0 expect(dropdown_label_size).to be > 0
end end
end end
...@@ -74,61 +79,73 @@ describe 'Dropdown label', js: true, feature: true do ...@@ -74,61 +79,73 @@ describe 'Dropdown label', js: true, feature: true do
it 'filters by name' do it 'filters by name' do
send_keys_to_filtered_search(':b') send_keys_to_filtered_search(':b')
expect(dropdown_label_size).to eq(2) expect(dropdown_label_size).to eq(2)
end end
it 'filters by case insensitive name' do it 'filters by case insensitive name' do
send_keys_to_filtered_search(':B') send_keys_to_filtered_search(':B')
expect(dropdown_label_size).to eq(2) expect(dropdown_label_size).to eq(2)
end end
it 'filters by name with symbol' do it 'filters by name with symbol' do
send_keys_to_filtered_search(':~bu') send_keys_to_filtered_search(':~bu')
expect(dropdown_label_size).to eq(2) expect(dropdown_label_size).to eq(2)
end end
it 'filters by case insensitive name with symbol' do it 'filters by case insensitive name with symbol' do
send_keys_to_filtered_search(':~BU') send_keys_to_filtered_search(':~BU')
expect(dropdown_label_size).to eq(2) expect(dropdown_label_size).to eq(2)
end end
it 'filters by multiple words' do it 'filters by multiple words' do
send_keys_to_filtered_search(':Hig') send_keys_to_filtered_search(':Hig')
expect(dropdown_label_size).to eq(1) expect(dropdown_label_size).to eq(1)
end end
it 'filters by multiple words with symbol' do it 'filters by multiple words with symbol' do
send_keys_to_filtered_search(':~Hig') send_keys_to_filtered_search(':~Hig')
expect(dropdown_label_size).to eq(1) expect(dropdown_label_size).to eq(1)
end end
it 'filters by multiple words containing single quotes' do it 'filters by multiple words containing single quotes' do
send_keys_to_filtered_search(':won\'t') send_keys_to_filtered_search(':won\'t')
expect(dropdown_label_size).to eq(1) expect(dropdown_label_size).to eq(1)
end end
it 'filters by multiple words containing single quotes with symbol' do it 'filters by multiple words containing single quotes with symbol' do
send_keys_to_filtered_search(':~won\'t') send_keys_to_filtered_search(':~won\'t')
expect(dropdown_label_size).to eq(1) expect(dropdown_label_size).to eq(1)
end end
it 'filters by multiple words containing double quotes' do it 'filters by multiple words containing double quotes' do
send_keys_to_filtered_search(':won"t') send_keys_to_filtered_search(':won"t')
expect(dropdown_label_size).to eq(1) expect(dropdown_label_size).to eq(1)
end end
it 'filters by multiple words containing double quotes with symbol' do it 'filters by multiple words containing double quotes with symbol' do
send_keys_to_filtered_search(':~won"t') send_keys_to_filtered_search(':~won"t')
expect(dropdown_label_size).to eq(1) expect(dropdown_label_size).to eq(1)
end end
it 'filters by special characters' do it 'filters by special characters' do
send_keys_to_filtered_search(':^+') send_keys_to_filtered_search(':^+')
expect(dropdown_label_size).to eq(1) expect(dropdown_label_size).to eq(1)
end end
it 'filters by special characters with symbol' do it 'filters by special characters with symbol' do
send_keys_to_filtered_search(':~^+') send_keys_to_filtered_search(':~^+')
expect(dropdown_label_size).to eq(1) expect(dropdown_label_size).to eq(1)
end end
end end
...@@ -140,6 +157,7 @@ describe 'Dropdown label', js: true, feature: true do ...@@ -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 it 'fills in the label name when the label has not been filled' do
click_label(bug_label.title) click_label(bug_label.title)
expect(page).to have_css(js_dropdown_label, visible: false) expect(page).to have_css(js_dropdown_label, visible: false)
expect(filtered_search.value).to eq("label:~#{bug_label.title}") expect(filtered_search.value).to eq("label:~#{bug_label.title}")
end end
...@@ -147,42 +165,49 @@ describe 'Dropdown label', js: true, feature: true do ...@@ -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 it 'fills in the label name when the label is partially filled' do
send_keys_to_filtered_search('bu') send_keys_to_filtered_search('bu')
click_label(bug_label.title) click_label(bug_label.title)
expect(page).to have_css(js_dropdown_label, visible: false) expect(page).to have_css(js_dropdown_label, visible: false)
expect(filtered_search.value).to eq("label:~#{bug_label.title}") expect(filtered_search.value).to eq("label:~#{bug_label.title}")
end end
it 'fills in the label name that contains multiple words' do it 'fills in the label name that contains multiple words' do
click_label(two_words_label.title) click_label(two_words_label.title)
expect(page).to have_css(js_dropdown_label, visible: false) expect(page).to have_css(js_dropdown_label, visible: false)
expect(filtered_search.value).to eq("label:~\"#{two_words_label.title}\"") expect(filtered_search.value).to eq("label:~\"#{two_words_label.title}\"")
end end
it 'fills in the label name that contains multiple words and is very long' do it 'fills in the label name that contains multiple words and is very long' do
click_label(long_label.title) click_label(long_label.title)
expect(page).to have_css(js_dropdown_label, visible: false) expect(page).to have_css(js_dropdown_label, visible: false)
expect(filtered_search.value).to eq("label:~\"#{long_label.title}\"") expect(filtered_search.value).to eq("label:~\"#{long_label.title}\"")
end end
it 'fills in the label name that contains double quotes' do it 'fills in the label name that contains double quotes' do
click_label(wont_fix_label.title) click_label(wont_fix_label.title)
expect(page).to have_css(js_dropdown_label, visible: false) expect(page).to have_css(js_dropdown_label, visible: false)
expect(filtered_search.value).to eq("label:~'#{wont_fix_label.title}'") expect(filtered_search.value).to eq("label:~'#{wont_fix_label.title}'")
end end
it 'fills in the label name with the correct capitalization' do it 'fills in the label name with the correct capitalization' do
click_label(uppercase_label.title) click_label(uppercase_label.title)
expect(page).to have_css(js_dropdown_label, visible: false) expect(page).to have_css(js_dropdown_label, visible: false)
expect(filtered_search.value).to eq("label:~#{uppercase_label.title}") expect(filtered_search.value).to eq("label:~#{uppercase_label.title}")
end end
it 'fills in the label name with special characters' do it 'fills in the label name with special characters' do
click_label(special_label.title) click_label(special_label.title)
expect(page).to have_css(js_dropdown_label, visible: false) expect(page).to have_css(js_dropdown_label, visible: false)
expect(filtered_search.value).to eq("label:~#{special_label.title}") expect(filtered_search.value).to eq("label:~#{special_label.title}")
end end
it 'selects `no label`' do it 'selects `no label`' do
find('#js-dropdown-label .filter-dropdown-item', text: 'No Label').click find('#js-dropdown-label .filter-dropdown-item', text: 'No Label').click
expect(page).to have_css(js_dropdown_label, visible: false) expect(page).to have_css(js_dropdown_label, visible: false)
expect(filtered_search.value).to eq("label:none") expect(filtered_search.value).to eq("label:none")
end end
......
...@@ -47,26 +47,31 @@ describe 'Dropdown milestone', js: true, feature: true do ...@@ -47,26 +47,31 @@ describe 'Dropdown milestone', js: true, feature: true do
describe 'behavior' do describe 'behavior' do
it 'opens when the search bar has milestone:' do it 'opens when the search bar has milestone:' do
filtered_search.set('milestone:') filtered_search.set('milestone:')
expect(page).to have_css(js_dropdown_milestone, visible: true) expect(page).to have_css(js_dropdown_milestone, visible: true)
end end
it 'closes when the search bar is unfocused' do it 'closes when the search bar is unfocused' do
find('body').click() find('body').click()
expect(page).to have_css(js_dropdown_milestone, visible: false) expect(page).to have_css(js_dropdown_milestone, visible: false)
end end
it 'should show loading indicator when opened' do it 'should show loading indicator when opened' do
filtered_search.set('milestone:') filtered_search.set('milestone:')
expect(page).to have_css('#js-dropdown-milestone .filter-dropdown-loading', visible: true) expect(page).to have_css('#js-dropdown-milestone .filter-dropdown-loading', visible: true)
end end
it 'should hide loading indicator when loaded' do it 'should hide loading indicator when loaded' do
send_keys_to_filtered_search('milestone:') send_keys_to_filtered_search('milestone:')
expect(page).not_to have_css('#js-dropdown-milestone .filter-dropdown-loading') expect(page).not_to have_css('#js-dropdown-milestone .filter-dropdown-loading')
end end
it 'should load all the milestones when opened' do it 'should load all the milestones when opened' do
send_keys_to_filtered_search('milestone:') send_keys_to_filtered_search('milestone:')
expect(dropdown_milestone_size).to be > 0 expect(dropdown_milestone_size).to be > 0
end end
end end
...@@ -78,31 +83,37 @@ describe 'Dropdown milestone', js: true, feature: true do ...@@ -78,31 +83,37 @@ describe 'Dropdown milestone', js: true, feature: true do
it 'filters by name' do it 'filters by name' do
send_keys_to_filtered_search(':v1') send_keys_to_filtered_search(':v1')
expect(dropdown_milestone_size).to eq(1) expect(dropdown_milestone_size).to eq(1)
end end
it 'filters by case insensitive name' do it 'filters by case insensitive name' do
send_keys_to_filtered_search(':V1') send_keys_to_filtered_search(':V1')
expect(dropdown_milestone_size).to eq(1) expect(dropdown_milestone_size).to eq(1)
end end
it 'filters by name with symbol' do it 'filters by name with symbol' do
send_keys_to_filtered_search(':%v1') send_keys_to_filtered_search(':%v1')
expect(dropdown_milestone_size).to eq(1) expect(dropdown_milestone_size).to eq(1)
end end
it 'filters by case insensitive name with symbol' do it 'filters by case insensitive name with symbol' do
send_keys_to_filtered_search(':%V1') send_keys_to_filtered_search(':%V1')
expect(dropdown_milestone_size).to eq(1) expect(dropdown_milestone_size).to eq(1)
end end
it 'filters by special characters' do it 'filters by special characters' do
send_keys_to_filtered_search(':(+') send_keys_to_filtered_search(':(+')
expect(dropdown_milestone_size).to eq(1) expect(dropdown_milestone_size).to eq(1)
end end
it 'filters by special characters with symbol' do it 'filters by special characters with symbol' do
send_keys_to_filtered_search(':%(+') send_keys_to_filtered_search(':%(+')
expect(dropdown_milestone_size).to eq(1) expect(dropdown_milestone_size).to eq(1)
end end
end end
...@@ -114,6 +125,7 @@ describe 'Dropdown milestone', js: true, feature: true do ...@@ -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 it 'fills in the milestone name when the milestone has not been filled' do
click_milestone(milestone.title) click_milestone(milestone.title)
expect(page).to have_css(js_dropdown_milestone, visible: false) expect(page).to have_css(js_dropdown_milestone, visible: false)
expect(filtered_search.value).to eq("milestone:%#{milestone.title}") expect(filtered_search.value).to eq("milestone:%#{milestone.title}")
end end
...@@ -121,48 +133,56 @@ describe 'Dropdown milestone', js: true, feature: true do ...@@ -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 it 'fills in the milestone name when the milestone is partially filled' do
send_keys_to_filtered_search('v') send_keys_to_filtered_search('v')
click_milestone(milestone.title) click_milestone(milestone.title)
expect(page).to have_css(js_dropdown_milestone, visible: false) expect(page).to have_css(js_dropdown_milestone, visible: false)
expect(filtered_search.value).to eq("milestone:%#{milestone.title}") expect(filtered_search.value).to eq("milestone:%#{milestone.title}")
end end
it 'fills in the milestone name that contains multiple words' do it 'fills in the milestone name that contains multiple words' do
click_milestone(two_words_milestone.title) click_milestone(two_words_milestone.title)
expect(page).to have_css(js_dropdown_milestone, visible: false) expect(page).to have_css(js_dropdown_milestone, visible: false)
expect(filtered_search.value).to eq("milestone:%\"#{two_words_milestone.title}\"") expect(filtered_search.value).to eq("milestone:%\"#{two_words_milestone.title}\"")
end end
it 'fills in the milestone name that contains multiple words and is very long' do it 'fills in the milestone name that contains multiple words and is very long' do
click_milestone(long_milestone.title) click_milestone(long_milestone.title)
expect(page).to have_css(js_dropdown_milestone, visible: false) expect(page).to have_css(js_dropdown_milestone, visible: false)
expect(filtered_search.value).to eq("milestone:%\"#{long_milestone.title}\"") expect(filtered_search.value).to eq("milestone:%\"#{long_milestone.title}\"")
end end
it 'fills in the milestone name that contains double quotes' do it 'fills in the milestone name that contains double quotes' do
click_milestone(wont_fix_milestone.title) click_milestone(wont_fix_milestone.title)
expect(page).to have_css(js_dropdown_milestone, visible: false) expect(page).to have_css(js_dropdown_milestone, visible: false)
expect(filtered_search.value).to eq("milestone:%'#{wont_fix_milestone.title}'") expect(filtered_search.value).to eq("milestone:%'#{wont_fix_milestone.title}'")
end end
it 'fills in the milestone name with the correct capitalization' do it 'fills in the milestone name with the correct capitalization' do
click_milestone(uppercase_milestone.title) click_milestone(uppercase_milestone.title)
expect(page).to have_css(js_dropdown_milestone, visible: false) expect(page).to have_css(js_dropdown_milestone, visible: false)
expect(filtered_search.value).to eq("milestone:%#{uppercase_milestone.title}") expect(filtered_search.value).to eq("milestone:%#{uppercase_milestone.title}")
end end
it 'fills in the milestone name with special characters' do it 'fills in the milestone name with special characters' do
click_milestone(special_milestone.title) click_milestone(special_milestone.title)
expect(page).to have_css(js_dropdown_milestone, visible: false) expect(page).to have_css(js_dropdown_milestone, visible: false)
expect(filtered_search.value).to eq("milestone:%#{special_milestone.title}") expect(filtered_search.value).to eq("milestone:%#{special_milestone.title}")
end end
it 'selects `no milestone`' do it 'selects `no milestone`' do
click_static_milestone('No Milestone') click_static_milestone('No Milestone')
expect(page).to have_css(js_dropdown_milestone, visible: false) expect(page).to have_css(js_dropdown_milestone, visible: false)
expect(filtered_search.value).to eq("milestone:none") expect(filtered_search.value).to eq("milestone:none")
end end
it 'selects `upcoming milestone`' do it 'selects `upcoming milestone`' do
click_static_milestone('Upcoming') click_static_milestone('Upcoming')
expect(page).to have_css(js_dropdown_milestone, visible: false) expect(page).to have_css(js_dropdown_milestone, visible: false)
expect(filtered_search.value).to eq("milestone:upcoming") expect(filtered_search.value).to eq("milestone:upcoming")
end end
...@@ -171,26 +191,31 @@ describe 'Dropdown milestone', js: true, feature: true do ...@@ -171,26 +191,31 @@ describe 'Dropdown milestone', js: true, feature: true do
describe 'input has existing content' do describe 'input has existing content' do
it 'opens milestone dropdown with existing search term' do it 'opens milestone dropdown with existing search term' do
filtered_search.set('searchTerm milestone:') filtered_search.set('searchTerm milestone:')
expect(page).to have_css(js_dropdown_milestone, visible: true) expect(page).to have_css(js_dropdown_milestone, visible: true)
end end
it 'opens milestone dropdown with existing author' do it 'opens milestone dropdown with existing author' do
filtered_search.set('author:@john milestone:') filtered_search.set('author:@john milestone:')
expect(page).to have_css(js_dropdown_milestone, visible: true) expect(page).to have_css(js_dropdown_milestone, visible: true)
end end
it 'opens milestone dropdown with existing assignee' do it 'opens milestone dropdown with existing assignee' do
filtered_search.set('assignee:@john milestone:') filtered_search.set('assignee:@john milestone:')
expect(page).to have_css(js_dropdown_milestone, visible: true) expect(page).to have_css(js_dropdown_milestone, visible: true)
end end
it 'opens milestone dropdown with existing label' do it 'opens milestone dropdown with existing label' do
filtered_search.set('label:~important milestone:') filtered_search.set('label:~important milestone:')
expect(page).to have_css(js_dropdown_milestone, visible: true) expect(page).to have_css(js_dropdown_milestone, visible: true)
end end
it 'opens milestone dropdown with existing milestone' do it 'opens milestone dropdown with existing milestone' do
filtered_search.set('milestone:%100 milestone:') filtered_search.set('milestone:%100 milestone:')
expect(page).to have_css(js_dropdown_milestone, visible: true) expect(page).to have_css(js_dropdown_milestone, visible: true)
end end
end end
......
...@@ -27,6 +27,7 @@ describe 'Search bar', js: true, feature: true do ...@@ -27,6 +27,7 @@ describe 'Search bar', js: true, feature: true do
expect(filtered_search.value).to eq(search_text) expect(filtered_search.value).to eq(search_text)
find('.filtered-search-input-container .clear-search').click find('.filtered-search-input-container .clear-search').click
expect(filtered_search.value).to eq('') expect(filtered_search.value).to eq('')
end end
...@@ -37,12 +38,14 @@ describe 'Search bar', js: true, feature: true do ...@@ -37,12 +38,14 @@ describe 'Search bar', js: true, feature: true do
it 'hides after clicked' do it 'hides after clicked' do
filtered_search.set('a') filtered_search.set('a')
find('.filtered-search-input-container .clear-search').click find('.filtered-search-input-container .clear-search').click
expect(page).to have_css('.clear-search', visible: false) expect(page).to have_css('.clear-search', visible: false)
end end
it 'hides when there is no text' do it 'hides when there is no text' do
filtered_search.set('a') filtered_search.set('a')
filtered_search.set('') filtered_search.set('')
expect(page).to have_css('.clear-search', visible: false) expect(page).to have_css('.clear-search', visible: false)
end end
...@@ -57,10 +60,12 @@ describe 'Search bar', js: true, feature: true do ...@@ -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 original_size = page.all('#js-dropdown-hint .filter-dropdown .filter-dropdown-item').size
filtered_search.set('author') filtered_search.set('author')
expect(page.all('#js-dropdown-hint .filter-dropdown .filter-dropdown-item').size).to eq(1) expect(page.all('#js-dropdown-hint .filter-dropdown .filter-dropdown-item').size).to eq(1)
find('.filtered-search-input-container .clear-search').click find('.filtered-search-input-container .clear-search').click
filtered_search.click filtered_search.click
expect(page.all('#js-dropdown-hint .filter-dropdown .filter-dropdown-item').size).to eq(original_size) expect(page.all('#js-dropdown-hint .filter-dropdown .filter-dropdown-item').size).to eq(original_size)
end end
...@@ -70,10 +75,12 @@ describe 'Search bar', js: true, feature: true do ...@@ -70,10 +75,12 @@ describe 'Search bar', js: true, feature: true do
hint_offset = get_left_style(hint_style) hint_offset = get_left_style(hint_style)
filtered_search.set('author:') filtered_search.set('author:')
expect(page.all('#js-dropdown-hint .filter-dropdown .filter-dropdown-item').size).to eq(0) expect(page.all('#js-dropdown-hint .filter-dropdown .filter-dropdown-item').size).to eq(0)
find('.filtered-search-input-container .clear-search').click find('.filtered-search-input-container .clear-search').click
filtered_search.click filtered_search.click
expect(page.all('#js-dropdown-hint .filter-dropdown .filter-dropdown-item').size).to be > 0 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) expect(get_left_style(page.find('#js-dropdown-hint')['style'])).to eq(hint_offset)
end 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