Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Add basic test for showing queries only the belonging module

Henriette Darge889730658e7c
diff --git a/modules/team_planner/spec/features/query_handling_spec.rb b/modules/team_planner/spec/features/query_handling_spec.rb
index 1316f20f4af..bd9b6a35aed 100644
--- a/modules/team_planner/spec/features/query_handling_spec.rb
+++ b/modules/team_planner/spec/features/query_handling_spec.rb
@@ -73,7 +73,9 @@ describe 'Team planner query handling', type: :feature, js: true do
end
let(:team_planner) { ::Pages::TeamPlanner.new project }
+ let(:work_package_page) { ::Pages::WorkPackagesTable.new project }
let(:query_title) { ::Components::WorkPackages::QueryTitle.new }
+ let(:query_menu) { ::Components::WorkPackages::QueryMenu.new }
let(:filters) { team_planner.filters }
current_user { user }
@@ -106,4 +108,27 @@ describe 'Team planner query handling', type: :feature, js: true do
team_planner.expect_and_dismiss_toaster(message: I18n.t('js.notice_successful_create'))
end
+
+ it 'shows only team planner queries' do
+ # Go to team planner where no query is shown
+ team_planner.visit!
+ query_menu.expect_no_menu_entry
+
+ # Change filter
+ filters.open
+ filters.add_filter_by('Type', 'is', [type_bug.name])
+ filters.expect_filter_count("2")
+
+ # Save current filters
+ query_title.expect_changed
+ query_title.rename 'I am your Query'
+ team_planner.expect_and_dismiss_toaster(message: I18n.t('js.notice_successful_create'))
+
+ # The saved query appears in the side menu...
+ query_menu.expect_menu_entry 'I am your Query'
+
+ # .. but not in the work packages module
+ work_package_page.visit!
+ query_menu.expect_menu_entry_not_visible 'I am your Query'
+ end
end
diff --git a/spec/support/components/work_packages/query_menu.rb b/spec/support/components/work_packages/query_menu.rb
index 914fd0aa97a..5b456ef6d70 100644
--- a/spec/support/components/work_packages/query_menu.rb
+++ b/spec/support/components/work_packages/query_menu.rb
@@ -57,6 +57,18 @@ module Components
def autocompleter_selector
'#query-title-filter'
end
+
+ def expect_menu_entry(name)
+ expect(page).to have_selector(autocompleter_item_selector, text: name)
+ end
+
+ def expect_menu_entry_not_visible(name)
+ expect(page).not_to have_selector(autocompleter_item_selector, text: name)
+ end
+
+ def expect_no_menu_entry
+ expect(page).not_to have_selector(autocompleter_item_selector)
+ end
end
end
end