Commit f8556d02 authored by Rémy Coutable's avatar Rémy Coutable

Merge branch 'search-spec' into 'master'

Change find to within for detecting bad search specs

Closes #35460

See merge request !13383
parents fcce6c31 b84d6efa
...@@ -134,8 +134,10 @@ describe 'Dropdown assignee', :js do ...@@ -134,8 +134,10 @@ describe 'Dropdown assignee', :js 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)
wait_for_requests
expect(page).to have_css(js_dropdown_assignee, visible: false) expect(page).to have_css(js_dropdown_assignee, visible: false)
expect_tokens([{ name: 'assignee', value: "@#{user_jacob.username}" }]) expect_tokens([assignee_token(user_jacob.name)])
expect_filtered_search_input_empty expect_filtered_search_input_empty
end end
...@@ -143,8 +145,10 @@ describe 'Dropdown assignee', :js do ...@@ -143,8 +145,10 @@ describe 'Dropdown assignee', :js do
filtered_search.send_keys('roo') filtered_search.send_keys('roo')
click_assignee(user.name) click_assignee(user.name)
wait_for_requests
expect(page).to have_css(js_dropdown_assignee, visible: false) expect(page).to have_css(js_dropdown_assignee, visible: false)
expect_tokens([{ name: 'assignee', value: "@#{user.username}" }]) expect_tokens([assignee_token(user.name)])
expect_filtered_search_input_empty expect_filtered_search_input_empty
end end
...@@ -152,7 +156,7 @@ describe 'Dropdown assignee', :js do ...@@ -152,7 +156,7 @@ describe 'Dropdown assignee', :js 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_tokens([{ name: 'assignee', value: 'none' }]) expect_tokens([assignee_token('none')])
expect_filtered_search_input_empty expect_filtered_search_input_empty
end end
end end
...@@ -171,7 +175,7 @@ describe 'Dropdown assignee', :js do ...@@ -171,7 +175,7 @@ describe 'Dropdown assignee', :js do
find('#js-dropdown-assignee .filter-dropdown-item', text: user.username).click find('#js-dropdown-assignee .filter-dropdown-item', text: user.username).click
expect(page).to have_css(js_dropdown_assignee, visible: false) expect(page).to have_css(js_dropdown_assignee, visible: false)
expect_tokens([{ name: 'assignee', value: user.username }]) expect_tokens([assignee_token(user.username)])
expect_filtered_search_input_empty expect_filtered_search_input_empty
end end
end end
......
...@@ -121,16 +121,20 @@ describe 'Dropdown author', js: true do ...@@ -121,16 +121,20 @@ describe 'Dropdown author', js: 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)
wait_for_requests
expect(page).to have_css(js_dropdown_author, visible: false) expect(page).to have_css(js_dropdown_author, visible: false)
expect_tokens([{ name: 'author', value: "@#{user_jacob.username}" }]) expect_tokens([author_token(user_jacob.name)])
expect_filtered_search_input_empty expect_filtered_search_input_empty
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)
wait_for_requests
expect(page).to have_css(js_dropdown_author, visible: false) expect(page).to have_css(js_dropdown_author, visible: false)
expect_tokens([{ name: 'author', value: "@#{user.username}" }]) expect_tokens([author_token(user.name)])
expect_filtered_search_input_empty expect_filtered_search_input_empty
end end
end end
...@@ -149,7 +153,7 @@ describe 'Dropdown author', js: true do ...@@ -149,7 +153,7 @@ describe 'Dropdown author', js: true do
find('#js-dropdown-author .filter-dropdown-item', text: user.username).click find('#js-dropdown-author .filter-dropdown-item', text: user.username).click
expect(page).to have_css(js_dropdown_author, visible: false) expect(page).to have_css(js_dropdown_author, visible: false)
expect_tokens([{ name: 'author', value: user.username }]) expect_tokens([author_token(user.username)])
expect_filtered_search_input_empty expect_filtered_search_input_empty
end end
end end
......
...@@ -47,7 +47,7 @@ describe 'Dropdown label', js: true do ...@@ -47,7 +47,7 @@ describe 'Dropdown label', js: true do
filtered_search.native.send_keys(:down, :down, :enter) filtered_search.native.send_keys(:down, :down, :enter)
expect_tokens([{ name: 'label', value: "~#{bug_label.title}" }]) expect_tokens([label_token(bug_label.title)])
expect_filtered_search_input_empty expect_filtered_search_input_empty
end end
end end
...@@ -178,7 +178,7 @@ describe 'Dropdown label', js: true do ...@@ -178,7 +178,7 @@ describe 'Dropdown label', js: true do
click_label(bug_label.title) click_label(bug_label.title)
expect(page).not_to have_css(js_dropdown_label) expect(page).not_to have_css(js_dropdown_label)
expect_tokens([{ name: 'label', value: "~#{bug_label.title}" }]) expect_tokens([label_token(bug_label.title)])
expect_filtered_search_input_empty expect_filtered_search_input_empty
end end
...@@ -187,7 +187,7 @@ describe 'Dropdown label', js: true do ...@@ -187,7 +187,7 @@ describe 'Dropdown label', js: true do
click_label(bug_label.title) click_label(bug_label.title)
expect(page).not_to have_css(js_dropdown_label) expect(page).not_to have_css(js_dropdown_label)
expect_tokens([{ name: 'label', value: "~#{bug_label.title}" }]) expect_tokens([label_token(bug_label.title)])
expect_filtered_search_input_empty expect_filtered_search_input_empty
end end
...@@ -195,7 +195,7 @@ describe 'Dropdown label', js: true do ...@@ -195,7 +195,7 @@ describe 'Dropdown label', js: true do
click_label(two_words_label.title) click_label(two_words_label.title)
expect(page).not_to have_css(js_dropdown_label) expect(page).not_to have_css(js_dropdown_label)
expect_tokens([{ name: 'label', value: "\"#{two_words_label.title}\"" }]) expect_tokens([label_token("\"#{two_words_label.title}\"")])
expect_filtered_search_input_empty expect_filtered_search_input_empty
end end
...@@ -203,7 +203,7 @@ describe 'Dropdown label', js: true do ...@@ -203,7 +203,7 @@ describe 'Dropdown label', js: true do
click_label(long_label.title) click_label(long_label.title)
expect(page).not_to have_css(js_dropdown_label) expect(page).not_to have_css(js_dropdown_label)
expect_tokens([{ name: 'label', value: "\"#{long_label.title}\"" }]) expect_tokens([label_token("\"#{long_label.title}\"")])
expect_filtered_search_input_empty expect_filtered_search_input_empty
end end
...@@ -211,7 +211,7 @@ describe 'Dropdown label', js: true do ...@@ -211,7 +211,7 @@ describe 'Dropdown label', js: true do
click_label(wont_fix_label.title) click_label(wont_fix_label.title)
expect(page).not_to have_css(js_dropdown_label) expect(page).not_to have_css(js_dropdown_label)
expect_tokens([{ name: 'label', value: "~'#{wont_fix_label.title}'" }]) expect_tokens([label_token("'#{wont_fix_label.title}'")])
expect_filtered_search_input_empty expect_filtered_search_input_empty
end end
...@@ -219,7 +219,7 @@ describe 'Dropdown label', js: true do ...@@ -219,7 +219,7 @@ describe 'Dropdown label', js: true do
click_label(uppercase_label.title) click_label(uppercase_label.title)
expect(page).not_to have_css(js_dropdown_label) expect(page).not_to have_css(js_dropdown_label)
expect_tokens([{ name: 'label', value: "~#{uppercase_label.title}" }]) expect_tokens([label_token(uppercase_label.title)])
expect_filtered_search_input_empty expect_filtered_search_input_empty
end end
...@@ -227,7 +227,7 @@ describe 'Dropdown label', js: true do ...@@ -227,7 +227,7 @@ describe 'Dropdown label', js: true do
click_label(special_label.title) click_label(special_label.title)
expect(page).not_to have_css(js_dropdown_label) expect(page).not_to have_css(js_dropdown_label)
expect_tokens([{ name: 'label', value: "~#{special_label.title}" }]) expect_tokens([label_token(special_label.title)])
expect_filtered_search_input_empty expect_filtered_search_input_empty
end end
...@@ -235,7 +235,7 @@ describe 'Dropdown label', js: true do ...@@ -235,7 +235,7 @@ describe 'Dropdown label', js: true 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).not_to have_css(js_dropdown_label) expect(page).not_to have_css(js_dropdown_label)
expect_tokens([{ name: 'label', value: 'none' }]) expect_tokens([label_token('none', false)])
expect_filtered_search_input_empty expect_filtered_search_input_empty
end end
end end
......
...@@ -134,7 +134,7 @@ describe 'Dropdown milestone', :js do ...@@ -134,7 +134,7 @@ describe 'Dropdown milestone', :js 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_tokens([{ name: 'milestone', value: "%#{milestone.title}" }]) expect_tokens([milestone_token(milestone.title)])
expect_filtered_search_input_empty expect_filtered_search_input_empty
end end
...@@ -143,7 +143,7 @@ describe 'Dropdown milestone', :js do ...@@ -143,7 +143,7 @@ describe 'Dropdown milestone', :js 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_tokens([{ name: 'milestone', value: "%#{milestone.title}" }]) expect_tokens([milestone_token(milestone.title)])
expect_filtered_search_input_empty expect_filtered_search_input_empty
end end
...@@ -151,7 +151,7 @@ describe 'Dropdown milestone', :js do ...@@ -151,7 +151,7 @@ describe 'Dropdown milestone', :js 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_tokens([{ name: 'milestone', value: "%\"#{two_words_milestone.title}\"" }]) expect_tokens([milestone_token("\"#{two_words_milestone.title}\"")])
expect_filtered_search_input_empty expect_filtered_search_input_empty
end end
...@@ -159,7 +159,7 @@ describe 'Dropdown milestone', :js do ...@@ -159,7 +159,7 @@ describe 'Dropdown milestone', :js 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_tokens([{ name: 'milestone', value: "%\"#{long_milestone.title}\"" }]) expect_tokens([milestone_token("\"#{long_milestone.title}\"")])
expect_filtered_search_input_empty expect_filtered_search_input_empty
end end
...@@ -167,7 +167,7 @@ describe 'Dropdown milestone', :js do ...@@ -167,7 +167,7 @@ describe 'Dropdown milestone', :js 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_tokens([{ name: 'milestone', value: "%'#{wont_fix_milestone.title}'" }]) expect_tokens([milestone_token("'#{wont_fix_milestone.title}'")])
expect_filtered_search_input_empty expect_filtered_search_input_empty
end end
...@@ -175,7 +175,7 @@ describe 'Dropdown milestone', :js do ...@@ -175,7 +175,7 @@ describe 'Dropdown milestone', :js 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_tokens([{ name: 'milestone', value: "%#{uppercase_milestone.title}" }]) expect_tokens([milestone_token(uppercase_milestone.title)])
expect_filtered_search_input_empty expect_filtered_search_input_empty
end end
...@@ -183,7 +183,7 @@ describe 'Dropdown milestone', :js do ...@@ -183,7 +183,7 @@ describe 'Dropdown milestone', :js 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_tokens([{ name: 'milestone', value: "%#{special_milestone.title}" }]) expect_tokens([milestone_token(special_milestone.title)])
expect_filtered_search_input_empty expect_filtered_search_input_empty
end end
...@@ -191,7 +191,7 @@ describe 'Dropdown milestone', :js do ...@@ -191,7 +191,7 @@ describe 'Dropdown milestone', :js 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_tokens([{ name: 'milestone', value: 'none' }]) expect_tokens([milestone_token('none', false)])
expect_filtered_search_input_empty expect_filtered_search_input_empty
end end
...@@ -199,7 +199,7 @@ describe 'Dropdown milestone', :js do ...@@ -199,7 +199,7 @@ describe 'Dropdown milestone', :js 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_tokens([{ name: 'milestone', value: 'upcoming' }]) expect_tokens([milestone_token('upcoming', false)])
expect_filtered_search_input_empty expect_filtered_search_input_empty
end end
...@@ -207,7 +207,7 @@ describe 'Dropdown milestone', :js do ...@@ -207,7 +207,7 @@ describe 'Dropdown milestone', :js do
click_static_milestone('Started') click_static_milestone('Started')
expect(page).to have_css(js_dropdown_milestone, visible: false) expect(page).to have_css(js_dropdown_milestone, visible: false)
expect_tokens([{ name: 'milestone', value: 'started' }]) expect_tokens([milestone_token('started', false)])
expect_filtered_search_input_empty expect_filtered_search_input_empty
end end
end end
......
...@@ -97,7 +97,9 @@ describe 'Filter issues', js: true do ...@@ -97,7 +97,9 @@ describe 'Filter issues', js: true do
it 'filters issues by searched author' do it 'filters issues by searched author' do
input_filtered_search("author:@#{user.username}") input_filtered_search("author:@#{user.username}")
expect_tokens([{ name: 'author', value: user.username }]) wait_for_requests
expect_tokens([author_token(user.name)])
expect_issues_list_count(5) expect_issues_list_count(5)
expect_filtered_search_input_empty expect_filtered_search_input_empty
end end
...@@ -117,7 +119,9 @@ describe 'Filter issues', js: true do ...@@ -117,7 +119,9 @@ describe 'Filter issues', js: true do
it 'filters issues by searched author and text' do it 'filters issues by searched author and text' do
input_filtered_search("author:@#{user.username} #{search_term}") input_filtered_search("author:@#{user.username} #{search_term}")
expect_tokens([{ name: 'author', value: user.username }]) wait_for_requests
expect_tokens([author_token(user.name)])
expect_issues_list_count(3) expect_issues_list_count(3)
expect_filtered_search_input(search_term) expect_filtered_search_input(search_term)
end end
...@@ -125,10 +129,9 @@ describe 'Filter issues', js: true do ...@@ -125,10 +129,9 @@ describe 'Filter issues', js: true do
it 'filters issues by searched author, assignee and text' do it 'filters issues by searched author, assignee and text' do
input_filtered_search("author:@#{user.username} assignee:@#{user.username} #{search_term}") input_filtered_search("author:@#{user.username} assignee:@#{user.username} #{search_term}")
expect_tokens([ wait_for_requests
{ name: 'author', value: user.username },
{ name: 'assignee', value: user.username } expect_tokens([author_token(user.name), assignee_token(user.name)])
])
expect_issues_list_count(3) expect_issues_list_count(3)
expect_filtered_search_input(search_term) expect_filtered_search_input(search_term)
end end
...@@ -136,10 +139,12 @@ describe 'Filter issues', js: true do ...@@ -136,10 +139,12 @@ describe 'Filter issues', js: true do
it 'filters issues by searched author, assignee, label, and text' do 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}") input_filtered_search("author:@#{user.username} assignee:@#{user.username} label:~#{caps_sensitive_label.title} #{search_term}")
wait_for_requests
expect_tokens([ expect_tokens([
{ name: 'author', value: user.username }, author_token(user.name),
{ name: 'assignee', value: user.username }, assignee_token(user.name),
{ name: 'label', value: caps_sensitive_label.title } label_token(caps_sensitive_label.title)
]) ])
expect_issues_list_count(1) expect_issues_list_count(1)
expect_filtered_search_input(search_term) expect_filtered_search_input(search_term)
...@@ -148,11 +153,13 @@ describe 'Filter issues', js: true do ...@@ -148,11 +153,13 @@ describe 'Filter issues', js: true do
it 'filters issues by searched author, assignee, label, milestone and text' do it 'filters issues by searched author, assignee, label, milestone and text' do
input_filtered_search("author:@#{user.username} assignee:@#{user.username} label:~#{caps_sensitive_label.title} milestone:%#{milestone.title} #{search_term}") input_filtered_search("author:@#{user.username} assignee:@#{user.username} label:~#{caps_sensitive_label.title} milestone:%#{milestone.title} #{search_term}")
wait_for_requests
expect_tokens([ expect_tokens([
{ name: 'author', value: user.username }, author_token(user.name),
{ name: 'assignee', value: user.username }, assignee_token(user.name),
{ name: 'label', value: caps_sensitive_label.title }, label_token(caps_sensitive_label.title),
{ name: 'milestone', value: milestone.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)
...@@ -169,7 +176,9 @@ describe 'Filter issues', js: true do ...@@ -169,7 +176,9 @@ describe 'Filter issues', js: true do
it 'filters issues by searched assignee' do it 'filters issues by searched assignee' do
input_filtered_search("assignee:@#{user.username}") input_filtered_search("assignee:@#{user.username}")
expect_tokens([{ name: 'assignee', value: user.username }]) wait_for_requests
expect_tokens([assignee_token(user.name)])
expect_issues_list_count(5) expect_issues_list_count(5)
expect_filtered_search_input_empty expect_filtered_search_input_empty
end end
...@@ -177,7 +186,7 @@ describe 'Filter issues', js: true do ...@@ -177,7 +186,7 @@ describe 'Filter issues', js: true do
it 'filters issues by no assignee' do it 'filters issues by no assignee' do
input_filtered_search('assignee:none') input_filtered_search('assignee:none')
expect_tokens([{ name: 'assignee', value: 'none' }]) expect_tokens([assignee_token('none')])
expect_issues_list_count(8, 1) expect_issues_list_count(8, 1)
expect_filtered_search_input_empty expect_filtered_search_input_empty
end end
...@@ -197,7 +206,9 @@ describe 'Filter issues', js: true do ...@@ -197,7 +206,9 @@ describe 'Filter issues', js: true do
it 'filters issues by searched assignee and text' do it 'filters issues by searched assignee and text' do
input_filtered_search("assignee:@#{user.username} #{search_term}") input_filtered_search("assignee:@#{user.username} #{search_term}")
expect_tokens([{ name: 'assignee', value: user.username }]) wait_for_requests
expect_tokens([assignee_token(user.name)])
expect_issues_list_count(2) expect_issues_list_count(2)
expect_filtered_search_input(search_term) expect_filtered_search_input(search_term)
end end
...@@ -205,10 +216,9 @@ describe 'Filter issues', js: true do ...@@ -205,10 +216,9 @@ describe 'Filter issues', js: true do
it 'filters issues by searched assignee, author and text' do it 'filters issues by searched assignee, author and text' do
input_filtered_search("assignee:@#{user.username} author:@#{user.username} #{search_term}") input_filtered_search("assignee:@#{user.username} author:@#{user.username} #{search_term}")
expect_tokens([ wait_for_requests
{ name: 'assignee', value: user.username },
{ name: 'author', value: user.username } expect_tokens([assignee_token(user.name), author_token(user.name)])
])
expect_issues_list_count(2) expect_issues_list_count(2)
expect_filtered_search_input(search_term) expect_filtered_search_input(search_term)
end end
...@@ -216,10 +226,12 @@ describe 'Filter issues', js: true do ...@@ -216,10 +226,12 @@ describe 'Filter issues', js: true do
it 'filters issues by searched assignee, author, label, text' do 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}") input_filtered_search("assignee:@#{user.username} author:@#{user.username} label:~#{caps_sensitive_label.title} #{search_term}")
wait_for_requests
expect_tokens([ expect_tokens([
{ name: 'assignee', value: user.username }, assignee_token(user.name),
{ name: 'author', value: user.username }, author_token(user.name),
{ name: 'label', value: caps_sensitive_label.title } label_token(caps_sensitive_label.title)
]) ])
expect_issues_list_count(1) expect_issues_list_count(1)
expect_filtered_search_input(search_term) expect_filtered_search_input(search_term)
...@@ -229,10 +241,10 @@ describe 'Filter issues', js: true do ...@@ -229,10 +241,10 @@ describe 'Filter issues', js: true do
input_filtered_search("assignee:@#{user.username} author:@#{user.username} label:~#{caps_sensitive_label.title} milestone:%#{milestone.title} #{search_term}") input_filtered_search("assignee:@#{user.username} author:@#{user.username} label:~#{caps_sensitive_label.title} milestone:%#{milestone.title} #{search_term}")
expect_tokens([ expect_tokens([
{ name: 'assignee', value: user.username }, assignee_token(user.name),
{ name: 'author', value: user.username }, author_token(user.name),
{ name: 'label', value: caps_sensitive_label.title }, label_token(caps_sensitive_label.title),
{ name: 'milestone', value: milestone.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)
...@@ -253,7 +265,7 @@ describe 'Filter issues', js: true do ...@@ -253,7 +265,7 @@ describe 'Filter issues', js: true 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}")
expect_tokens([{ name: 'label', value: bug_label.title }]) expect_tokens([label_token(bug_label.title)])
expect_issues_list_count(2) expect_issues_list_count(2)
expect_filtered_search_input_empty expect_filtered_search_input_empty
end end
...@@ -261,7 +273,7 @@ describe 'Filter issues', js: true do ...@@ -261,7 +273,7 @@ describe 'Filter issues', js: true do
it 'filters issues by no label' do it 'filters issues by no label' do
input_filtered_search('label:none') input_filtered_search('label:none')
expect_tokens([{ name: 'label', value: 'none' }]) expect_tokens([label_token('none', false)])
expect_issues_list_count(9, 1) expect_issues_list_count(9, 1)
expect_filtered_search_input_empty expect_filtered_search_input_empty
end end
...@@ -274,8 +286,8 @@ describe 'Filter issues', js: true do ...@@ -274,8 +286,8 @@ describe 'Filter issues', js: true do
input_filtered_search("label:~#{bug_label.title} label:~#{caps_sensitive_label.title}") input_filtered_search("label:~#{bug_label.title} label:~#{caps_sensitive_label.title}")
expect_tokens([ expect_tokens([
{ name: 'label', value: bug_label.title }, label_token(bug_label.title),
{ name: 'label', value: caps_sensitive_label.title } label_token(caps_sensitive_label.title)
]) ])
expect_issues_list_count(1) expect_issues_list_count(1)
expect_filtered_search_input_empty expect_filtered_search_input_empty
...@@ -287,7 +299,8 @@ describe 'Filter issues', js: true do ...@@ -287,7 +299,8 @@ describe 'Filter issues', js: true do
special_issue.labels << special_label special_issue.labels << special_label
input_filtered_search("label:~#{special_label.title}") input_filtered_search("label:~#{special_label.title}")
expect_tokens([{ name: 'label', value: special_label.title }])
expect_tokens([label_token(special_label.title)])
expect_issues_list_count(1) expect_issues_list_count(1)
expect_filtered_search_input_empty expect_filtered_search_input_empty
end end
...@@ -297,7 +310,7 @@ describe 'Filter issues', js: true do ...@@ -297,7 +310,7 @@ describe 'Filter issues', js: true do
input_filtered_search("label:~#{new_label.title}") input_filtered_search("label:~#{new_label.title}")
expect_tokens([{ name: 'label', value: 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
...@@ -311,25 +324,27 @@ describe 'Filter issues', js: true do ...@@ -311,25 +324,27 @@ describe 'Filter issues', js: true do
input_filtered_search("label:~'#{special_multiple_label.title}'") input_filtered_search("label:~'#{special_multiple_label.title}'")
# filtered search defaults quotations to double quotes # Check for search results (which makes sure that the page has changed)
expect_tokens([{ name: 'label', value: "\"#{special_multiple_label.title}\"" }])
expect_issues_list_count(1) expect_issues_list_count(1)
# filtered search defaults quotations to double quotes
expect_tokens([label_token("\"#{special_multiple_label.title}\"")])
expect_filtered_search_input_empty expect_filtered_search_input_empty
end end
it 'single quotes' do it 'single quotes' do
input_filtered_search("label:~'#{multiple_words_label.title}'") input_filtered_search("label:~'#{multiple_words_label.title}'")
expect_tokens([{ name: 'label', value: "\"#{multiple_words_label.title}\"" }])
expect_issues_list_count(1) expect_issues_list_count(1)
expect_tokens([label_token("\"#{multiple_words_label.title}\"")])
expect_filtered_search_input_empty expect_filtered_search_input_empty
end end
it 'double quotes' do it 'double quotes' do
input_filtered_search("label:~\"#{multiple_words_label.title}\"") input_filtered_search("label:~\"#{multiple_words_label.title}\"")
expect_tokens([{ name: 'label', value: "\"#{multiple_words_label.title}\"" }]) expect_tokens([label_token("\"#{multiple_words_label.title}\"")])
expect_issues_list_count(1) expect_issues_list_count(1)
expect_filtered_search_input_empty expect_filtered_search_input_empty
end end
...@@ -341,7 +356,7 @@ describe 'Filter issues', js: true do ...@@ -341,7 +356,7 @@ describe 'Filter issues', js: true do
input_filtered_search("label:~'#{double_quotes_label.title}'") input_filtered_search("label:~'#{double_quotes_label.title}'")
expect_tokens([{ name: 'label', value: "'#{double_quotes_label.title}'" }]) expect_tokens([label_token("'#{double_quotes_label.title}'")])
expect_issues_list_count(1) expect_issues_list_count(1)
expect_filtered_search_input_empty expect_filtered_search_input_empty
end end
...@@ -353,7 +368,7 @@ describe 'Filter issues', js: true do ...@@ -353,7 +368,7 @@ describe 'Filter issues', js: true do
input_filtered_search("label:~\"#{single_quotes_label.title}\"") input_filtered_search("label:~\"#{single_quotes_label.title}\"")
expect_tokens([{ name: 'label', value: "\"#{single_quotes_label.title}\"" }]) expect_tokens([label_token("\"#{single_quotes_label.title}\"")])
expect_issues_list_count(1) expect_issues_list_count(1)
expect_filtered_search_input_empty expect_filtered_search_input_empty
end end
...@@ -363,7 +378,7 @@ describe 'Filter issues', js: true do ...@@ -363,7 +378,7 @@ describe 'Filter issues', js: true do
it 'filters issues by searched label and text' do it 'filters issues by searched label and text' do
input_filtered_search("label:~#{caps_sensitive_label.title} #{search_term}") input_filtered_search("label:~#{caps_sensitive_label.title} #{search_term}")
expect_tokens([{ name: 'label', value: caps_sensitive_label.title }]) expect_tokens([label_token(caps_sensitive_label.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
...@@ -371,10 +386,9 @@ describe 'Filter issues', js: true do ...@@ -371,10 +386,9 @@ describe 'Filter issues', js: true do
it 'filters issues by searched label, author and text' do it 'filters issues by searched label, author and text' do
input_filtered_search("label:~#{caps_sensitive_label.title} author:@#{user.username} #{search_term}") input_filtered_search("label:~#{caps_sensitive_label.title} author:@#{user.username} #{search_term}")
expect_tokens([ wait_for_requests
{ name: 'label', value: caps_sensitive_label.title },
{ name: 'author', value: user.username } expect_tokens([label_token(caps_sensitive_label.title), author_token(user.name)])
])
expect_issues_list_count(1) expect_issues_list_count(1)
expect_filtered_search_input(search_term) expect_filtered_search_input(search_term)
end end
...@@ -382,10 +396,12 @@ describe 'Filter issues', js: true do ...@@ -382,10 +396,12 @@ describe 'Filter issues', js: true do
it 'filters issues by searched label, author, assignee and text' do 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}") input_filtered_search("label:~#{caps_sensitive_label.title} author:@#{user.username} assignee:@#{user.username} #{search_term}")
wait_for_requests
expect_tokens([ expect_tokens([
{ name: 'label', value: caps_sensitive_label.title }, label_token(caps_sensitive_label.title),
{ name: 'author', value: user.username }, author_token(user.name),
{ name: 'assignee', value: user.username } assignee_token(user.name)
]) ])
expect_issues_list_count(1) expect_issues_list_count(1)
expect_filtered_search_input(search_term) expect_filtered_search_input(search_term)
...@@ -395,10 +411,10 @@ describe 'Filter issues', js: true do ...@@ -395,10 +411,10 @@ describe 'Filter issues', js: true do
input_filtered_search("label:~#{caps_sensitive_label.title} author:@#{user.username} assignee:@#{user.username} milestone:%#{milestone.title} #{search_term}") input_filtered_search("label:~#{caps_sensitive_label.title} author:@#{user.username} assignee:@#{user.username} milestone:%#{milestone.title} #{search_term}")
expect_tokens([ expect_tokens([
{ name: 'label', value: caps_sensitive_label.title }, label_token(caps_sensitive_label.title),
{ name: 'author', value: user.username }, author_token(user.name),
{ name: 'assignee', value: user.username }, assignee_token(user.name),
{ name: 'milestone', value: milestone.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)
...@@ -410,8 +426,8 @@ describe 'Filter issues', js: true do ...@@ -410,8 +426,8 @@ describe 'Filter issues', js: true do
input_filtered_search("label:~#{bug_label.title} label:~#{caps_sensitive_label.title} #{search_term}") input_filtered_search("label:~#{bug_label.title} label:~#{caps_sensitive_label.title} #{search_term}")
expect_tokens([ expect_tokens([
{ name: 'label', value: bug_label.title }, label_token(bug_label.title),
{ name: 'label', value: caps_sensitive_label.title } label_token(caps_sensitive_label.title)
]) ])
expect_issues_list_count(1) expect_issues_list_count(1)
expect_filtered_search_input(search_term) expect_filtered_search_input(search_term)
...@@ -420,10 +436,12 @@ describe 'Filter issues', js: true do ...@@ -420,10 +436,12 @@ describe 'Filter issues', js: true do
it 'filters issues by searched label, label2, author and text' do 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}") input_filtered_search("label:~#{bug_label.title} label:~#{caps_sensitive_label.title} author:@#{user.username} #{search_term}")
wait_for_requests
expect_tokens([ expect_tokens([
{ name: 'label', value: bug_label.title }, label_token(bug_label.title),
{ name: 'label', value: caps_sensitive_label.title }, label_token(caps_sensitive_label.title),
{ name: 'author', value: user.username } author_token(user.name)
]) ])
expect_issues_list_count(1) expect_issues_list_count(1)
expect_filtered_search_input(search_term) expect_filtered_search_input(search_term)
...@@ -432,11 +450,13 @@ describe 'Filter issues', js: true do ...@@ -432,11 +450,13 @@ describe 'Filter issues', js: true do
it 'filters issues by searched label, label2, author, assignee and text' do 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}") 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([ expect_tokens([
{ name: 'label', value: bug_label.title }, label_token(bug_label.title),
{ name: 'label', value: caps_sensitive_label.title }, label_token(caps_sensitive_label.title),
{ name: 'author', value: user.username }, author_token(user.name),
{ name: 'assignee', value: user.username } assignee_token(user.name)
]) ])
expect_issues_list_count(1) expect_issues_list_count(1)
expect_filtered_search_input(search_term) expect_filtered_search_input(search_term)
...@@ -445,12 +465,14 @@ describe 'Filter issues', js: true do ...@@ -445,12 +465,14 @@ describe 'Filter issues', js: true do
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
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
expect_tokens([ expect_tokens([
{ name: 'label', value: bug_label.title }, label_token(bug_label.title),
{ name: 'label', value: caps_sensitive_label.title }, label_token(caps_sensitive_label.title),
{ name: 'author', value: user.username }, author_token(user.name),
{ name: 'assignee', value: user.username }, assignee_token(user.name),
{ name: 'milestone', value: milestone.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)
...@@ -467,7 +489,7 @@ describe 'Filter issues', js: true do ...@@ -467,7 +489,7 @@ describe 'Filter issues', js: true do
end end
it 'displays in search bar' do it 'displays in search bar' do
expect_tokens([{ name: 'label', value: "\"#{multiple_words_label.title}\"" }]) expect_tokens([label_token("\"#{multiple_words_label.title}\"")])
expect_filtered_search_input_empty expect_filtered_search_input_empty
end end
end end
...@@ -484,7 +506,7 @@ describe 'Filter issues', js: true do ...@@ -484,7 +506,7 @@ describe 'Filter issues', js: true do
it 'filters issues by searched milestone' do it 'filters issues by searched milestone' do
input_filtered_search("milestone:%#{milestone.title}") input_filtered_search("milestone:%#{milestone.title}")
expect_tokens([{ name: 'milestone', value: milestone.title }]) expect_tokens([milestone_token(milestone.title)])
expect_issues_list_count(5) expect_issues_list_count(5)
expect_filtered_search_input_empty expect_filtered_search_input_empty
end end
...@@ -492,7 +514,7 @@ describe 'Filter issues', js: true do ...@@ -492,7 +514,7 @@ describe 'Filter issues', js: true do
it 'filters issues by no milestone' do it 'filters issues by no milestone' do
input_filtered_search("milestone:none") input_filtered_search("milestone:none")
expect_tokens([{ name: 'milestone', value: 'none' }]) expect_tokens([milestone_token('none', false)])
expect_issues_list_count(7, 1) expect_issues_list_count(7, 1)
expect_filtered_search_input_empty expect_filtered_search_input_empty
end end
...@@ -500,7 +522,7 @@ describe 'Filter issues', js: true do ...@@ -500,7 +522,7 @@ describe 'Filter issues', js: true do
it 'filters issues by upcoming milestones' do it 'filters issues by upcoming milestones' do
input_filtered_search("milestone:upcoming") input_filtered_search("milestone:upcoming")
expect_tokens([{ name: 'milestone', value: 'upcoming' }]) expect_tokens([milestone_token('upcoming', false)])
expect_issues_list_count(1) expect_issues_list_count(1)
expect_filtered_search_input_empty expect_filtered_search_input_empty
end end
...@@ -508,7 +530,7 @@ describe 'Filter issues', js: true do ...@@ -508,7 +530,7 @@ describe 'Filter issues', js: true do
it 'filters issues by started milestones' do it 'filters issues by started milestones' do
input_filtered_search("milestone:started") input_filtered_search("milestone:started")
expect_tokens([{ name: 'milestone', value: 'started' }]) expect_tokens([milestone_token('started', false)])
expect_issues_list_count(5) expect_issues_list_count(5)
expect_filtered_search_input_empty expect_filtered_search_input_empty
end end
...@@ -527,7 +549,7 @@ describe 'Filter issues', js: true do ...@@ -527,7 +549,7 @@ describe 'Filter issues', js: true do
input_filtered_search("milestone:%#{special_milestone.title}") input_filtered_search("milestone:%#{special_milestone.title}")
expect_tokens([{ name: 'milestone', value: special_milestone.title }]) expect_tokens([milestone_token(special_milestone.title)])
expect_issues_list_count(1) expect_issues_list_count(1)
expect_filtered_search_input_empty expect_filtered_search_input_empty
end end
...@@ -537,7 +559,7 @@ describe 'Filter issues', js: true do ...@@ -537,7 +559,7 @@ describe 'Filter issues', js: true do
input_filtered_search("milestone:%#{new_milestone.title}") input_filtered_search("milestone:%#{new_milestone.title}")
expect_tokens([{ name: 'milestone', value: 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
...@@ -549,7 +571,7 @@ describe 'Filter issues', js: true do ...@@ -549,7 +571,7 @@ describe 'Filter issues', js: true do
it 'filters issues by searched milestone and text' do it 'filters issues by searched milestone and text' do
input_filtered_search("milestone:%#{milestone.title} #{search_term}") input_filtered_search("milestone:%#{milestone.title} #{search_term}")
expect_tokens([{ name: 'milestone', value: milestone.title }]) expect_tokens([milestone_token(milestone.title)])
expect_issues_list_count(2) expect_issues_list_count(2)
expect_filtered_search_input(search_term) expect_filtered_search_input(search_term)
end end
...@@ -557,9 +579,11 @@ describe 'Filter issues', js: true do ...@@ -557,9 +579,11 @@ describe 'Filter issues', js: true do
it 'filters issues by searched milestone, author and text' do it 'filters issues by searched milestone, author and text' do
input_filtered_search("milestone:%#{milestone.title} author:@#{user.username} #{search_term}") input_filtered_search("milestone:%#{milestone.title} author:@#{user.username} #{search_term}")
wait_for_requests
expect_tokens([ expect_tokens([
{ name: 'milestone', value: milestone.title }, milestone_token(milestone.title),
{ name: 'author', value: user.username } author_token(user.name)
]) ])
expect_issues_list_count(2) expect_issues_list_count(2)
expect_filtered_search_input(search_term) expect_filtered_search_input(search_term)
...@@ -568,10 +592,12 @@ describe 'Filter issues', js: true do ...@@ -568,10 +592,12 @@ describe 'Filter issues', js: true do
it 'filters issues by searched milestone, author, assignee and text' do 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}") input_filtered_search("milestone:%#{milestone.title} author:@#{user.username} assignee:@#{user.username} #{search_term}")
wait_for_requests
expect_tokens([ expect_tokens([
{ name: 'milestone', value: milestone.title }, milestone_token(milestone.title),
{ name: 'author', value: user.username }, author_token(user.name),
{ name: 'assignee', value: user.username } assignee_token(user.name)
]) ])
expect_issues_list_count(2) expect_issues_list_count(2)
expect_filtered_search_input(search_term) expect_filtered_search_input(search_term)
...@@ -580,11 +606,13 @@ describe 'Filter issues', js: true do ...@@ -580,11 +606,13 @@ describe 'Filter issues', js: true do
it 'filters issues by searched milestone, author, assignee, label and text' do 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}") input_filtered_search("milestone:%#{milestone.title} author:@#{user.username} assignee:@#{user.username} label:~#{bug_label.title} #{search_term}")
wait_for_requests
expect_tokens([ expect_tokens([
{ name: 'milestone', value: milestone.title }, milestone_token(milestone.title),
{ name: 'author', value: user.username }, author_token(user.name),
{ name: 'assignee', value: user.username }, assignee_token(user.name),
{ name: 'label', value: bug_label.title } label_token(bug_label.title)
]) ])
expect_issues_list_count(2) expect_issues_list_count(2)
expect_filtered_search_input(search_term) expect_filtered_search_input(search_term)
......
...@@ -32,7 +32,7 @@ describe 'Search bar', js: true do ...@@ -32,7 +32,7 @@ describe 'Search bar', js: true do
it 'selects item' do it 'selects item' do
filtered_search.native.send_keys(:down, :down, :enter) filtered_search.native.send_keys(:down, :down, :enter)
expect_tokens([{ name: 'author' }]) expect_tokens([author_token])
expect_filtered_search_input_empty expect_filtered_search_input_empty
end end
end end
......
...@@ -346,8 +346,8 @@ describe 'Visual tokens', js: true do ...@@ -346,8 +346,8 @@ describe 'Visual tokens', js: true do
it 'tokenizes the search term to complete visual token' do it 'tokenizes the search term to complete visual token' do
expect_tokens([ expect_tokens([
{ name: 'author', value: '@root' }, author_token(user.name),
{ name: 'assignee', value: 'none' } assignee_token('none')
]) ])
end end
end end
......
...@@ -25,7 +25,7 @@ feature 'Merge Request filtering by Milestone' do ...@@ -25,7 +25,7 @@ feature 'Merge Request filtering by Milestone' do
visit_merge_requests(project) visit_merge_requests(project)
input_filtered_search('milestone:none') input_filtered_search('milestone:none')
expect_tokens([{ name: 'milestone', value: 'none' }]) expect_tokens([milestone_token('none', false)])
expect_filtered_search_input_empty expect_filtered_search_input_empty
expect(page).to have_issuable_counts(open: 1, closed: 0, all: 1) expect(page).to have_issuable_counts(open: 1, closed: 0, all: 1)
......
...@@ -24,7 +24,9 @@ describe 'Filter merge requests' do ...@@ -24,7 +24,9 @@ describe 'Filter merge requests' do
let(:search_query) { "assignee:@#{user.username}" } let(:search_query) { "assignee:@#{user.username}" }
def expect_assignee_visual_tokens def expect_assignee_visual_tokens
expect_tokens([{ name: 'assignee', value: "@#{user.username}" }]) wait_for_requests
expect_tokens([assignee_token(user.name)])
expect_filtered_search_input_empty expect_filtered_search_input_empty
end end
...@@ -57,7 +59,7 @@ describe 'Filter merge requests' do ...@@ -57,7 +59,7 @@ describe 'Filter merge requests' do
let(:search_query) { "milestone:%\"#{milestone.title}\"" } let(:search_query) { "milestone:%\"#{milestone.title}\"" }
def expect_milestone_visual_tokens def expect_milestone_visual_tokens
expect_tokens([{ name: 'milestone', value: "%\"#{milestone.title}\"" }]) expect_tokens([milestone_token("\"#{milestone.title}\"")])
expect_filtered_search_input_empty expect_filtered_search_input_empty
end end
...@@ -91,7 +93,7 @@ describe 'Filter merge requests' do ...@@ -91,7 +93,7 @@ describe 'Filter merge requests' do
input_filtered_search('label:none') input_filtered_search('label:none')
expect_mr_list_count(1) expect_mr_list_count(1)
expect_tokens([{ name: 'label', value: 'none' }]) expect_tokens([label_token('none', false)])
expect_filtered_search_input_empty expect_filtered_search_input_empty
end end
...@@ -99,7 +101,7 @@ describe 'Filter merge requests' do ...@@ -99,7 +101,7 @@ describe 'Filter merge requests' do
input_filtered_search("label:~#{label.title}") input_filtered_search("label:~#{label.title}")
expect_mr_list_count(0) expect_mr_list_count(0)
expect_tokens([{ name: 'label', value: "~#{label.title}" }]) expect_tokens([label_token(label.title)])
expect_filtered_search_input_empty expect_filtered_search_input_empty
end end
...@@ -107,10 +109,7 @@ describe 'Filter merge requests' do ...@@ -107,10 +109,7 @@ describe 'Filter merge requests' do
input_filtered_search("label:~\"#{wontfix.title}\" label:~#{label.title}") input_filtered_search("label:~\"#{wontfix.title}\" label:~#{label.title}")
expect_mr_list_count(0) expect_mr_list_count(0)
expect_tokens([ expect_tokens([label_token("\"#{wontfix.title}\""), label_token(label.title)])
{ name: 'label', value: "~\"#{wontfix.title}\"" },
{ name: 'label', value: "~#{label.title}" }
])
expect_filtered_search_input_empty expect_filtered_search_input_empty
end end
...@@ -118,16 +117,13 @@ describe 'Filter merge requests' do ...@@ -118,16 +117,13 @@ describe 'Filter merge requests' do
input_filtered_search("label:~\"#{wontfix.title}\"") input_filtered_search("label:~\"#{wontfix.title}\"")
expect_mr_list_count(0) expect_mr_list_count(0)
expect_tokens([{ name: 'label', value: "~\"#{wontfix.title}\"" }]) expect_tokens([label_token("\"#{wontfix.title}\"")])
expect_filtered_search_input_empty expect_filtered_search_input_empty
input_filtered_search_keys("label:~#{label.title}") input_filtered_search_keys("label:~#{label.title}")
expect_mr_list_count(0) expect_mr_list_count(0)
expect_tokens([ expect_tokens([label_token("\"#{wontfix.title}\""), label_token(label.title)])
{ name: 'label', value: "~\"#{wontfix.title}\"" },
{ name: 'label', value: "~#{label.title}" }
])
expect_filtered_search_input_empty expect_filtered_search_input_empty
end end
end end
...@@ -143,10 +139,9 @@ describe 'Filter merge requests' do ...@@ -143,10 +139,9 @@ describe 'Filter merge requests' do
context 'assignee and label', js: true do context 'assignee and label', js: true do
def expect_assignee_label_visual_tokens def expect_assignee_label_visual_tokens
expect_tokens([ wait_for_requests
{ name: 'assignee', value: "@#{user.username}" },
{ name: 'label', value: "~#{label.title}" } expect_tokens([assignee_token(user.name), label_token(label.title)])
])
expect_filtered_search_input_empty expect_filtered_search_input_empty
end end
...@@ -214,7 +209,7 @@ describe 'Filter merge requests' do ...@@ -214,7 +209,7 @@ describe 'Filter merge requests' do
input_filtered_search_keys(' label:~bug') input_filtered_search_keys(' label:~bug')
expect_mr_list_count(1) expect_mr_list_count(1)
expect_tokens([{ name: 'label', value: '~bug' }]) expect_tokens([label_token('bug')])
expect_filtered_search_input('Bug') expect_filtered_search_input('Bug')
end end
...@@ -227,7 +222,7 @@ describe 'Filter merge requests' do ...@@ -227,7 +222,7 @@ describe 'Filter merge requests' do
input_filtered_search_keys(' milestone:%8') input_filtered_search_keys(' milestone:%8')
expect_mr_list_count(1) expect_mr_list_count(1)
expect_tokens([{ name: 'milestone', value: '%8' }]) expect_tokens([milestone_token('8')])
expect_filtered_search_input('Bug') expect_filtered_search_input('Bug')
end end
...@@ -240,7 +235,10 @@ describe 'Filter merge requests' do ...@@ -240,7 +235,10 @@ describe 'Filter merge requests' do
input_filtered_search_keys(" assignee:@#{user.username}") input_filtered_search_keys(" assignee:@#{user.username}")
expect_mr_list_count(1) expect_mr_list_count(1)
expect_tokens([{ name: 'assignee', value: "@#{user.username}" }])
wait_for_requests
expect_tokens([assignee_token(user.name)])
expect_filtered_search_input('Bug') expect_filtered_search_input('Bug')
end end
...@@ -252,8 +250,10 @@ describe 'Filter merge requests' do ...@@ -252,8 +250,10 @@ describe 'Filter merge requests' do
input_filtered_search_keys(" author:@#{user.username}") input_filtered_search_keys(" author:@#{user.username}")
wait_for_requests
expect_mr_list_count(1) expect_mr_list_count(1)
expect_tokens([{ name: 'author', value: "@#{user.username}" }]) expect_tokens([author_token(user.name)])
expect_filtered_search_input('Bug') expect_filtered_search_input('Bug')
end end
end end
...@@ -293,7 +293,9 @@ describe 'Filter merge requests' do ...@@ -293,7 +293,9 @@ describe 'Filter merge requests' do
it 'filter by current user' do it 'filter by current user' do
visit project_merge_requests_path(project, assignee_id: user.id) visit project_merge_requests_path(project, assignee_id: user.id)
expect_tokens([{ name: 'assignee', value: "@#{user.username}" }]) wait_for_requests
expect_tokens([assignee_token(user.name)])
expect_filtered_search_input_empty expect_filtered_search_input_empty
end end
...@@ -303,7 +305,9 @@ describe 'Filter merge requests' do ...@@ -303,7 +305,9 @@ describe 'Filter merge requests' do
visit project_merge_requests_path(project, assignee_id: new_user.id) visit project_merge_requests_path(project, assignee_id: new_user.id)
expect_tokens([{ name: 'assignee', value: "@#{new_user.username}" }]) wait_for_requests
expect_tokens([assignee_token(new_user.name)])
expect_filtered_search_input_empty expect_filtered_search_input_empty
end end
end end
...@@ -312,7 +316,9 @@ describe 'Filter merge requests' do ...@@ -312,7 +316,9 @@ describe 'Filter merge requests' do
it 'filter by current user' do it 'filter by current user' do
visit project_merge_requests_path(project, author_id: user.id) visit project_merge_requests_path(project, author_id: user.id)
expect_tokens([{ name: 'author', value: "@#{user.username}" }]) wait_for_requests
expect_tokens([author_token(user.name)])
expect_filtered_search_input_empty expect_filtered_search_input_empty
end end
...@@ -322,7 +328,9 @@ describe 'Filter merge requests' do ...@@ -322,7 +328,9 @@ describe 'Filter merge requests' do
visit project_merge_requests_path(project, author_id: new_user.id) visit project_merge_requests_path(project, author_id: new_user.id)
expect_tokens([{ name: 'author', value: "@#{new_user.username}" }]) wait_for_requests
expect_tokens([author_token(new_user.name)])
expect_filtered_search_input_empty expect_filtered_search_input_empty
end end
end end
......
...@@ -195,37 +195,33 @@ describe "Search" do ...@@ -195,37 +195,33 @@ describe "Search" do
it 'takes user to her issues page when issues assigned is clicked' do it 'takes user to her issues page when issues assigned is clicked' do
find('.dropdown-menu').click_link 'Issues assigned to me' find('.dropdown-menu').click_link 'Issues assigned to me'
sleep 2
expect(page).to have_selector('.filtered-search') expect(page).to have_selector('.filtered-search')
expect_tokens([{ name: 'assignee', value: "@#{user.username}" }]) expect_tokens([assignee_token(user.name)])
expect_filtered_search_input_empty expect_filtered_search_input_empty
end end
it 'takes user to her issues page when issues authored is clicked' do it 'takes user to her issues page when issues authored is clicked' do
find('.dropdown-menu').click_link "Issues I've created" find('.dropdown-menu').click_link "Issues I've created"
sleep 2
expect(page).to have_selector('.filtered-search') expect(page).to have_selector('.filtered-search')
expect_tokens([{ name: 'author', value: "@#{user.username}" }]) expect_tokens([author_token(user.name)])
expect_filtered_search_input_empty expect_filtered_search_input_empty
end end
it 'takes user to her MR page when MR assigned is clicked' do it 'takes user to her MR page when MR assigned is clicked' do
find('.dropdown-menu').click_link 'Merge requests assigned to me' find('.dropdown-menu').click_link 'Merge requests assigned to me'
sleep 2
expect(page).to have_selector('.merge-requests-holder') expect(page).to have_selector('.merge-requests-holder')
expect_tokens([{ name: 'assignee', value: "@#{user.username}" }]) expect_tokens([assignee_token(user.name)])
expect_filtered_search_input_empty expect_filtered_search_input_empty
end end
it 'takes user to her MR page when MR authored is clicked' do it 'takes user to her MR page when MR authored is clicked' do
find('.dropdown-menu').click_link "Merge requests I've created" find('.dropdown-menu').click_link "Merge requests I've created"
sleep 2
expect(page).to have_selector('.merge-requests-holder') expect(page).to have_selector('.merge-requests-holder')
expect_tokens([{ name: 'author', value: "@#{user.username}" }]) expect_tokens([author_token(user.name)])
expect_filtered_search_input_empty expect_filtered_search_input_empty
end end
end end
......
...@@ -54,8 +54,8 @@ module FilteredSearchHelpers ...@@ -54,8 +54,8 @@ module FilteredSearchHelpers
# Iterates through each visual token inside # Iterates through each visual token inside
# .tokens-container to make sure the correct names and values are rendered # .tokens-container to make sure the correct names and values are rendered
def expect_tokens(tokens) def expect_tokens(tokens)
page.find '.filtered-search-box .tokens-container' do page.within '.filtered-search-box .tokens-container' do
page.all(:css, '.tokens-container li').each_with_index do |el, index| page.all(:css, '.tokens-container li .selectable').each_with_index do |el, index|
token_name = tokens[index][:name] token_name = tokens[index][:name]
token_value = tokens[index][:value] token_value = tokens[index][:value]
...@@ -67,6 +67,28 @@ module FilteredSearchHelpers ...@@ -67,6 +67,28 @@ module FilteredSearchHelpers
end end
end end
def create_token(token_name, token_value = nil, symbol = nil)
{ name: token_name, value: "#{symbol}#{token_value}" }
end
def author_token(author_name = nil)
create_token('Author', author_name)
end
def assignee_token(assignee_name = nil)
create_token('Assignee', assignee_name)
end
def milestone_token(milestone_name = nil, has_symbol = true)
symbol = has_symbol ? '%' : nil
create_token('Milestone', milestone_name, symbol)
end
def label_token(label_name = nil, has_symbol = true)
symbol = has_symbol ? '~' : nil
create_token('Label', label_name, symbol)
end
def default_placeholder def default_placeholder
'Search or filter results...' 'Search or filter results...'
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