From 12753def903f265467d2cab8e19deced31daf066 Mon Sep 17 00:00:00 2001 From: Clement Ho Date: Sun, 18 Dec 2016 17:04:29 -0600 Subject: [PATCH] Fix specs --- app/assets/javascripts/dispatcher.js.es6 | 2 +- .../filtered_search/dropdown_utils.js.es6 | 2 +- .../filtered_search/dropdown_author_spec.rb | 13 ++---- .../filtered_search/dropdown_label_spec.rb | 40 +++++++++++-------- .../dropdown_milestone_spec.rb | 39 ++++-------------- ...ltered_search_dropdown_manager_spec.js.es6 | 2 - 6 files changed, 36 insertions(+), 62 deletions(-) diff --git a/app/assets/javascripts/dispatcher.js.es6 b/app/assets/javascripts/dispatcher.js.es6 index 1e9111f4718..ca2da18dc26 100644 --- a/app/assets/javascripts/dispatcher.js.es6 +++ b/app/assets/javascripts/dispatcher.js.es6 @@ -84,7 +84,7 @@ break; case 'projects:merge_requests:index': case 'projects:issues:index': - if(document.querySelector('.filtered-search') && gl.FilteredSearchManager) { + if (document.querySelector('.filtered-search') && gl.FilteredSearchManager) { new gl.FilteredSearchManager(); } Issuable.init(); diff --git a/app/assets/javascripts/filtered_search/dropdown_utils.js.es6 b/app/assets/javascripts/filtered_search/dropdown_utils.js.es6 index 0c0d24d4de8..3453311bee5 100644 --- a/app/assets/javascripts/filtered_search/dropdown_utils.js.es6 +++ b/app/assets/javascripts/filtered_search/dropdown_utils.js.es6 @@ -43,7 +43,7 @@ static filterHint(item, query) { const updatedItem = item; let { lastToken } = gl.FilteredSearchTokenizer.processTokens(query); - lastToken = lastToken || ''; + lastToken = lastToken.key || lastToken || ''; if (!lastToken || query.split('').last() === ' ') { updatedItem.droplab_hidden = false; diff --git a/spec/features/issues/filtered_search/dropdown_author_spec.rb b/spec/features/issues/filtered_search/dropdown_author_spec.rb index 956f7156c5f..d053b032768 100644 --- a/spec/features/issues/filtered_search/dropdown_author_spec.rb +++ b/spec/features/issues/filtered_search/dropdown_author_spec.rb @@ -70,13 +70,13 @@ describe 'Dropdown author', js: true, feature: true do end it 'filters by name' do - send_keys_to_filtered_search('j') - expect(dropdown_author_size).to eq(2) + 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('J') - expect(dropdown_author_size).to eq(2) + send_keys_to_filtered_search('Ja') + expect(dropdown_author_size).to eq(1) end it 'filters by username with symbol' do @@ -84,11 +84,6 @@ describe 'Dropdown author', js: true, feature: true do expect(dropdown_author_size).to eq(2) end - it 'filters by case insensitive 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) diff --git a/spec/features/issues/filtered_search/dropdown_label_spec.rb b/spec/features/issues/filtered_search/dropdown_label_spec.rb index a0e2973d6b8..1a21b0d64ed 100644 --- a/spec/features/issues/filtered_search/dropdown_label_spec.rb +++ b/spec/features/issues/filtered_search/dropdown_label_spec.rb @@ -9,6 +9,7 @@ describe 'Dropdown label', js: true, feature: true do let!(:uppercase_label) { create(:label, project: project, title: 'BUG') } let!(:two_words_label) { create(:label, project: project, title: 'High Priority') } let!(:wont_fix_label) { create(:label, project: project, title: 'Won"t Fix') } + let!(:wont_fix_single_label) { create(:label, project: project, title: 'Won\'t Fix') } let!(:special_label) { create(:label, project: project, title: '!@#$%^+&*()')} let!(:long_label) { create(:label, project: project, title: 'this is a very long title this is a very long title this is a very long title this is a very long title this is a very long title')} let(:filtered_search) { find('.filtered-search') } @@ -68,61 +69,66 @@ describe 'Dropdown label', js: true, feature: true do describe 'filtering' do before do - filtered_search.set('label:') + filtered_search.set('label') end it 'filters by name' do - send_keys_to_filtered_search('b') + 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') + 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') + 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') + send_keys_to_filtered_search(':~BU') expect(dropdown_label_size).to eq(2) end - it 'filters by multiple names using double quotes' do - send_keys_to_filtered_search('"High P') + it 'filters by multiple words' do + send_keys_to_filtered_search(':Hig') expect(dropdown_label_size).to eq(1) end - it 'filters by multiple names using single quotes' do - send_keys_to_filtered_search('\'High P') + 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 names using single and double quotes' do - send_keys_to_filtered_search('~"won`\'t f') + 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 names using double quotes with symbol' do - send_keys_to_filtered_search('~"High P') + 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 names using single quotes with symbol' do - send_keys_to_filtered_search('~\'High P') + 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('^+') + 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('~^+') + send_keys_to_filtered_search(':~^+') expect(dropdown_label_size).to eq(1) end end diff --git a/spec/features/issues/filtered_search/dropdown_milestone_spec.rb b/spec/features/issues/filtered_search/dropdown_milestone_spec.rb index d367430a670..64fc83c6ccb 100644 --- a/spec/features/issues/filtered_search/dropdown_milestone_spec.rb +++ b/spec/features/issues/filtered_search/dropdown_milestone_spec.rb @@ -73,61 +73,36 @@ describe 'Dropdown milestone', js: true, feature: true do describe 'filtering' do before do - filtered_search.set('milestone:') + filtered_search.set('milestone') end it 'filters by name' do - send_keys_to_filtered_search('v1') + 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') + 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') + 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 multiple names using double quotes' do - send_keys_to_filtered_search('"future') - expect(dropdown_milestone_size).to eq(1) - end - - it 'filters by multiple names using single quotes' do - send_keys_to_filtered_search('\'future p') - expect(dropdown_milestone_size).to eq(1) - end - - it 'filters by multiple names using single and double quotes' do - send_keys_to_filtered_search('%"won`\'t f') - expect(dropdown_milestone_size).to eq(1) - end - - it 'filters by multiple names using double quotes with symbol' do - send_keys_to_filtered_search('%"future p') - expect(dropdown_milestone_size).to eq(1) - end - - it 'filters by multiple names using single quotes with symbol' do - send_keys_to_filtered_search('%\'future p') + 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('^+') + 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('~^+') + send_keys_to_filtered_search(':%(+') expect(dropdown_milestone_size).to eq(1) end end diff --git a/spec/javascripts/filtered_search/filtered_search_dropdown_manager_spec.js.es6 b/spec/javascripts/filtered_search/filtered_search_dropdown_manager_spec.js.es6 index 562673a4ee5..e9841e3c89e 100644 --- a/spec/javascripts/filtered_search/filtered_search_dropdown_manager_spec.js.es6 +++ b/spec/javascripts/filtered_search/filtered_search_dropdown_manager_spec.js.es6 @@ -12,8 +12,6 @@ const input = document.createElement('input'); input.classList.add('filtered-search'); document.body.appendChild(input); - - expect(input.value).toBe(''); }); afterEach(() => {