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)
issue = create(:issue,
title: "Bug 2",
project: project,
milestone: milestone,
author: user,
assignee: user)
issue.labels << bug_label
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
issue_with_everything = create(:issue,
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
visit namespace_project_issues_path(project.namespace, project)
end
find('.js-assignee-search').click describe 'filter issues by author' do
context 'only author', js: true do
it 'filters issues by searched author' do
input_filtered_search("author:#{user.username}")
expect_issues_list_count(5)
end
find('.dropdown-menu-user-link', text: user.username).click it 'filters issues by invalid author' do
# YOLO
end
wait_for_ajax it 'filters issues by multiple authors' do
# YOLO
end
end end
context 'assignee', js: true do context 'author with other filters', js: true do
it 'updates to current user' do it 'filters issues by searched author and text' do
expect(find('.js-assignee-search .dropdown-toggle-text')).to have_content(user.name) input_filtered_search("author:#{user.username} issue")
expect_issues_list_count(3)
end end
it 'does not change when closed link is clicked' do it 'filters issues by searched author, assignee and text' do
find('.issues-state-filters a', text: "Closed").click input_filtered_search("author:#{user.username} assignee:#{user.username} issue")
expect_issues_list_count(3)
expect(find('.js-assignee-search .dropdown-toggle-text')).to have_content(user.name)
end end
it 'does not change when all link is clicked' do it 'filters issues by searched author, assignee, label, and text' do
find('.issues-state-filters a', text: "All").click input_filtered_search("author:#{user.username} assignee:#{user.username} label:#{caps_sensitive_label.title} issue")
expect_issues_list_count(1)
end
expect(find('.js-assignee-search .dropdown-toggle-text')).to have_content(user.name) 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} issue")
expect_issues_list_count(1)
end end
end end
context 'sorting', js: true do
# TODO
end
end end
describe 'for milestone from issues#index' do describe 'filter issues by assignee' do
before do context 'only assignee', js: true do
visit namespace_project_issues_path(project.namespace, project) it 'filters issues by searched assignee' do
input_filtered_search("assignee:#{user.username}")
expect_issues_list_count(5)
end
find('.js-milestone-select').click it 'filters issues by no assignee' do
# TODO
end
find('.milestone-filter .dropdown-content a', text: milestone.title).click it 'filters issues by invalid assignee' do
# YOLO
end
wait_for_ajax it 'filters issues by multiple assignees' do
# YOLO
end
end end
context 'milestone', js: true do context 'assignee with other filters', js: true do
it 'updates to current milestone' do it 'filters issues by searched assignee and text' do
expect(find('.js-milestone-select .dropdown-toggle-text')).to have_content(milestone.title) input_filtered_search("assignee:#{user.username} searchTerm")
expect_issues_list_count(2)
end end
it 'does not change when closed link is clicked' do it 'filters issues by searched assignee, author and text' do
find('.issues-state-filters a', text: "Closed").click input_filtered_search("assignee:#{user.username} author:#{user.username} searchTerm")
expect_issues_list_count(2)
expect(find('.js-milestone-select .dropdown-toggle-text')).to have_content(milestone.title)
end end
it 'does not change when all link is clicked' do it 'filters issues by searched assignee, author, label, text' do
find('.issues-state-filters a', text: "All").click input_filtered_search("assignee:#{user.username} author:#{user.username} label:#{caps_sensitive_label.title} searchTerm")
expect_issues_list_count(1)
expect(find('.js-milestone-select .dropdown-toggle-text')).to have_content(milestone.title)
end end
end
end
describe 'for label from issues#index', js: true do it 'filters issues by searched assignee, author, label, milestone and text' do
before do input_filtered_search("assignee:#{user.username} author:#{user.username} label:#{caps_sensitive_label.title} milestone:#{milestone.title} searchTerm")
visit namespace_project_issues_path(project.namespace, project) expect_issues_list_count(1)
find('.js-label-select').click end
wait_for_ajax
end end
it 'filters by any label' do context 'sorting', js: true do
find('.dropdown-menu-labels a', text: 'Any Label').click # TODO
page.first('.labels-filter .dropdown-title .dropdown-menu-close-icon').click
wait_for_ajax
expect(find('.labels-filter')).to have_content 'Label'
end end
end
it 'filters by no label' do describe 'filter issues by label' do
find('.dropdown-menu-labels a', text: 'No Label').click context 'only label', js: true do
page.first('.labels-filter .dropdown-title .dropdown-menu-close-icon').click it 'filters issues by searched label' do
wait_for_ajax input_filtered_search("label:#{bug_label.title}")
expect_issues_list_count(2)
page.within '.labels-filter' do
expect(page).to have_content 'Labels'
end end
expect(find('.js-label-select .dropdown-toggle-text')).to have_content('Labels')
end
it 'filters by a label' do it 'filters issues by no label' do
find('.dropdown-menu-labels a', text: label.title).click # TODO
page.within '.labels-filter' do
expect(page).to have_content label.title
end end
expect(find('.js-label-select .dropdown-toggle-text')).to have_content(label.title)
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)
end
find('.dropdown-menu-user-link', text: user.username).click
expect(page).not_to have_selector('.issues-list .issue') it 'filters issues by no milestone' do
# TODO
end
find('.js-label-select').click it 'filters issues by upcoming milestones' do
# TODO
end
find('.dropdown-menu-labels .dropdown-content a', text: label.title).click it 'filters issues by invalid milestones' do
page.first('.labels-filter .dropdown-title .dropdown-menu-close-icon').click # YOLO
end
wait_for_ajax it 'filters issues by multiple milestones' do
# YOLO
end
end end
context 'assignee and label', js: true do context 'milestone with other filters', js: true do
it 'updates to current assignee and label' do it 'filters issues by searched milestone and text' do
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 searched milestone, author and text' do
find('.issues-state-filters a', text: "Closed").click
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 searched milestone, author, assignee and text' do
find('.issues-state-filters a', text: "All").click end
expect(find('.js-assignee-search .dropdown-toggle-text')).to have_content(user.name) it 'filters issues by searched milestone, author, assignee, label and text' do
expect(find('.js-label-select .dropdown-toggle-text')).to have_content(label.title)
end end
end end
end
describe 'filter issues by text' do
before do
create(:issue, title: "Bug", project: project)
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) context 'sorting', js: true do
# TODO
end end
end
describe 'filter issues by text' do
context 'only text', js: true do context 'only text', js: true do
it 'filters issues by searched text' do it 'filters issues by searched text' do
fill_in 'issuable_search', with: 'Bug' input_filtered_search('Bug')
expect_issues_list_count(4)
page.within '.issues-list' do
expect(page).to have_selector('.issue', count: 2)
end
end end
it 'does not show any issues' do it 'filters issues by multiple searched text' do
fill_in 'issuable_search', with: 'testing' input_filtered_search('Bug report')
expect_issues_list_count(3)
page.within '.issues-list' do
expect(page).not_to have_selector('.issue')
end
end end
end
context 'text and dropdown options', js: true do it 'filters issues by case insensitive searched text' do
it 'filters by text and label' do input_filtered_search('bug report')
fill_in 'issuable_search', with: 'Bug' expect_issues_list_count(3)
expect(page).to have_issuable_counts(open: 2, closed: 0, all: 2)
page.within '.issues-list' do
expect(page).to have_selector('.issue', count: 2)
end
click_button 'Label'
page.within '.labels-filter' do
click_link 'bug'
end
find('.dropdown-menu-close-icon').click
expect(page).to have_issuable_counts(open: 1, closed: 0, all: 1)
page.within '.issues-list' do
expect(page).to have_selector('.issue', count: 1)
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)
expect(page).to have_issuable_counts(open: 2, closed: 0, all: 2)
page.within '.issues-list' do
expect(page).to have_selector('.issue', count: 2)
end
click_button 'Milestone'
page.within '.milestone-filter' do
click_link '8'
end
expect(page).to have_issuable_counts(open: 1, closed: 0, all: 1)
page.within '.issues-list' do
expect(page).to have_selector('.issue', count: 1)
end
end end
it 'filters by text and assignee' do it 'filters issues by searched text containing double quotes' do
fill_in 'issuable_search', with: 'Bug' input_filtered_search('"double quotes"')
expect_issues_list_count(1)
expect(page).to have_issuable_counts(open: 2, closed: 0, all: 2) end
page.within '.issues-list' do
expect(page).to have_selector('.issue', count: 2)
end
click_button 'Assignee' it 'filters issues by searched text containing special characters' do
page.within '.dropdown-menu-assignee' do input_filtered_search('!@#{$%^&*()-+')
click_link user.name 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 author' 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_issues_list_count(2)
end
expect(page).to have_issuable_counts(open: 2, closed: 0, all: 2) it 'filters issues by searched text, author and more text' do
page.within '.issues-list' do input_filtered_search("bug author:#{user.username} report")
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 and assignee' do
page.within '.dropdown-menu-author' do input_filtered_search("bug author:#{user.username} assignee:#{user.username}")
click_link user.name expect_issues_list_count(2)
end end
expect(page).to have_issuable_counts(open: 1, closed: 0, all: 1) 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: 1) expect_issues_list_count(1)
end
end end
end
end
describe 'filter issues and sort', js: true do it 'filters issues by searched text, author, more text, assignee and even more text' do
before do input_filtered_search("bug author:#{user.username} report assignee:#{user.username} with")
bug_label = create(:label, project: project, title: 'bug') expect_issues_list_count(1)
bug_one = create(:issue, title: "Frontend", project: project) end
bug_two = create(:issue, title: "Bug 2", project: project)
bug_one.labels << bug_label it 'filters issues by searched text, author, assignee and label' do
bug_two.labels << bug_label input_filtered_search("bug author:#{user.username} assignee:#{user.username} label:#{bug_label.title}")
expect_issues_list_count(2)
end
visit namespace_project_issues_path(project.namespace, project) it 'filters issues by searched text, author, text, assignee, text, label and text' do
end input_filtered_search("bug author:#{user.username} report assignee:#{user.username} with label:#{bug_label.title} everything")
expect_issues_list_count(1)
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