From e487d53abeaf981edd896dbe08a2fddefeba212e Mon Sep 17 00:00:00 2001 From: Markus Kahl Date: Fri, 21 Oct 2016 16:02:27 +0100 Subject: [PATCH] regression test for #24114 (broken watcher filter) --- .../work_packages/table/filter_spec.rb | 39 +++++++++++++++++++ .../components/work_packages/filters.rb | 5 +++ spec/support/pages/work_packages_table.rb | 6 ++- 3 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 spec/features/work_packages/table/filter_spec.rb diff --git a/spec/features/work_packages/table/filter_spec.rb b/spec/features/work_packages/table/filter_spec.rb new file mode 100644 index 0000000000..540f7edbdf --- /dev/null +++ b/spec/features/work_packages/table/filter_spec.rb @@ -0,0 +1,39 @@ +require 'spec_helper' + +describe 'filter by watcher', js: true do + let(:user) { FactoryGirl.create :admin } + let(:watcher) { FactoryGirl.create :user } + let(:project) { FactoryGirl.create :project } + let(:role) { FactoryGirl.create :existing_role, permissions: [:view_work_packages] } + + let(:work_packages) { FactoryGirl.create_list :work_package, 10, project: project } + let(:watched_wps) { [work_packages[3], work_packages[5], work_packages[7]] } + + let(:wp_table) { ::Pages::WorkPackagesTable.new } + let(:filters) { ::Components::WorkPackages::Filters.new } + + before do + project.add_member! watcher, role + + watched_wps.each_with_index do |wp, i| + wp.add_watcher watcher + wp.subject = "Watched WP ##{i}" + wp.save! + end + + login_as(user) + wp_table.visit! + end + + # Regression test for bug #24114 (broken watcher filter) + it 'should only filter work packages by watcher' do + filters.open + loading_indicator_saveguard + + filters.filter_by_watcher watcher.name + loading_indicator_saveguard + + expect(wp_table).to have_work_packages_listed watched_wps + expect(wp_table).not_to have_work_packages_listed (work_packages - watched_wps) + end +end diff --git a/spec/support/components/work_packages/filters.rb b/spec/support/components/work_packages/filters.rb index 306596a440..59d717d4bc 100644 --- a/spec/support/components/work_packages/filters.rb +++ b/spec/support/components/work_packages/filters.rb @@ -49,6 +49,11 @@ module Components expect(page).to have_selector(filters_selector, visible: :hidden) end + def filter_by_watcher(name) + select "Watcher", from: "add_filter_select" + select name, from: "values-watcher" + end + def remove_filter(field) page.within(filters_selector) do find("#filter_#{field} .advanced-filters--remove-filter-icon").click diff --git a/spec/support/pages/work_packages_table.rb b/spec/support/pages/work_packages_table.rb index 143b56cc29..176b501466 100644 --- a/spec/support/pages/work_packages_table.rb +++ b/spec/support/pages/work_packages_table.rb @@ -43,10 +43,14 @@ module Pages def expect_work_package_listed(work_package) within(table_container) do - expect(page).to have_content(work_package.subject) + expect(page).to have_cont_nt(work_package.subject) end end + def has_work_packages_listed?(work_packages) + work_packages.all? { |wp| has_text? wp.subject } + end + def expect_no_work_package_listed within(table_container) do expect(page).to have_selector('#empty-row-notification')