summaryrefslogtreecommitdiff
path: root/spec/features
diff options
context:
space:
mode:
authorBryce Johnson <bryce@gitlab.com>2016-09-02 20:04:55 +0200
committerBryce Johnson <bryce@gitlab.com>2016-09-02 20:30:36 +0200
commite1f2ff91eb1df285ac1ef07a2a93d479971084d4 (patch)
tree46dfb981805510dfe81a5a828116007ae5e5bc1f /spec/features
parent1750fe321052c96fb896bad3e51c1bbee74d6600 (diff)
downloadgitlab-ce-e1f2ff91eb1df285ac1ef07a2a93d479971084d4.tar.gz
Add tests for reset filters button.
Diffstat (limited to 'spec/features')
-rw-r--r--spec/features/issues/reset_filters_spec.rb97
1 files changed, 97 insertions, 0 deletions
diff --git a/spec/features/issues/reset_filters_spec.rb b/spec/features/issues/reset_filters_spec.rb
new file mode 100644
index 00000000000..6d08a30c7ad
--- /dev/null
+++ b/spec/features/issues/reset_filters_spec.rb
@@ -0,0 +1,97 @@
+require 'rails_helper'
+
+feature 'Filter Resetter', feature: true do
+ include WaitForAjax
+
+ let(:project) { create(:project, :public) }
+ let(:milestone) { create(:milestone, project: project) }
+
+ context 'resets the milestone filter', js: true do
+ it 'shows all issues when reset' do
+ create(:issue, project: project, milestone: milestone)
+ create(:issue, project: project)
+
+ visit_issues(project)
+
+ filter_by_milestone(milestone.title)
+ expect(page).to have_css(".issue", count: 1)
+
+ reset_filters
+ expect(page).to have_css(".issue", count: 2)
+ end
+ end
+
+ context 'resets labels filter', js:true do
+ it 'shows all issues when reset' do
+ bug = create(:label, project: project, title: 'bug')
+ issue1 = create(:issue, title: "Bugfix1", project: project)
+ issue1.labels << bug
+ issue2 = create(:issue, title: "Feature", project: project)
+
+ visit_issues(project)
+
+ filter_by_label(bug.title)
+ expect(page).to have_css(".issue", count: 1)
+
+ reset_filters
+ expect(page).to have_css(".issue", count: 2)
+ end
+ end
+
+ context 'resets text filter', js:true do
+ it 'shows all issues when reset' do
+ issue1 = create(:issue, title: "Bugfix1", project: project)
+ issue2 = create(:issue, title: "Feature", project: project)
+
+ visit_issues(project)
+ fill_in 'issue_search', with: 'Bug'
+ expect(page).to have_css(".issue", count: 1)
+
+ reset_filters
+ expect(page).to have_css(".issue", count: 2)
+ end
+ end
+
+ context 'resets label and text dually applied', js:true do
+ it 'shows all issues when reset' do
+ bug = create(:label, project: project, title: 'bug')
+ issue1 = create(:issue, title: "Bugfix1", project: project)
+ issue1.labels << bug
+ issue2 = create(:issue, project: project, title: 'Feature1')
+
+ visit_issues(project)
+ expect(page).to have_css('.issue', count: 2)
+
+ fill_in 'issue_search', with: 'Feat'
+ expect(page).to have_css(".issue", count: 1)
+
+ wait_for_ajax
+
+ filter_by_label(bug.title)
+ expect(page).to have_css(".issue", count: 0)
+
+ reset_filters
+ expect(page).to have_css(".issue", count: 2)
+ 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 reset_filters()
+ find(".reset-filters").click
+ wait_for_ajax
+ end
+
+ def visit_issues(project)
+ visit namespace_project_issues_path(project.namespace, project)
+ end
+end