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
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
Fix specs for reporting to work with autocompleters
Klaus Zanders678cfc2fd00f
diff --git a/modules/reporting/spec/features/filter_spec.rb b/modules/reporting/spec/features/filter_spec.rbindex 21b52eb3422..8daeb6d09a4 100644--- a/modules/reporting/spec/features/filter_spec.rb+++ b/modules/reporting/spec/features/filter_spec.rb@@ -1,6 +1,38 @@+# frozen_string_literal: true++#-- copyright+# OpenProject is an open source project management software.+# Copyright (C) the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# This program is distributed in the hope that it will be useful,+# but WITHOUT ANY WARRANTY; without even the implied warranty of+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+# GNU General Public License for more details.+#+# You should have received a copy of the GNU General Public License+# along with this program; if not, write to the Free Software+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.+#+# See COPYRIGHT and LICENSE files for more details.+#+++require "spec_helper"RSpec.describe "Cost report calculations", :js do+ include Components::Autocompleter::NgSelectAutocompleteHelpers+let(:project) { create(:project) }let(:user) { create(:admin) }@@ -49,6 +81,7 @@ RSpec.describe "Cost report calculations", :js doexpect(page).to have_css("#filter_spent_on")expect(page).to have_css("#filter_user_id")- expect(page).to have_css("#user_id_arg_1_val", text: "me")+ user_autocompleter = find("opce-user-autocompleter#user_id_select_1")+ expect_current_autocompleter_value(user_autocompleter, "me")endenddiff --git a/modules/reporting/spec/features/me_value_spec.rb b/modules/reporting/spec/features/me_value_spec.rbindex 6a8d2861920..d335bee08ce 100644--- a/modules/reporting/spec/features/me_value_spec.rb+++ b/modules/reporting/spec/features/me_value_spec.rb@@ -1,6 +1,8 @@require "spec_helper"RSpec.describe "Cost report showing my own times", :js do+ include Components::Autocompleter::NgSelectAutocompleteHelpers+let(:project) { create(:project) }let(:user) { create(:admin) }let(:user2) { create(:admin) }@@ -33,7 +35,11 @@ RSpec.describe "Cost report showing my own times", :js doshared_examples "me filter value" do |filter_name, filter_selector|it 'keeps the special "me" value for the current user' do- select "me", from: filter_selector+ user_autocompleter = find("opce-user-autocompleter##{filter_selector}")++ ng_select_clear(user_autocompleter, raise_on_missing: false)+ select_autocomplete(user_autocompleter, query: "me")+click_on "Save"fill_in "query_name", with: "Query ME value"check "query_is_public"@@ -57,10 +63,9 @@ RSpec.describe "Cost report showing my own times", :js do# Create and save cost reportvisit cost_report_path(report.id, project_id: project.identifier)- expect(page).to have_no_css(".report", text: "10.00")expect(page).to have_css(".report", text: "15.00")- expect(page).to have_field(filter_selector, text: "me")+ expect_current_autocompleter_value(user_autocompleter, "me")endend@@ -89,10 +94,10 @@ RSpec.describe "Cost report showing my own times", :js doselect "Assignee", from: "add_filter_select"end- it_behaves_like "me filter value", "AssignedToId", "assigned_to_id_arg_1_val"+ it_behaves_like "me filter value", "AssignedToId", "assigned_to_id_select_1"enddescribe "user filter" do- it_behaves_like "me filter value", "UserId", "user_id_arg_1_val"+ it_behaves_like "me filter value", "UserId", "user_id_select_1"endenddiff --git a/modules/reporting/spec/features/work_package_costlog_spec.rb b/modules/reporting/spec/features/work_package_costlog_spec.rbindex c9d0eb3883e..f8565b904b5 100644--- a/modules/reporting/spec/features/work_package_costlog_spec.rb+++ b/modules/reporting/spec/features/work_package_costlog_spec.rb@@ -1,6 +1,38 @@+# frozen_string_literal: true++#-- copyright+# OpenProject is an open source project management software.+# Copyright (C) the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# This program is distributed in the hope that it will be useful,+# but WITHOUT ANY WARRANTY; without even the implied warranty of+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+# GNU General Public License for more details.+#+# You should have received a copy of the GNU General Public License+# along with this program; if not, write to the Free Software+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.+#+# See COPYRIGHT and LICENSE files for more details.+#+++require "spec_helper"RSpec.describe "Cost report showing my own times", :js do+ include Components::Autocompleter::NgSelectAutocompleteHelpers+let(:project) { create(:project) }let(:user) docreate(:user, member_with_roles: { project => role })@@ -39,7 +71,8 @@ RSpec.describe "Cost report showing my own times", :js dowithin_window new_window doexpect(page).to have_css("#query_saved_name", text: "New cost report")- expect(page).to have_field("values[work_package_id][]", with: work_package.id)+ wp_autocompleter = find("opce-autocompleter#work_package_id_select_1")+ expect_current_autocompleter_value(wp_autocompleter, "##{work_package.id} #{work_package.subject}")expect(page).to have_css("td.units", text: "10.0 Foobars")endenddiff --git a/spec/features/activities/time_entry_activity_spec.rb b/spec/features/activities/time_entry_activity_spec.rbindex 002577e7119..13b8e72a814 100644--- a/spec/features/activities/time_entry_activity_spec.rb+++ b/spec/features/activities/time_entry_activity_spec.rb@@ -33,6 +33,8 @@ require "spec_helper"RSpec.describe "TimeEntry activity",:js,with_settings: { journal_aggregation_time_minutes: 0 } do+ include Components::Autocompleter::NgSelectAutocompleteHelpers+let(:user) docreate(:user,member_with_permissions: { project => %i[log_time@@ -80,7 +82,8 @@ RSpec.describe "TimeEntry activity",wait_for_reload- expect(page).to have_field("Work package Value", with: work_package.id)+ wp_autocompleter = find("opce-autocompleter#work_package_id_select_1")+ expect_current_autocompleter_value(wp_autocompleter, "##{work_package.id} #{work_package.subject}")old_comments = time_entry.commentsold_spent_on = time_entry.spent_on@@ -105,7 +108,8 @@ RSpec.describe "TimeEntry activity",within("li.op-activity-list--item", match: :first) doexpect(page).to have_link("#{project.types.first} ##{work_package2.id}: #{work_package2.subject}")expect(page).to have_css("li", text: "Logged for #{user2.name}")- expect(page).to have_css("li", text: "Logged for changed from #{work_package.name} to #{work_package2.name}")+ expect(page).to have_css("li",+ text: "Logged for changed from #{work_package.name} to #{work_package2.name}")expect(page).to have_css("li", text: "Spent time changed from 5 hours to 1 hour")expect(page).to have_css("li", text: "Comment changed from #{old_comments} to #{time_entry.comments}")expect(page).to have_css("li",@@ -116,6 +120,7 @@ RSpec.describe "TimeEntry activity",wait_for_reload- expect(page).to have_field("Work package Value", with: work_package2.id)+ wp_autocompleter = find("opce-autocompleter#work_package_id_select_1")+ expect_current_autocompleter_value(wp_autocompleter, "##{work_package2.id} #{work_package2.subject}")endenddiff --git a/spec/support/components/autocompleter/ng_select_autocomplete_helpers.rb b/spec/support/components/autocompleter/ng_select_autocomplete_helpers.rbindex 9d854df90fb..28ed3f61b61 100644--- a/spec/support/components/autocompleter/ng_select_autocomplete_helpers.rb+++ b/spec/support/components/autocompleter/ng_select_autocomplete_helpers.rb@@ -159,6 +159,10 @@ module Components::Autocompletertarget_dropdown.first(".ng-option", text:, wait: 15).clickend+ def expect_current_autocompleter_value(element, value)+ expect(element).to have_css(".ng-value .ng-value-label", text: value, wait: 10)+ end+# Finds the currently visible, expanded user auto completer and returns its dropdown menu options.# A user always has a name, but their email is only visible in certain circumstances, so that value# might be nil.