Commit 9c8a86f6 authored by Clement Ho's avatar Clement Ho

Update filter issue specs

parent 8b4e4e33
...@@ -24,10 +24,12 @@ ...@@ -24,10 +24,12 @@
} }
.filtered-search-container { .filtered-search-container {
display: -webkit-flex;
display: flex; display: flex;
} }
.filtered-search-input-container { .filtered-search-input-container {
display: -webkit-flex;
display: flex; display: flex;
position: relative; position: relative;
width: 100%; width: 100%;
......
...@@ -4,147 +4,236 @@ describe 'Filter issues', feature: true do ...@@ -4,147 +4,236 @@ describe 'Filter issues', feature: true do
include WaitForAjax include WaitForAjax
let!(:group) { create(:group) } let!(:group) { create(:group) }
let!(:project) { create(:project, group: group) } let!(:project) { create(:project) }
let!(:user) { create(:user)} let!(:user) { create(:user)}
let!(:user) { create(:user) }
let!(:user2) { create(:user) }
let!(:milestone) { create(:milestone, project: project) } let!(:milestone) { create(:milestone, project: project) }
let!(:label) { create(:label, project: project) } let!(:label) { create(:label, project: project) }
let!(:wontfix) { create(:label, project: project, title: "Won't fix") } let!(:wontfix) { create(:label, project: project, title: "Won't fix") }
let!(:bug_label) { create(:label, project: project, title: 'bug') }
let!(:caps_sensitive_label) { create(:label, project: project, title: 'CAPS_sensitive') }
let!(:milestone) { create(:milestone, title: "8", project: project) }
def input_filtered_search(search_term)
filtered_search = find('.filtered-search')
filtered_search.set(search_term)
filtered_search.send_keys(:enter)
end
def expect_no_issues_list
page.within '.issues-list' do
expect(page).not_to have_selector('.issue')
end
end
def expect_issues_list_count(open_count, closed_count = 0)
all_count = open_count + closed_count
expect(page).to have_issuable_counts(open: open_count, closed: closed_count, all: all_count)
page.within '.issues-list' do
expect(page).to have_selector('.issue', count: open_count)
end
end
before do before do
project.team << [user, :master] project.team << [user, :master]
project.team << [user2, :master]
group.add_developer(user) group.add_developer(user)
group.add_developer(user2)
login_as(user) login_as(user)
create(:issue, project: project) create(:issue, project: project)
end
describe 'for assignee from issues#index' do create(:issue, title: "Bug report 1", project: project)
before do create(:issue, title: "Bug report 2", project: project)
visit namespace_project_issues_path(project.namespace, project) create(:issue, title: "issue with 'single quotes'", project: project)
create(:issue, title: "issue with \"double quotes\"", project: project)
create(:issue, title: "issue with !@\#{$%^&*()-+", project: project)
create(:issue, title: "issue by assignee", project: project, milestone: milestone, author: user, assignee: user)
create(:issue, title: "issue by assignee with searchTerm", project: project, milestone: milestone, author: user, assignee: user)
find('.js-assignee-search').click issue = create(:issue,
title: "Bug 2",
project: project,
milestone: milestone,
author: user,
assignee: user)
issue.labels << bug_label
find('.dropdown-menu-user-link', text: user.username).click issue_with_caps_label = create(:issue,
title: "issue by assignee with searchTerm and label",
project: project,
milestone: milestone,
author: user,
assignee: user)
issue_with_caps_label.labels << caps_sensitive_label
wait_for_ajax issue_with_everything = create(:issue,
end title: "Bug report with everything you thought was possible",
project: project,
milestone: milestone,
author: user,
assignee: user)
issue_with_everything.labels << bug_label
issue_with_everything.labels << caps_sensitive_label
context 'assignee', js: true do visit namespace_project_issues_path(project.namespace, project)
it 'updates to current user' do
expect(find('.js-assignee-search .dropdown-toggle-text')).to have_content(user.name)
end end
it 'does not change when closed link is clicked' do describe 'filter issues by author' do
find('.issues-state-filters a', text: "Closed").click context 'only author', js: true do
it 'filters issues by searched author' do
expect(find('.js-assignee-search .dropdown-toggle-text')).to have_content(user.name) input_filtered_search("author:#{user.username}")
expect_issues_list_count(5)
end end
it 'does not change when all link is clicked' do it 'filters issues by invalid author' do
find('.issues-state-filters a', text: "All").click # YOLO
expect(find('.js-assignee-search .dropdown-toggle-text')).to have_content(user.name)
end end
it 'filters issues by multiple authors' do
# YOLO
end end
end end
describe 'for milestone from issues#index' do context 'author with other filters', js: true do
before do it 'filters issues by searched author and text' do
visit namespace_project_issues_path(project.namespace, project) input_filtered_search("author:#{user.username} issue")
expect_issues_list_count(3)
find('.js-milestone-select').click end
find('.milestone-filter .dropdown-content a', text: milestone.title).click it 'filters issues by searched author, assignee and text' do
input_filtered_search("author:#{user.username} assignee:#{user.username} issue")
expect_issues_list_count(3)
end
wait_for_ajax 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} issue")
expect_issues_list_count(1)
end end
context 'milestone', js: true do it 'filters issues by searched author, assignee, label, milestone and text' do
it 'updates to current milestone' do input_filtered_search("author:#{user.username} assignee:#{user.username} label:#{caps_sensitive_label.title} milestone:#{milestone.title} issue")
expect(find('.js-milestone-select .dropdown-toggle-text')).to have_content(milestone.title) expect_issues_list_count(1)
end
end end
it 'does not change when closed link is clicked' do context 'sorting', js: true do
find('.issues-state-filters a', text: "Closed").click # TODO
end
end
expect(find('.js-milestone-select .dropdown-toggle-text')).to have_content(milestone.title) describe 'filter issues by assignee' do
context 'only assignee', js: true do
it 'filters issues by searched assignee' do
input_filtered_search("assignee:#{user.username}")
expect_issues_list_count(5)
end end
it 'does not change when all link is clicked' do it 'filters issues by no assignee' do
find('.issues-state-filters a', text: "All").click # TODO
end
expect(find('.js-milestone-select .dropdown-toggle-text')).to have_content(milestone.title) it 'filters issues by invalid assignee' do
# YOLO
end end
it 'filters issues by multiple assignees' do
# YOLO
end end
end end
describe 'for label from issues#index', js: true do context 'assignee with other filters', js: true do
before do it 'filters issues by searched assignee and text' do
visit namespace_project_issues_path(project.namespace, project) input_filtered_search("assignee:#{user.username} searchTerm")
find('.js-label-select').click expect_issues_list_count(2)
wait_for_ajax
end end
it 'filters by any label' do it 'filters issues by searched assignee, author and text' do
find('.dropdown-menu-labels a', text: 'Any Label').click input_filtered_search("assignee:#{user.username} author:#{user.username} searchTerm")
page.first('.labels-filter .dropdown-title .dropdown-menu-close-icon').click expect_issues_list_count(2)
wait_for_ajax end
expect(find('.labels-filter')).to have_content 'Label' it 'filters issues by searched assignee, author, label, text' do
input_filtered_search("assignee:#{user.username} author:#{user.username} label:#{caps_sensitive_label.title} searchTerm")
expect_issues_list_count(1)
end end
it 'filters by no label' do it 'filters issues by searched assignee, author, label, milestone and text' do
find('.dropdown-menu-labels a', text: 'No Label').click input_filtered_search("assignee:#{user.username} author:#{user.username} label:#{caps_sensitive_label.title} milestone:#{milestone.title} searchTerm")
page.first('.labels-filter .dropdown-title .dropdown-menu-close-icon').click expect_issues_list_count(1)
wait_for_ajax end
end
page.within '.labels-filter' do context 'sorting', js: true do
expect(page).to have_content 'Labels' # TODO
end end
expect(find('.js-label-select .dropdown-toggle-text')).to have_content('Labels')
end end
it 'filters by a label' do describe 'filter issues by label' do
find('.dropdown-menu-labels a', text: label.title).click context 'only label', js: true do
page.within '.labels-filter' do it 'filters issues by searched label' do
expect(page).to have_content label.title input_filtered_search("label:#{bug_label.title}")
expect_issues_list_count(2)
end end
expect(find('.js-label-select .dropdown-toggle-text')).to have_content(label.title)
it 'filters issues by no label' do
# TODO
end end
it "filters by `won't fix` and another label" do it 'filters issues by invalid label' do
page.within '.labels-filter' do # YOLO
click_link wontfix.title
expect(page).to have_content wontfix.title
click_link label.title
end end
expect(find('.js-label-select .dropdown-toggle-text')).to have_content("#{wontfix.title} +1 more") it 'filters issues by multiple labels' do
input_filtered_search("label:#{bug_label.title} label:#{caps_sensitive_label.title}")
expect_issues_list_count(1)
end
end end
it "filters by `won't fix` label followed by another label after page load" do context 'label with other filters', js: true do
page.within '.labels-filter' do it 'filters issues by searched label and text' do
click_link wontfix.title input_filtered_search("label:#{caps_sensitive_label.title} bug")
expect(page).to have_content wontfix.title expect_issues_list_count(1)
end end
find('.dropdown-menu-close-icon').click it 'filters issues by searched label, author and text' do
input_filtered_search("label:#{caps_sensitive_label.title} author:#{user.username} bug")
expect_issues_list_count(1)
end
expect(find('.filtered-labels')).to have_content(wontfix.title) 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} bug")
expect_issues_list_count(1)
end
find('.js-label-select').click it 'filters issues by searched label, author, assignee, milestone and text' do
wait_for_ajax input_filtered_search("label:#{caps_sensitive_label.title} author:#{user.username} assignee:#{user.username} milestone:#{milestone.title} bug")
find('.dropdown-menu-labels a', text: label.title).click expect_issues_list_count(1)
end
end
find('.dropdown-menu-close-icon').click context 'multiple labels with other filters', js: true do
it 'filters issues by searched label, label2, and text' do
input_filtered_search("label:#{bug_label.title} label:#{caps_sensitive_label.title} bug")
expect_issues_list_count(1)
end
expect(find('.filtered-labels')).to have_content(wontfix.title) it 'filters issues by searched label, label2, author and text' do
expect(find('.filtered-labels')).to have_content(label.title) input_filtered_search("label:#{bug_label.title} label:#{caps_sensitive_label.title} author:#{user.username} bug")
expect_issues_list_count(1)
end
find('.js-label-select').click it 'filters issues by searched label, label2, author, assignee and text' do
wait_for_ajax input_filtered_search("label:#{bug_label.title} label:#{caps_sensitive_label.title} author:#{user.username} assignee:#{user.username} bug")
expect_issues_list_count(1)
end
expect(find('.dropdown-menu-labels li', text: wontfix.title)).to have_css('.is-active') it 'filters issues by searched label, label2, author, assignee, milestone and text' do
expect(find('.dropdown-menu-labels li', text: label.title)).to have_css('.is-active') input_filtered_search("label:#{bug_label.title} label:#{caps_sensitive_label.title} author:#{user.username} assignee:#{user.username} milestone:#{milestone.title} bug")
expect_issues_list_count(1)
end
end end
it "selects and unselects `won't fix`" do it "selects and unselects `won't fix`" do
...@@ -153,211 +242,160 @@ describe 'Filter issues', feature: true do ...@@ -153,211 +242,160 @@ describe 'Filter issues', feature: true do
find('.dropdown-menu-close-icon').click find('.dropdown-menu-close-icon').click
expect(page).not_to have_css('.filtered-labels') expect(page).not_to have_css('.filtered-labels')
context 'sorting', js: true do
# TODO
end end
end end
describe 'for assignee and label from issues#index' do describe 'filter issues by milestone' do
before do context 'only milestone', js: true do
visit namespace_project_issues_path(project.namespace, project) it 'filters issues by searched milestone' do
input_filtered_search("milestone:#{milestone.title}")
find('.js-assignee-search').click expect_issues_list_count(5)
find('.dropdown-menu-user-link', text: user.username).click
expect(page).not_to have_selector('.issues-list .issue')
find('.js-label-select').click
find('.dropdown-menu-labels .dropdown-content a', text: label.title).click
page.first('.labels-filter .dropdown-title .dropdown-menu-close-icon').click
wait_for_ajax
end end
context 'assignee and label', js: true do it 'filters issues by no milestone' do
it 'updates to current assignee and label' do # TODO
expect(find('.js-assignee-search .dropdown-toggle-text')).to have_content(user.name)
expect(find('.js-label-select .dropdown-toggle-text')).to have_content(label.title)
end end
it 'does not change when closed link is clicked' do it 'filters issues by upcoming milestones' do
find('.issues-state-filters a', text: "Closed").click # TODO
expect(find('.js-assignee-search .dropdown-toggle-text')).to have_content(user.name)
expect(find('.js-label-select .dropdown-toggle-text')).to have_content(label.title)
end end
it 'does not change when all link is clicked' do it 'filters issues by invalid milestones' do
find('.issues-state-filters a', text: "All").click # YOLO
expect(find('.js-assignee-search .dropdown-toggle-text')).to have_content(user.name)
expect(find('.js-label-select .dropdown-toggle-text')).to have_content(label.title)
end end
it 'filters issues by multiple milestones' do
# YOLO
end end
end end
describe 'filter issues by text' do context 'milestone with other filters', js: true do
before do it 'filters issues by searched milestone and text' do
create(:issue, title: "Bug", project: project) end
bug_label = create(:label, project: project, title: 'bug')
milestone = create(:milestone, title: "8", project: project)
issue = create(:issue,
title: "Bug 2",
project: project,
milestone: milestone,
author: user,
assignee: user)
issue.labels << bug_label
visit namespace_project_issues_path(project.namespace, project) it 'filters issues by searched milestone, author and text' do
end end
context 'only text', js: true do it 'filters issues by searched milestone, author, assignee and text' do
it 'filters issues by searched text' do end
fill_in 'issuable_search', with: 'Bug'
page.within '.issues-list' do it 'filters issues by searched milestone, author, assignee, label and text' do
expect(page).to have_selector('.issue', count: 2)
end end
end end
it 'does not show any issues' do context 'sorting', js: true do
fill_in 'issuable_search', with: 'testing' # TODO
page.within '.issues-list' do
expect(page).not_to have_selector('.issue')
end end
end end
end
context 'text and dropdown options', js: true do
it 'filters by text and label' do
fill_in 'issuable_search', with: 'Bug'
expect(page).to have_issuable_counts(open: 2, closed: 0, all: 2) describe 'filter issues by text' do
page.within '.issues-list' do context 'only text', js: true do
expect(page).to have_selector('.issue', count: 2) it 'filters issues by searched text' do
input_filtered_search('Bug')
expect_issues_list_count(4)
end end
click_button 'Label' it 'filters issues by multiple searched text' do
page.within '.labels-filter' do input_filtered_search('Bug report')
click_link 'bug' expect_issues_list_count(3)
end end
find('.dropdown-menu-close-icon').click
expect(page).to have_issuable_counts(open: 1, closed: 0, all: 1) it 'filters issues by case insensitive searched text' do
page.within '.issues-list' do input_filtered_search('bug report')
expect(page).to have_selector('.issue', count: 1) expect_issues_list_count(3)
end
end end
it 'filters by text and milestone' do it 'filters issues by searched text containing single quotes' do
fill_in 'issuable_search', with: 'Bug' input_filtered_search('\'single quotes\'')
expect_issues_list_count(1)
end
expect(page).to have_issuable_counts(open: 2, closed: 0, all: 2) it 'filters issues by searched text containing double quotes' do
page.within '.issues-list' do input_filtered_search('"double quotes"')
expect(page).to have_selector('.issue', count: 2) expect_issues_list_count(1)
end end
click_button 'Milestone' it 'filters issues by searched text containing special characters' do
page.within '.milestone-filter' do input_filtered_search('!@#{$%^&*()-+')
click_link '8' expect_issues_list_count(1)
end end
expect(page).to have_issuable_counts(open: 1, closed: 0, all: 1) it 'does not show any issues' do
page.within '.issues-list' do input_filtered_search('testing')
expect(page).to have_selector('.issue', count: 1) expect_no_issues_list()
end end
end end
it 'filters by text and assignee' do context 'searched text with other filters', js: true do
fill_in 'issuable_search', with: 'Bug' it 'filters issues by searched text and author' do
input_filtered_search("bug author:#{user.username}")
expect(page).to have_issuable_counts(open: 2, closed: 0, all: 2) expect_issues_list_count(2)
page.within '.issues-list' do
expect(page).to have_selector('.issue', count: 2)
end end
click_button 'Assignee' it 'filters issues by searched text, author and more text' do
page.within '.dropdown-menu-assignee' do input_filtered_search("bug author:#{user.username} report")
click_link user.name expect_issues_list_count(1)
end end
expect(page).to have_issuable_counts(open: 1, closed: 0, all: 1) it 'filters issues by searched text, author and assignee' do
page.within '.issues-list' do input_filtered_search("bug author:#{user.username} assignee:#{user.username}")
expect(page).to have_selector('.issue', count: 1) expect_issues_list_count(2)
end end
end
it 'filters by text and author' do
fill_in 'issuable_search', with: 'Bug'
expect(page).to have_issuable_counts(open: 2, closed: 0, all: 2) it 'filters issues by searched text, author, more text and assignee' do
page.within '.issues-list' do input_filtered_search("bug author:#{user.username} report assignee:#{user.username}")
expect(page).to have_selector('.issue', count: 2) expect_issues_list_count(1)
end end
click_button 'Author' it 'filters issues by searched text, author, more text, assignee and even more text' do
page.within '.dropdown-menu-author' do input_filtered_search("bug author:#{user.username} report assignee:#{user.username} with")
click_link user.name expect_issues_list_count(1)
end end
expect(page).to have_issuable_counts(open: 1, closed: 0, all: 1) it 'filters issues by searched text, author, assignee and label' do
page.within '.issues-list' do input_filtered_search("bug author:#{user.username} assignee:#{user.username} label:#{bug_label.title}")
expect(page).to have_selector('.issue', count: 1) expect_issues_list_count(2)
end end
end
end
end
describe 'filter issues and sort', js: true do
before do
bug_label = create(:label, project: project, title: 'bug')
bug_one = create(:issue, title: "Frontend", project: project)
bug_two = create(:issue, title: "Bug 2", project: project)
bug_one.labels << bug_label
bug_two.labels << bug_label
visit namespace_project_issues_path(project.namespace, project) it 'filters issues by searched text, author, text, assignee, text, label and text' do
input_filtered_search("bug author:#{user.username} report assignee:#{user.username} with label:#{bug_label.title} everything")
expect_issues_list_count(1)
end end
it 'is able to filter and sort issues' do it 'filters issues by searched text, author, assignee, label and milestone' do
click_button 'Label' input_filtered_search("bug author:#{user.username} assignee:#{user.username} label:#{bug_label.title} milestone:#{milestone.title}")
wait_for_ajax expect_issues_list_count(2)
page.within '.labels-filter' do
click_link 'bug'
end end
find('.dropdown-menu-close-icon').click
wait_for_ajax
expect(page).to have_issuable_counts(open: 2, closed: 0, all: 2) it 'filters issues by searched text, author, text, assignee, text, label, text, milestone and text' do
page.within '.issues-list' do input_filtered_search("bug author:#{user.username} report assignee:#{user.username} with label:#{bug_label.title} everything milestone:#{milestone.title} you")
expect(page).to have_selector('.issue', count: 2) expect_issues_list_count(1)
end end
click_button 'Last created' it 'filters issues by searched text, author, assignee, multiple labels and milestone' do
page.within '.dropdown-menu-sort' do input_filtered_search("bug author:#{user.username} assignee:#{user.username} label:#{bug_label.title} label:#{caps_sensitive_label.title} milestone:#{milestone.title}")
click_link 'Oldest created' expect_issues_list_count(1)
end end
wait_for_ajax
page.within '.issues-list' do it 'filters issues by searched text, author, text, assignee, text, label1, text, label2, text, milestone and text' do
expect(page).to have_content('Frontend') input_filtered_search("bug author:#{user.username} report assignee:#{user.username} with label:#{bug_label.title} everything label:#{caps_sensitive_label.title} you milestone:#{milestone.title} thought")
expect_issues_list_count(1)
end end
end end
context 'sorting', js: true do
# TODO
end
end end
it 'updates atom feed link for project issues' do it 'updates atom feed link for project issues' do
visit namespace_project_issues_path(project.namespace, project, milestone_title: '', assignee_id: user.id) visit namespace_project_issues_path(project.namespace, project, milestone_title: '', assignee_id: user.id)
link = find('.nav-controls a', text: 'Subscribe') link = find('.nav-controls a', text: '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('private_token' => [user.private_token]) expect(params).to include('private_token' => [user.private_token])
expect(params).to include('milestone_title' => ['']) expect(params).to include('milestone_title' => [''])
expect(params).to include('assignee_id' => [user.id.to_s]) expect(params).to include('assignee_id' => [user.id.to_s])
...@@ -368,12 +406,10 @@ describe 'Filter issues', feature: true do ...@@ -368,12 +406,10 @@ describe 'Filter issues', feature: true do
it 'updates atom feed link for group issues' do it 'updates atom feed link for group issues' do
visit issues_group_path(group, milestone_title: '', assignee_id: user.id) visit issues_group_path(group, milestone_title: '', assignee_id: user.id)
link = find('.nav-controls a', text: 'Subscribe') link = find('.nav-controls a', text: '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('private_token' => [user.private_token]) expect(params).to include('private_token' => [user.private_token])
expect(params).to include('milestone_title' => ['']) expect(params).to include('milestone_title' => [''])
expect(params).to include('assignee_id' => [user.id.to_s]) expect(params).to include('assignee_id' => [user.id.to_s])
......
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