Commit 08b05d0c authored by Bryce Johnson's avatar Bryce Johnson

Refactor filters reset test to re-use issues.

parent 87f6209c
...@@ -3,16 +3,19 @@ require 'rails_helper' ...@@ -3,16 +3,19 @@ require 'rails_helper'
feature 'Issues filter reset button', feature: true, js: true do feature 'Issues filter reset button', feature: true, js: true do
include WaitForAjax include WaitForAjax
let(:project) { create(:project, :public) } let!(:project) { create(:project, :public) }
let(:milestone) { create(:milestone, project: project) } let!(:user) { create(:user)}
let!(:milestone) { create(:milestone, project: project) }
let!(:bug) { create(:label, project: project, name: 'bug')} # maybe switch back to title
let!(:issue1) { create(:issue, project: project, milestone: milestone, author: user, assignee: user, title: 'Feature')}
let!(:issue2) { create(:labeled_issue, project: project, labels: [bug], title: 'Bugfix1')}
before do
visit_issues(project)
end
context 'when a milestone filter has been applied' do context 'when a milestone filter has been applied' do
it 'resets the milestone filter' do it 'resets the milestone filter' do
create(:issue, project: project, milestone: milestone)
create(:issue, project: project)
visit_issues(project)
filter_by_milestone(milestone.title) filter_by_milestone(milestone.title)
expect(page).to have_css('.issue', count: 1) expect(page).to have_css('.issue', count: 1)
...@@ -23,14 +26,6 @@ feature 'Issues filter reset button', feature: true, js: true do ...@@ -23,14 +26,6 @@ feature 'Issues filter reset button', feature: true, js: true do
context 'when a label filter has been applied' do context 'when a label filter has been applied' do
it 'resets the label filter' do it 'resets the label filter' do
bug = create(:label, project: project, title: 'bug')
issue1 = create(:issue, title: 'Bugfix1', project: project)
issue1.labels << bug
create(:issue, title: 'Feature', project: project)
visit_issues(project)
filter_by_label(bug.title) filter_by_label(bug.title)
expect(page).to have_css('.issue', count: 1) expect(page).to have_css('.issue', count: 1)
...@@ -41,10 +36,6 @@ feature 'Issues filter reset button', feature: true, js: true do ...@@ -41,10 +36,6 @@ feature 'Issues filter reset button', feature: true, js: true do
context 'when a text search has been conducted' do context 'when a text search has been conducted' do
it 'resets the text search filter' do it 'resets the text search filter' do
create(:issue, title: 'Bugfix1', project: project)
create(:issue, title: 'Feature', project: project)
visit_issues(project)
fill_in 'issue_search', with: 'Bug' fill_in 'issue_search', with: 'Bug'
expect(page).to have_css('.issue', count: 1) expect(page).to have_css('.issue', count: 1)
...@@ -54,15 +45,28 @@ feature 'Issues filter reset button', feature: true, js: true do ...@@ -54,15 +45,28 @@ feature 'Issues filter reset button', feature: true, js: true do
end end
end end
context 'when label and text filters have been dually applied' do context 'when author filter has been applied' do
it 'resets both filters' do it 'resets the author filter' do
bug = create(:label, project: project, title: 'bug') filter_by_author(user.name)
issue1 = create(:issue, title: 'Bugfix1', project: project) expect(page).to have_css('.issue', count: 1)
issue1.labels << bug
create(:issue, project: project, title: 'Feature1')
visit_issues(project) reset_filters
expect(page).to have_css('.issue', count: 2)
end
end
context 'when assignee filter has been applied' do
it 'resets the assignee filter' do
filter_by_assignee(user.name)
expect(page).to have_css('.issue', count: 1)
reset_filters
expect(page).to have_css('.issue', count: 2)
end
end
context 'when label and text filters have been dually applied' do
it 'resets both filters' do
fill_in 'issue_search', with: 'Feat' fill_in 'issue_search', with: 'Feat'
expect(page).to have_css('.issue', count: 1) expect(page).to have_css('.issue', count: 1)
...@@ -87,6 +91,16 @@ feature 'Issues filter reset button', feature: true, js: true do ...@@ -87,6 +91,16 @@ feature 'Issues filter reset button', feature: true, js: true do
find('.labels-filter .dropdown-title .dropdown-menu-close-icon').click find('.labels-filter .dropdown-title .dropdown-menu-close-icon').click
end 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 def reset_filters
find('.reset-filters').click find('.reset-filters').click
wait_for_ajax wait_for_ajax
......
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