diff options
author | Hiroyuki Sato <sathiroyuki@gmail.com> | 2017-08-30 10:48:55 +0300 |
---|---|---|
committer | Phil Hughes <me@iamphill.com> | 2017-08-30 10:48:55 +0300 |
commit | 7187395ef13d8d84a145d1b5251882ebada3f7f2 (patch) | |
tree | 06188448a7059648d5ca99c159f525eaf3499cc3 /spec/features/issues/filtered_search | |
parent | df8ca5aaab21f47c328cc15f2c454b9cc97a3ed5 (diff) |
Add filter by my reaction
Diffstat (limited to 'spec/features/issues/filtered_search')
6 files changed, 367 insertions, 123 deletions
diff --git a/spec/features/issues/filtered_search/dropdown_assignee_spec.rb b/spec/features/issues/filtered_search/dropdown_assignee_spec.rb index 2cc027aac9e..1c4649d0ba9 100644 --- a/spec/features/issues/filtered_search/dropdown_assignee_spec.rb +++ b/spec/features/issues/filtered_search/dropdown_assignee_spec.rb @@ -204,6 +204,12 @@ describe 'Dropdown assignee', :js do expect(page).to have_css(js_dropdown_assignee, visible: true) end + + it 'opens assignee dropdown with existing my-reaction' do + filtered_search.set('my-reaction:star assignee:') + + expect(page).to have_css(js_dropdown_assignee, visible: true) + end end describe 'caching requests' do diff --git a/spec/features/issues/filtered_search/dropdown_emoji_spec.rb b/spec/features/issues/filtered_search/dropdown_emoji_spec.rb new file mode 100644 index 00000000000..44741bcc92d --- /dev/null +++ b/spec/features/issues/filtered_search/dropdown_emoji_spec.rb @@ -0,0 +1,182 @@ +require 'rails_helper' + +describe 'Dropdown emoji', js: true do + include FilteredSearchHelpers + + let!(:project) { create(:project, :public) } + let!(:user) { create(:user, name: 'administrator', username: 'root') } + let!(:issue) { create(:issue, project: project) } + let!(:award_emoji_star) { create(:award_emoji, name: 'star', user: user, awardable: issue) } + let(:filtered_search) { find('.filtered-search') } + let(:js_dropdown_emoji) { '#js-dropdown-my-reaction' } + + def send_keys_to_filtered_search(input) + input.split("").each do |i| + filtered_search.send_keys(i) + end + + sleep 0.5 + wait_for_requests + end + + def dropdown_emoji_size + page.all('#js-dropdown-my-reaction .filter-dropdown .filter-dropdown-item').size + end + + def click_emoji(text) + find('#js-dropdown-my-reaction .filter-dropdown .filter-dropdown-item', text: text).click + end + + before do + project.team << [user, :master] + create_list(:award_emoji, 2, user: user, name: 'thumbsup') + create_list(:award_emoji, 1, user: user, name: 'thumbsdown') + create_list(:award_emoji, 3, user: user, name: 'star') + create_list(:award_emoji, 1, user: user, name: 'tea') + end + + context 'when user not logged in' do + before do + visit project_issues_path(project) + end + + describe 'behavior' do + it 'does not open when the search bar has my-reaction:' do + filtered_search.set('my-reaction:') + + expect(page).not_to have_css(js_dropdown_emoji) + end + end + end + + context 'when user loggged in' do + before do + sign_in(user) + + visit project_issues_path(project) + end + + describe 'behavior' do + it 'opens when the search bar has my-reaction:' do + filtered_search.set('my-reaction:') + + expect(page).to have_css(js_dropdown_emoji, visible: true) + end + + it 'closes when the search bar is unfocused' do + find('body').click() + + expect(page).to have_css(js_dropdown_emoji, visible: false) + end + + it 'should show loading indicator when opened' do + filtered_search.set('my-reaction:') + + expect(page).to have_css('#js-dropdown-my-reaction .filter-dropdown-loading', visible: true) + end + + it 'should hide loading indicator when loaded' do + send_keys_to_filtered_search('my-reaction:') + + expect(page).not_to have_css('#js-dropdown-my-reaction .filter-dropdown-loading') + end + + it 'should load all the emojis when opened' do + send_keys_to_filtered_search('my-reaction:') + + expect(dropdown_emoji_size).to eq(4) + end + + it 'shows the most populated emoji at top of dropdown' do + send_keys_to_filtered_search('my-reaction:') + + expect(first('#js-dropdown-my-reaction li')).to have_content(award_emoji_star.name) + end + end + + describe 'filtering' do + before do + filtered_search.set('my-reaction') + send_keys_to_filtered_search(':') + end + + it 'filters by name' do + send_keys_to_filtered_search('up') + + expect(dropdown_emoji_size).to eq(1) + end + + it 'filters by case insensitive name' do + send_keys_to_filtered_search('Up') + + expect(dropdown_emoji_size).to eq(1) + end + end + + describe 'selecting from dropdown' do + before do + filtered_search.set('my-reaction') + send_keys_to_filtered_search(':') + end + + it 'fills in the my-reaction name' do + click_emoji('thumbsup') + + wait_for_requests + + expect(page).to have_css(js_dropdown_emoji, visible: false) + expect_tokens([emoji_token('thumbsup')]) + expect_filtered_search_input_empty + end + end + + describe 'input has existing content' do + it 'opens my-reaction dropdown with existing search term' do + filtered_search.set('searchTerm my-reaction:') + + expect(page).to have_css(js_dropdown_emoji, visible: true) + end + + it 'opens my-reaction dropdown with existing assignee' do + filtered_search.set('assignee:@user my-reaction:') + + expect(page).to have_css(js_dropdown_emoji, visible: true) + end + + it 'opens my-reaction dropdown with existing label' do + filtered_search.set('label:~bug my-reaction:') + + expect(page).to have_css(js_dropdown_emoji, visible: true) + end + + it 'opens my-reaction dropdown with existing milestone' do + filtered_search.set('milestone:%v1.0 my-reaction:') + + expect(page).to have_css(js_dropdown_emoji, visible: true) + end + + it 'opens my-reaction dropdown with existing my-reaction' do + filtered_search.set('my-reaction:star my-reaction:') + + expect(page).to have_css(js_dropdown_emoji, visible: true) + end + end + + describe 'caching requests' do + it 'caches requests after the first load' do + filtered_search.set('my-reaction') + send_keys_to_filtered_search(':') + initial_size = dropdown_emoji_size + + expect(initial_size).to be > 0 + + create_list(:award_emoji, 1, user: user, name: 'smile') + find('.filtered-search-box .clear-search').click + filtered_search.set('my-reaction') + send_keys_to_filtered_search(':') + + expect(dropdown_emoji_size).to eq(initial_size) + end + end + end +end diff --git a/spec/features/issues/filtered_search/dropdown_hint_spec.rb b/spec/features/issues/filtered_search/dropdown_hint_spec.rb index 04d6dea4b8c..0183495a1db 100644 --- a/spec/features/issues/filtered_search/dropdown_hint_spec.rb +++ b/spec/features/issues/filtered_search/dropdown_hint_spec.rb @@ -3,7 +3,7 @@ require 'rails_helper' describe 'Dropdown hint', :js do include FilteredSearchHelpers - let!(:project) { create(:project) } + let!(:project) { create(:project, :public) } let!(:user) { create(:user) } let(:filtered_search) { find('.filtered-search') } let(:js_dropdown_hint) { '#js-dropdown-hint' } @@ -14,165 +14,209 @@ describe 'Dropdown hint', :js do before do project.team << [user, :master] - sign_in(user) create(:issue, project: project) - - visit project_issues_path(project) end - describe 'behavior' do + context 'when user not logged in' do before do - expect(page).to have_css(js_dropdown_hint, visible: false) - filtered_search.click + visit project_issues_path(project) end - it 'opens when the search bar is first focused' do - expect(page).to have_css(js_dropdown_hint, visible: true) - end - - it 'closes when the search bar is unfocused' do - find('body').click - + it 'does not exist my-reaction dropdown item' do expect(page).to have_css(js_dropdown_hint, visible: false) + expect(page).not_to have_content('my-reaction') end end - describe 'filtering' do - it 'does not filter `Press Enter or click to search`' do - filtered_search.set('randomtext') - - hint_dropdown = find(js_dropdown_hint) + context 'when user logged in' do + before do + sign_in(user) - expect(hint_dropdown).to have_content('Press Enter or click to search') - expect(hint_dropdown).to have_selector('.filter-dropdown .filter-dropdown-item', count: 0) + visit project_issues_path(project) end - it 'filters with text' do - filtered_search.set('a') + describe 'behavior' do + before do + expect(page).to have_css(js_dropdown_hint, visible: false) + filtered_search.click + end - expect(find(js_dropdown_hint)).to have_selector('.filter-dropdown .filter-dropdown-item', count: 3) - end - end + it 'opens when the search bar is first focused' do + expect(page).to have_css(js_dropdown_hint, visible: true) + end - describe 'selecting from dropdown with no input' do - before do - filtered_search.click - end + it 'closes when the search bar is unfocused' do + find('body').click - 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_tokens([{ name: 'author' }]) - expect_filtered_search_input_empty + expect(page).to have_css(js_dropdown_hint, visible: false) + end end - it 'opens the assignee dropdown when you click on assignee' do - click_hint('assignee') + describe 'filtering' do + it 'does not filter `Press Enter or click to search`' do + filtered_search.set('randomtext') - expect(page).to have_css(js_dropdown_hint, visible: false) - expect(page).to have_css('#js-dropdown-assignee', visible: true) - expect_tokens([{ name: 'assignee' }]) - expect_filtered_search_input_empty - end + hint_dropdown = find(js_dropdown_hint) - it 'opens the milestone dropdown when you click on milestone' do - click_hint('milestone') + expect(hint_dropdown).to have_content('Press Enter or click to search') + expect(hint_dropdown).to have_selector('.filter-dropdown .filter-dropdown-item', count: 0) + end - expect(page).to have_css(js_dropdown_hint, visible: false) - expect(page).to have_css('#js-dropdown-milestone', visible: true) - expect_tokens([{ name: 'milestone' }]) - expect_filtered_search_input_empty - end + it 'filters with text' do + filtered_search.set('a') - 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_tokens([{ name: 'label' }]) - expect_filtered_search_input_empty + expect(find(js_dropdown_hint)).to have_selector('.filter-dropdown .filter-dropdown-item', count: 4) + end end - end - - describe 'selecting from dropdown with some input' 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_tokens([{ name: 'author' }]) - expect_filtered_search_input_empty - end + describe 'selecting from dropdown with no input' do + before do + filtered_search.click + end - it 'opens the assignee dropdown when you click on assignee' do - filtered_search.set('assign') - click_hint('assignee') + 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-assignee', visible: true) - expect_tokens([{ name: 'assignee' }]) - expect_filtered_search_input_empty - end + expect(page).to have_css(js_dropdown_hint, visible: false) + expect(page).to have_css('#js-dropdown-author', visible: true) + expect_tokens([{ name: 'author' }]) + expect_filtered_search_input_empty + end - it 'opens the milestone dropdown when you click on milestone' do - filtered_search.set('mile') - click_hint('milestone') + 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-milestone', visible: true) - expect_tokens([{ name: 'milestone' }]) - expect_filtered_search_input_empty - end + expect(page).to have_css(js_dropdown_hint, visible: false) + expect(page).to have_css('#js-dropdown-assignee', visible: true) + expect_tokens([{ name: 'assignee' }]) + expect_filtered_search_input_empty + end - it 'opens the label dropdown when you click on label' do - filtered_search.set('lab') - click_hint('label') + 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-label', visible: true) - expect_tokens([{ name: 'label' }]) - expect_filtered_search_input_empty - end - end + expect(page).to have_css(js_dropdown_hint, visible: false) + expect(page).to have_css('#js-dropdown-milestone', visible: true) + expect_tokens([{ name: 'milestone' }]) + expect_filtered_search_input_empty + end - describe 'reselecting from dropdown' do - it 'reuses existing author text' do - filtered_search.send_keys('author:') - filtered_search.send_keys(:backspace) - click_hint('author') + it 'opens the label dropdown when you click on label' do + click_hint('label') - expect_tokens([{ name: 'author' }]) - expect_filtered_search_input_empty - end + expect(page).to have_css(js_dropdown_hint, visible: false) + expect(page).to have_css('#js-dropdown-label', visible: true) + expect_tokens([{ name: 'label' }]) + expect_filtered_search_input_empty + end - it 'reuses existing assignee text' do - filtered_search.send_keys('assignee:') - filtered_search.send_keys(:backspace) - click_hint('assignee') + it 'opens the emoji dropdown when you click on my-reaction' do + click_hint('my-reaction') - expect_tokens([{ name: 'assignee' }]) - expect_filtered_search_input_empty + expect(page).to have_css(js_dropdown_hint, visible: false) + expect(page).to have_css('#js-dropdown-my-reaction', visible: true) + expect_tokens([{ name: 'my-reaction' }]) + expect_filtered_search_input_empty + end end - it 'reuses existing milestone text' do - filtered_search.send_keys('milestone:') - filtered_search.send_keys(:backspace) - click_hint('milestone') - - expect_tokens([{ name: 'milestone' }]) - expect_filtered_search_input_empty - end + describe 'selecting from dropdown with some input' do + it 'opens the author dropdown when you click on author' do + filtered_search.set('auth') + click_hint('author') - it 'reuses existing label text' do - filtered_search.send_keys('label:') - filtered_search.send_keys(:backspace) - click_hint('label') + expect(page).to have_css(js_dropdown_hint, visible: false) + expect(page).to have_css('#js-dropdown-author', visible: true) + expect_tokens([{ name: 'author' }]) + expect_filtered_search_input_empty + end - expect_tokens([{ name: 'label' }]) - expect_filtered_search_input_empty + 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_tokens([{ name: 'assignee' }]) + expect_filtered_search_input_empty + end + + 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_tokens([{ name: 'milestone' }]) + expect_filtered_search_input_empty + end + + 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_tokens([{ name: 'label' }]) + expect_filtered_search_input_empty + end + + it 'opens the emoji dropdown when you click on my-reaction' do + filtered_search.set('my') + click_hint('my-reaction') + + expect(page).to have_css(js_dropdown_hint, visible: false) + expect(page).to have_css('#js-dropdown-my-reaction', visible: true) + expect_tokens([{ name: 'my-reaction' }]) + expect_filtered_search_input_empty + end + end + + describe 'reselecting from dropdown' do + it 'reuses existing author text' do + filtered_search.send_keys('author:') + filtered_search.send_keys(:backspace) + click_hint('author') + + expect_tokens([{ name: 'author' }]) + expect_filtered_search_input_empty + end + + it 'reuses existing assignee text' do + filtered_search.send_keys('assignee:') + filtered_search.send_keys(:backspace) + click_hint('assignee') + + expect_tokens([{ name: 'assignee' }]) + expect_filtered_search_input_empty + end + + it 'reuses existing milestone text' do + filtered_search.send_keys('milestone:') + filtered_search.send_keys(:backspace) + click_hint('milestone') + + expect_tokens([{ name: 'milestone' }]) + expect_filtered_search_input_empty + end + + it 'reuses existing label text' do + filtered_search.send_keys('label:') + filtered_search.send_keys(:backspace) + click_hint('label') + + expect_tokens([{ name: 'label' }]) + expect_filtered_search_input_empty + end + + it 'reuses existing emoji text' do + filtered_search.send_keys('my-reaction:') + filtered_search.send_keys(:backspace) + click_hint('my-reaction') + + expect_tokens([{ name: 'my-reaction' }]) + expect_filtered_search_input_empty + end end end end diff --git a/spec/features/issues/filtered_search/dropdown_label_spec.rb b/spec/features/issues/filtered_search/dropdown_label_spec.rb index e84b07ec2ef..c46803112a9 100644 --- a/spec/features/issues/filtered_search/dropdown_label_spec.rb +++ b/spec/features/issues/filtered_search/dropdown_label_spec.rb @@ -270,6 +270,12 @@ describe 'Dropdown label', js: true do expect(page).to have_css(js_dropdown_label) end + + it 'opens label dropdown with existing my-reaction' do + filtered_search.set('my-reaction:star label:') + + expect(page).to have_css(js_dropdown_label) + end end describe 'caching requests' do diff --git a/spec/features/issues/filtered_search/dropdown_milestone_spec.rb b/spec/features/issues/filtered_search/dropdown_milestone_spec.rb index 5f99921ae2e..f6c2e952bea 100644 --- a/spec/features/issues/filtered_search/dropdown_milestone_spec.rb +++ b/spec/features/issues/filtered_search/dropdown_milestone_spec.rb @@ -242,6 +242,12 @@ describe 'Dropdown milestone', :js do expect(page).to have_css(js_dropdown_milestone, visible: true) end + + it 'opens milestone dropdown with existing my-reaction' do + filtered_search.set('my-reaction:star milestone:') + + expect(page).to have_css(js_dropdown_milestone, visible: true) + end end describe 'caching requests' do diff --git a/spec/features/issues/filtered_search/search_bar_spec.rb b/spec/features/issues/filtered_search/search_bar_spec.rb index a432d031337..d4dd570fb37 100644 --- a/spec/features/issues/filtered_search/search_bar_spec.rb +++ b/spec/features/issues/filtered_search/search_bar_spec.rb @@ -100,7 +100,7 @@ describe 'Search bar', js: true do find('.filtered-search-box .clear-search').click filtered_search.click - expect(find('#js-dropdown-hint')).to have_selector('.filter-dropdown .filter-dropdown-item', count: 4) + expect(find('#js-dropdown-hint')).to have_selector('.filter-dropdown .filter-dropdown-item', count: 5) expect(get_left_style(find('#js-dropdown-hint')['style'])).to eq(hint_offset) end end |