Commit c7f74256 authored by Bryce Johnson's avatar Bryce Johnson

Simulate filtering with url params, clean up accordingly.

parent a329763d
......@@ -2,6 +2,7 @@ require 'rails_helper'
feature 'Issues filter reset button', feature: true, js: true do
include WaitForAjax
include IssueHelpers
let!(:project) { create(:project, :public) }
let!(:user) { create(:user)}
......@@ -12,12 +13,11 @@ feature 'Issues filter reset button', feature: true, js: true do
before do
project.team << [user, :developer]
visit_issues(project)
end
context 'when a milestone filter has been applied' do
it 'resets the milestone filter' do
filter_by_milestone(milestone.title)
visit_issues(project, milestone_title: milestone.title)
expect(page).to have_css('.issue', count: 1)
reset_filters
......@@ -27,7 +27,7 @@ feature 'Issues filter reset button', feature: true, js: true do
context 'when a label filter has been applied' do
it 'resets the label filter' do
filter_by_label(bug.title)
visit_issues(project, label_name: bug.name)
expect(page).to have_css('.issue', count: 1)
reset_filters
......@@ -37,8 +37,7 @@ feature 'Issues filter reset button', feature: true, js: true do
context 'when a text search has been conducted' do
it 'resets the text search filter' do
fill_in 'issue_search', with: 'Bug'
visit_issues(project, issue_search: 'Bug')
expect(page).to have_css('.issue', count: 1)
reset_filters
......@@ -48,7 +47,7 @@ feature 'Issues filter reset button', feature: true, js: true do
context 'when author filter has been applied' do
it 'resets the author filter' do
filter_by_author(user.name)
visit_issues(project, author_id: user.id)
expect(page).to have_css('.issue', count: 1)
reset_filters
......@@ -58,7 +57,7 @@ feature 'Issues filter reset button', feature: true, js: true do
context 'when assignee filter has been applied' do
it 'resets the assignee filter' do
filter_by_assignee(user.name)
visit_issues(project, assignee_id: user.id)
expect(page).to have_css('.issue', count: 1)
reset_filters
......@@ -68,17 +67,7 @@ feature 'Issues filter reset button', feature: true, js: true do
context 'when all filters have been applied' do
it 'resets all filters' do
wait_for_ajax
filter_by_milestone(milestone.title)
wait_for_ajax
filter_by_author(user.username)
wait_for_ajax
visit_issues(project, assignee_id: user.id, author_id: user.id, milestone_title: milestone.title, label_name: bug.name, issue_search: 'Bug')
expect(page).to have_css('.issue', count: 0)
reset_filters
......@@ -86,33 +75,7 @@ feature 'Issues filter reset button', feature: true, js: true do
end
end
def filter_by_milestone(title)
find('.js-milestone-select').click
find('.milestone-filter .dropdown-content a', text: title).click
end
def filter_by_label(title)
find('.js-label-select').click
find('.labels-filter .dropdown-content a', text: title).click
find('.labels-filter .dropdown-title .dropdown-menu-close-icon').click
end
def filter_by_author(name)
find('.js-author-search').click
find('.dropdown-menu-author .dropdown-content a', text: name).click
end
def filter_by_assignee(name)
find('.js-assignee-search').click
find('.dropdown-menu-assignee .dropdown-content a', text: name).click
end
def reset_filters
find('.reset-filters').click
wait_for_ajax
end
def visit_issues(project)
visit namespace_project_issues_path(project.namespace, project)
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