Commit 6c21e6f9 authored by Sean McGivern's avatar Sean McGivern

Merge branch 'rs-filtered-issue-search-speed' into 'master'

Reduce duration and complexity of spec/features/issues/filtered_search/filter_issues_spec.rb

See merge request !13973
parents ad32bac5 4a6ab780
require 'spec_helper' require 'spec_helper'
describe 'Filter issues', js: true do describe 'Filter issues', js: true do
include Devise::Test::IntegrationHelpers
include FilteredSearchHelpers include FilteredSearchHelpers
let!(:group) { create(:group) } let(:project) { create(:project) }
let!(:project) { create(:project, group: group) }
let!(:user) { create(:user, username: 'joe', name: 'Joe') } # NOTE: The short name here is actually important
let!(:user2) { create(:user, username: 'jane') } #
let!(:label) { create(:label, project: project) } # When the name is longer, the filtered search input can end up scrolling
let!(:wontfix) { create(:label, project: project, title: "Won't fix") } # horizontally, and PhantomJS can't handle it.
let(:user) { create(:user, name: 'Ann') }
let!(:bug_label) { create(:label, project: project, title: 'bug') } let!(:bug_label) { create(:label, project: project, title: 'bug') }
let!(:caps_sensitive_label) { create(:label, project: project, title: 'CaPs') } let!(:caps_sensitive_label) { create(:label, project: project, title: 'CaPs') }
let!(:milestone) { create(:milestone, title: "8", project: project, start_date: 2.days.ago) }
let!(:multiple_words_label) { create(:label, project: project, title: "Two words") } let!(:multiple_words_label) { create(:label, project: project, title: "Two words") }
let!(:milestone) { create(:milestone, title: "8", project: project, start_date: 2.days.ago) }
let!(:closed_issue) { create(:issue, title: 'bug that is closed', project: project, state: :closed) }
def expect_no_issues_list def expect_no_issues_list
page.within '.issues-list' do page.within '.issues-list' do
expect(page).not_to have_selector('.issue') expect(page).to have_no_selector('.issue')
end end
end end
...@@ -33,130 +31,74 @@ describe 'Filter issues', js: true do ...@@ -33,130 +31,74 @@ describe 'Filter issues', js: true do
end end
end end
def select_search_at_index(pos)
evaluate_script("el = document.querySelector('.filtered-search'); el.focus(); el.setSelectionRange(#{pos}, #{pos});")
end
before do before do
project.team << [user, :master] project.add_master(user)
project.team << [user2, :master]
group.add_developer(user)
group.add_developer(user2)
sign_in(user) user2 = create(:user)
create(:issue, project: project, author: user2, title: "Bug report 1")
create(:issue, project: project, author: user2, title: "Bug report 2")
create(:issue, project: project) create(:issue, project: project, author: user, title: "issue by assignee", milestone: milestone, assignees: [user])
create(:issue, project: project, title: "Bug report 1") create(:issue, project: project, author: user, title: "issue by assignee with searchTerm", milestone: milestone, assignees: [user])
create(:issue, project: project, title: "Bug report 2")
create(:issue, project: project, title: "issue with 'single quotes'")
create(:issue, project: project, title: "issue with \"double quotes\"")
create(:issue, project: project, title: "issue with !@\#{$%^&*()-+")
create(:issue, project: project, title: "issue by assignee", milestone: milestone, author: user, assignees: [user])
create(:issue, project: project, title: "issue by assignee with searchTerm", milestone: milestone, author: user, assignees: [user])
issue = create(:issue, create(:labeled_issue,
title: "Bug 2", title: "Bug 2",
project: project, project: project,
milestone: milestone, milestone: milestone,
author: user, author: user,
assignees: [user]) assignees: [user],
issue.labels << bug_label labels: [bug_label])
issue_with_caps_label = create(:issue, create(:labeled_issue,
title: "issue by assignee with searchTerm and label", title: "issue by assignee with searchTerm and label",
project: project, project: project,
milestone: milestone, milestone: milestone,
author: user, author: user,
assignees: [user]) assignees: [user],
issue_with_caps_label.labels << caps_sensitive_label labels: [caps_sensitive_label])
issue_with_everything = create(:issue, create(:labeled_issue,
title: "Bug report foo was possible", title: "Bug report foo was possible",
project: project, project: project,
milestone: milestone, milestone: milestone,
author: user, author: user,
assignees: [user]) assignees: [user],
issue_with_everything.labels << bug_label labels: [bug_label, caps_sensitive_label])
issue_with_everything.labels << caps_sensitive_label
multiple_words_label_issue = create(:issue, title: "Issue with multiple words label", project: project) create(:labeled_issue, title: "Issue with multiple words label", project: project, labels: [multiple_words_label])
multiple_words_label_issue.labels << multiple_words_label
future_milestone = create(:milestone, title: "future", project: project, due_date: Time.now + 1.month)
create(:issue,
title: "Issue with future milestone",
milestone: future_milestone,
project: project)
allow_any_instance_of(ApplicationHelper).to receive(:collapsed_sidebar?).and_return(true)
sign_in(user)
visit project_issues_path(project) visit project_issues_path(project)
end end
describe 'filter issues by author' do it 'filters by all available tokens' do
context 'only author' do search_term = 'issue'
it 'filters issues by searched author' do
input_filtered_search("author:@#{user.username}")
wait_for_requests
expect_tokens([author_token(user.name)])
expect_issues_list_count(5)
expect_filtered_search_input_empty
end
end
context 'author with other filters' do
let(:search_term) { 'issue' }
it 'filters issues by searched author and text' do
input_filtered_search("author:@#{user.username} #{search_term}")
wait_for_requests
expect_tokens([author_token(user.name)])
expect_issues_list_count(3)
expect_filtered_search_input(search_term)
end
it 'filters issues by searched author, assignee and text' do
input_filtered_search("author:@#{user.username} assignee:@#{user.username} #{search_term}")
wait_for_requests input_filtered_search("assignee:@#{user.username} author:@#{user.username} label:~#{caps_sensitive_label.title} milestone:%#{milestone.title} #{search_term}")
expect_tokens([author_token(user.name), assignee_token(user.name)])
expect_issues_list_count(3)
expect_filtered_search_input(search_term)
end
it 'filters issues by searched author, assignee, label, and text' do
input_filtered_search("author:@#{user.username} assignee:@#{user.username} label:~#{caps_sensitive_label.title} #{search_term}")
wait_for_requests wait_for_requests
expect_tokens([ expect_tokens([
author_token(user.name),
assignee_token(user.name), assignee_token(user.name),
label_token(caps_sensitive_label.title) author_token(user.name),
label_token(caps_sensitive_label.title),
milestone_token(milestone.title)
]) ])
expect_issues_list_count(1) expect_issues_list_count(1)
expect_filtered_search_input(search_term) expect_filtered_search_input(search_term)
end end
it 'filters issues by searched author, assignee, label, milestone and text' do describe 'filter issues by author' do
input_filtered_search("author:@#{user.username} assignee:@#{user.username} label:~#{caps_sensitive_label.title} milestone:%#{milestone.title} #{search_term}") context 'only author' do
it 'filters issues by searched author' do
input_filtered_search("author:@#{user.username}")
wait_for_requests wait_for_requests
expect_tokens([ expect_tokens([author_token(user.name)])
author_token(user.name), expect_issues_list_count(5)
assignee_token(user.name), expect_filtered_search_input_empty
label_token(caps_sensitive_label.title),
milestone_token(milestone.title)
])
expect_issues_list_count(1)
expect_filtered_search_input(search_term)
end end
end end
end end
...@@ -177,66 +119,13 @@ describe 'Filter issues', js: true do ...@@ -177,66 +119,13 @@ describe 'Filter issues', js: true do
input_filtered_search('assignee:none') input_filtered_search('assignee:none')
expect_tokens([assignee_token('none')]) expect_tokens([assignee_token('none')])
expect_issues_list_count(8, 1) expect_issues_list_count(3)
expect_filtered_search_input_empty expect_filtered_search_input_empty
end end
end end
context 'assignee with other filters' do
let(:search_term) { 'searchTerm' }
it 'filters issues by searched assignee and text' do
input_filtered_search("assignee:@#{user.username} #{search_term}")
wait_for_requests
expect_tokens([assignee_token(user.name)])
expect_issues_list_count(2)
expect_filtered_search_input(search_term)
end
it 'filters issues by searched assignee, author and text' do
input_filtered_search("assignee:@#{user.username} author:@#{user.username} #{search_term}")
wait_for_requests
expect_tokens([assignee_token(user.name), author_token(user.name)])
expect_issues_list_count(2)
expect_filtered_search_input(search_term)
end
it 'filters issues by searched assignee, author, label, text' do
input_filtered_search("assignee:@#{user.username} author:@#{user.username} label:~#{caps_sensitive_label.title} #{search_term}")
wait_for_requests
expect_tokens([
assignee_token(user.name),
author_token(user.name),
label_token(caps_sensitive_label.title)
])
expect_issues_list_count(1)
expect_filtered_search_input(search_term)
end
it 'filters issues by searched assignee, author, label, milestone and text' do
input_filtered_search("assignee:@#{user.username} author:@#{user.username} label:~#{caps_sensitive_label.title} milestone:%#{milestone.title} #{search_term}")
expect_tokens([
assignee_token(user.name),
author_token(user.name),
label_token(caps_sensitive_label.title),
milestone_token(milestone.title)
])
expect_issues_list_count(1)
expect_filtered_search_input(search_term)
end
end
end end
describe 'filter issues by label' do describe 'filter issues by label' do
let(:search_term) { 'bug' }
context 'only label' do context 'only label' do
it 'filters issues by searched label' do it 'filters issues by searched label' do
input_filtered_search("label:~#{bug_label.title}") input_filtered_search("label:~#{bug_label.title}")
...@@ -250,7 +139,7 @@ describe 'Filter issues', js: true do ...@@ -250,7 +139,7 @@ describe 'Filter issues', js: true do
input_filtered_search('label:none') input_filtered_search('label:none')
expect_tokens([label_token('none', false)]) expect_tokens([label_token('none', false)])
expect_issues_list_count(9, 1) expect_issues_list_count(8)
expect_filtered_search_input_empty expect_filtered_search_input_empty
end end
...@@ -277,13 +166,13 @@ describe 'Filter issues', js: true do ...@@ -277,13 +166,13 @@ describe 'Filter issues', js: true do
expect_filtered_search_input_empty expect_filtered_search_input_empty
end end
it 'does not show issues' do it 'does not show issues for unused labels' do
new_label = create(:label, project: project, title: 'new_label') new_label = create(:label, project: project, title: 'new_label')
input_filtered_search("label:~#{new_label.title}") input_filtered_search("label:~#{new_label.title}")
expect_tokens([label_token(new_label.title)]) expect_tokens([label_token(new_label.title)])
expect_no_issues_list() expect_no_issues_list
expect_filtered_search_input_empty expect_filtered_search_input_empty
end end
end end
...@@ -346,95 +235,10 @@ describe 'Filter issues', js: true do ...@@ -346,95 +235,10 @@ describe 'Filter issues', js: true do
end end
end end
context 'label with other filters' do
it 'filters issues by searched label and text' do
input_filtered_search("label:~#{caps_sensitive_label.title} #{search_term}")
expect_tokens([label_token(caps_sensitive_label.title)])
expect_issues_list_count(1)
expect_filtered_search_input(search_term)
end
it 'filters issues by searched label, author and text' do
input_filtered_search("label:~#{caps_sensitive_label.title} author:@#{user.username} #{search_term}")
wait_for_requests
expect_tokens([label_token(caps_sensitive_label.title), author_token(user.name)])
expect_issues_list_count(1)
expect_filtered_search_input(search_term)
end
it 'filters issues by searched label, author, assignee and text' do
input_filtered_search("label:~#{caps_sensitive_label.title} author:@#{user.username} assignee:@#{user.username} #{search_term}")
wait_for_requests
expect_tokens([
label_token(caps_sensitive_label.title),
author_token(user.name),
assignee_token(user.name)
])
expect_issues_list_count(1)
expect_filtered_search_input(search_term)
end
it 'filters issues by searched label, author, assignee, milestone and text' do
input_filtered_search("label:~#{caps_sensitive_label.title} author:@#{user.username} assignee:@#{user.username} milestone:%#{milestone.title} #{search_term}")
expect_tokens([
label_token(caps_sensitive_label.title),
author_token(user.name),
assignee_token(user.name),
milestone_token(milestone.title)
])
expect_issues_list_count(1)
expect_filtered_search_input(search_term)
end
end
context 'multiple labels with other filters' do context 'multiple labels with other filters' do
it 'filters issues by searched label, label2, and text' do
input_filtered_search("label:~#{bug_label.title} label:~#{caps_sensitive_label.title} #{search_term}")
expect_tokens([
label_token(bug_label.title),
label_token(caps_sensitive_label.title)
])
expect_issues_list_count(1)
expect_filtered_search_input(search_term)
end
it 'filters issues by searched label, label2, author and text' do
input_filtered_search("label:~#{bug_label.title} label:~#{caps_sensitive_label.title} author:@#{user.username} #{search_term}")
wait_for_requests
expect_tokens([
label_token(bug_label.title),
label_token(caps_sensitive_label.title),
author_token(user.name)
])
expect_issues_list_count(1)
expect_filtered_search_input(search_term)
end
it 'filters issues by searched label, label2, author, assignee and text' do
input_filtered_search("label:~#{bug_label.title} label:~#{caps_sensitive_label.title} author:@#{user.username} assignee:@#{user.username} #{search_term}")
wait_for_requests
expect_tokens([
label_token(bug_label.title),
label_token(caps_sensitive_label.title),
author_token(user.name),
assignee_token(user.name)
])
expect_issues_list_count(1)
expect_filtered_search_input(search_term)
end
it 'filters issues by searched label, label2, author, assignee, milestone and text' do it 'filters issues by searched label, label2, author, assignee, milestone and text' do
search_term = 'bug'
input_filtered_search("label:~#{bug_label.title} label:~#{caps_sensitive_label.title} author:@#{user.username} assignee:@#{user.username} milestone:%#{milestone.title} #{search_term}") input_filtered_search("label:~#{bug_label.title} label:~#{caps_sensitive_label.title} author:@#{user.username} assignee:@#{user.username} milestone:%#{milestone.title} #{search_term}")
wait_for_requests wait_for_requests
...@@ -452,15 +256,10 @@ describe 'Filter issues', js: true do ...@@ -452,15 +256,10 @@ describe 'Filter issues', js: true do
end end
context 'issue label clicked' do context 'issue label clicked' do
before do it 'filters and displays in search bar' do
find('.issues-list .issue .issue-main-info .issuable-info a .label', text: multiple_words_label.title).click find('.issues-list .issue .issue-main-info .issuable-info a .label', text: multiple_words_label.title).click
end
it 'filters' do
expect_issues_list_count(1) expect_issues_list_count(1)
end
it 'displays in search bar' do
expect_tokens([label_token("\"#{multiple_words_label.title}\"")]) expect_tokens([label_token("\"#{multiple_words_label.title}\"")])
expect_filtered_search_input_empty expect_filtered_search_input_empty
end end
...@@ -481,11 +280,15 @@ describe 'Filter issues', js: true do ...@@ -481,11 +280,15 @@ describe 'Filter issues', js: true do
input_filtered_search("milestone:none") input_filtered_search("milestone:none")
expect_tokens([milestone_token('none', false)]) expect_tokens([milestone_token('none', false)])
expect_issues_list_count(7, 1) expect_issues_list_count(3)
expect_filtered_search_input_empty expect_filtered_search_input_empty
end end
it 'filters issues by upcoming milestones' do it 'filters issues by upcoming milestones' do
create(:milestone, project: project, due_date: 1.month.from_now) do |future_milestone|
create(:issue, project: project, milestone: future_milestone, author: user)
end
input_filtered_search("milestone:upcoming") input_filtered_search("milestone:upcoming")
expect_tokens([milestone_token('upcoming', false)]) expect_tokens([milestone_token('upcoming', false)])
...@@ -503,7 +306,7 @@ describe 'Filter issues', js: true do ...@@ -503,7 +306,7 @@ describe 'Filter issues', js: true do
it 'filters issues by milestone containing special characters' do it 'filters issues by milestone containing special characters' do
special_milestone = create(:milestone, title: '!@\#{$%^&*()}', project: project) special_milestone = create(:milestone, title: '!@\#{$%^&*()}', project: project)
create(:issue, title: "Issue with special character milestone", project: project, milestone: special_milestone) create(:issue, project: project, milestone: special_milestone)
input_filtered_search("milestone:%#{special_milestone.title}") input_filtered_search("milestone:%#{special_milestone.title}")
...@@ -512,70 +315,16 @@ describe 'Filter issues', js: true do ...@@ -512,70 +315,16 @@ describe 'Filter issues', js: true do
expect_filtered_search_input_empty expect_filtered_search_input_empty
end end
it 'does not show issues' do it 'does not show issues for unused milestones' do
new_milestone = create(:milestone, title: "new", project: project) new_milestone = create(:milestone, title: 'new', project: project)
input_filtered_search("milestone:%#{new_milestone.title}") input_filtered_search("milestone:%#{new_milestone.title}")
expect_tokens([milestone_token(new_milestone.title)]) expect_tokens([milestone_token(new_milestone.title)])
expect_no_issues_list() expect_no_issues_list
expect_filtered_search_input_empty expect_filtered_search_input_empty
end end
end end
context 'milestone with other filters' do
let(:search_term) { 'bug' }
it 'filters issues by searched milestone and text' do
input_filtered_search("milestone:%#{milestone.title} #{search_term}")
expect_tokens([milestone_token(milestone.title)])
expect_issues_list_count(2)
expect_filtered_search_input(search_term)
end
it 'filters issues by searched milestone, author and text' do
input_filtered_search("milestone:%#{milestone.title} author:@#{user.username} #{search_term}")
wait_for_requests
expect_tokens([
milestone_token(milestone.title),
author_token(user.name)
])
expect_issues_list_count(2)
expect_filtered_search_input(search_term)
end
it 'filters issues by searched milestone, author, assignee and text' do
input_filtered_search("milestone:%#{milestone.title} author:@#{user.username} assignee:@#{user.username} #{search_term}")
wait_for_requests
expect_tokens([
milestone_token(milestone.title),
author_token(user.name),
assignee_token(user.name)
])
expect_issues_list_count(2)
expect_filtered_search_input(search_term)
end
it 'filters issues by searched milestone, author, assignee, label and text' do
input_filtered_search("milestone:%#{milestone.title} author:@#{user.username} assignee:@#{user.username} label:~#{bug_label.title} #{search_term}")
wait_for_requests
expect_tokens([
milestone_token(milestone.title),
author_token(user.name),
assignee_token(user.name),
label_token(bug_label.title)
])
expect_issues_list_count(2)
expect_filtered_search_input(search_term)
end
end
end end
describe 'filter issues by text' do describe 'filter issues by text' do
...@@ -584,7 +333,7 @@ describe 'Filter issues', js: true do ...@@ -584,7 +333,7 @@ describe 'Filter issues', js: true do
search = 'Bug' search = 'Bug'
input_filtered_search(search) input_filtered_search(search)
expect_issues_list_count(4, 1) expect_issues_list_count(4)
expect_filtered_search_input(search) expect_filtered_search_input(search)
end end
...@@ -605,112 +354,50 @@ describe 'Filter issues', js: true do ...@@ -605,112 +354,50 @@ describe 'Filter issues', js: true do
end end
it 'filters issues by searched text containing single quotes' do it 'filters issues by searched text containing single quotes' do
search = '\'single quotes\'' issue = create(:issue, project: project, author: user, title: "issue with 'single quotes'")
search = "'single quotes'"
input_filtered_search(search) input_filtered_search(search)
expect_issues_list_count(1) expect_issues_list_count(1)
expect_filtered_search_input(search) expect_filtered_search_input(search)
expect(page).to have_content(issue.title)
end end
it 'filters issues by searched text containing double quotes' do it 'filters issues by searched text containing double quotes' do
issue = create(:issue, project: project, author: user, title: "issue with \"double quotes\"")
search = '"double quotes"' search = '"double quotes"'
input_filtered_search(search) input_filtered_search(search)
expect_issues_list_count(1) expect_issues_list_count(1)
expect_filtered_search_input(search) expect_filtered_search_input(search)
expect(page).to have_content(issue.title)
end end
it 'filters issues by searched text containing special characters' do it 'filters issues by searched text containing special characters' do
issue = create(:issue, project: project, author: user, title: "issue with !@\#{$%^&*()-+")
search = '!@#{$%^&*()-+' search = '!@#{$%^&*()-+'
input_filtered_search(search) input_filtered_search(search)
expect_issues_list_count(1) expect_issues_list_count(1)
expect_filtered_search_input(search) expect_filtered_search_input(search)
expect(page).to have_content(issue.title)
end end
it 'does not show any issues' do it 'does not show any issues' do
search = 'testing' search = 'testing'
input_filtered_search(search) input_filtered_search(search)
expect_no_issues_list() expect_no_issues_list
expect_filtered_search_input(search) expect_filtered_search_input(search)
end end
end end
context 'searched text with other filters' do context 'searched text with other filters' do
it 'filters issues by searched text and author' do
# After searching, all search terms are placed at the end
input_filtered_search("bug author:@#{user.username}")
expect_issues_list_count(2)
expect_filtered_search_input('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('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('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('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} foo")
expect_issues_list_count(1)
expect_filtered_search_input('bug report foo')
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('bug')
end
it 'filters issues by searched text, author, text, assignee, text, label and text' do
input_filtered_search("bug author:@#{user.username} assignee:@#{user.username} report label:~#{bug_label.title} foo")
expect_issues_list_count(1)
expect_filtered_search_input('bug report foo')
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('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} assignee:@#{user.username} report label:~#{bug_label.title} milestone:%#{milestone.title} foo")
expect_issues_list_count(1)
expect_filtered_search_input('bug report foo')
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('bug')
end
it 'filters issues by searched text, author, text, assignee, text, label1, text, label2, text, milestone and text' do 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} assignee:@#{user.username} report label:~#{bug_label.title} label:~#{caps_sensitive_label.title} milestone:%#{milestone.title} foo") input_filtered_search("bug author:@#{user.username} report label:~#{bug_label.title} label:~#{caps_sensitive_label.title} milestone:%#{milestone.title} foo")
expect_issues_list_count(1) expect_issues_list_count(1)
expect_filtered_search_input('bug report foo') expect_filtered_search_input('bug report foo')
...@@ -748,7 +435,9 @@ describe 'Filter issues', js: true do ...@@ -748,7 +435,9 @@ describe 'Filter issues', js: true do
end end
end end
describe 'retains filter when switching issue states' do describe 'switching issue states' do
let!(:closed_issue) { create(:issue, :closed, project: project, title: 'closed bug') }
before do before do
input_filtered_search('bug') input_filtered_search('bug')
...@@ -756,25 +445,21 @@ describe 'Filter issues', js: true do ...@@ -756,25 +445,21 @@ describe 'Filter issues', js: true do
expect_issues_list_count(4, 1) expect_issues_list_count(4, 1)
end end
it 'open state' do it 'maintains filter' do
# Closed
find('.issues-state-filters [data-state="closed"]').click find('.issues-state-filters [data-state="closed"]').click
wait_for_requests wait_for_requests
expect(page).to have_selector('.issues-list .issue', count: 1)
expect(page).to have_link(closed_issue.title)
# Opened
find('.issues-state-filters [data-state="opened"]').click find('.issues-state-filters [data-state="opened"]').click
wait_for_requests wait_for_requests
expect(page).to have_selector('.issues-list .issue', count: 4) expect(page).to have_selector('.issues-list .issue', count: 4)
end
it 'closed state' do # All
find('.issues-state-filters [data-state="closed"]').click
wait_for_requests
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
it 'all state' do
find('.issues-state-filters [data-state="all"]').click find('.issues-state-filters [data-state="all"]').click
wait_for_requests wait_for_requests
...@@ -783,34 +468,39 @@ describe 'Filter issues', js: true do ...@@ -783,34 +468,39 @@ describe 'Filter issues', js: true do
end end
describe 'RSS feeds' do describe 'RSS feeds' do
it 'updates atom feed link for project issues' do let(:group) { create(:group) }
visit project_issues_path(project, milestone_title: milestone.title, assignee_id: user.id) let(:project) { create(:project, group: group) }
before do
group.add_developer(user)
end
shared_examples 'updates atom feed link' do |type|
it "for #{type}" do
visit path
link = find_link('Subscribe') link = find_link('Subscribe')
params = CGI.parse(URI.parse(link[:href]).query) params = CGI.parse(URI.parse(link[:href]).query)
auto_discovery_link = find('link[type="application/atom+xml"]', visible: false) auto_discovery_link = find('link[type="application/atom+xml"]', visible: false)
auto_discovery_params = CGI.parse(URI.parse(auto_discovery_link[:href]).query) auto_discovery_params = CGI.parse(URI.parse(auto_discovery_link[:href]).query)
expect(params).to include('rss_token' => [user.rss_token]) expected = {
expect(params).to include('milestone_title' => [milestone.title]) 'rss_token' => [user.rss_token],
expect(params).to include('assignee_id' => [user.id.to_s]) 'milestone_title' => [milestone.title],
expect(auto_discovery_params).to include('rss_token' => [user.rss_token]) 'assignee_id' => [user.id.to_s]
expect(auto_discovery_params).to include('milestone_title' => [milestone.title]) }
expect(auto_discovery_params).to include('assignee_id' => [user.id.to_s])
expect(params).to include(expected)
expect(auto_discovery_params).to include(expected)
end
end end
it 'updates atom feed link for group issues' do it_behaves_like 'updates atom feed link', :project do
visit issues_group_path(group, milestone_title: milestone.title, assignee_id: user.id) let(:path) { project_issues_path(project, milestone_title: milestone.title, assignee_id: user.id) }
link = find('.breadcrumbs a', text: 'Subscribe') end
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('rss_token' => [user.rss_token]) it_behaves_like 'updates atom feed link', :group do
expect(params).to include('milestone_title' => [milestone.title]) let(:path) { issues_group_path(group, milestone_title: milestone.title, assignee_id: user.id) }
expect(params).to include('assignee_id' => [user.id.to_s])
expect(auto_discovery_params).to include('rss_token' => [user.rss_token])
expect(auto_discovery_params).to include('milestone_title' => [milestone.title])
expect(auto_discovery_params).to include('assignee_id' => [user.id.to_s])
end end
end end
...@@ -823,7 +513,7 @@ describe 'Filter issues', js: true do ...@@ -823,7 +513,7 @@ describe 'Filter issues', js: true do
input_filtered_search("milestone:", submit: false) input_filtered_search("milestone:", submit: false)
within('#js-dropdown-milestone') do within('#js-dropdown-milestone') do
expect(page).to have_selector('.filter-dropdown .filter-dropdown-item', count: 2) expect(page).to have_selector('.filter-dropdown .filter-dropdown-item', count: 1)
end end
end end
...@@ -831,7 +521,7 @@ describe 'Filter issues', js: true do ...@@ -831,7 +521,7 @@ describe 'Filter issues', js: true do
input_filtered_search("label:", submit: false) input_filtered_search("label:", submit: false)
within('#js-dropdown-label') do within('#js-dropdown-label') do
expect(page).to have_selector('.filter-dropdown .filter-dropdown-item', count: 5) expect(page).to have_selector('.filter-dropdown .filter-dropdown-item', count: 3)
end end
end end
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