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
Move autocomplete helper to the proper place
Tobias Dillmann0f0e361ac21f
diff --git a/spec/features/work_packages/edit_work_package_spec.rb b/spec/features/work_packages/edit_work_package_spec.rbindex 6a185f73568..d71c5775d88 100644--- a/spec/features/work_packages/edit_work_package_spec.rb+++ b/spec/features/work_packages/edit_work_package_spec.rb@@ -1,7 +1,9 @@require "spec_helper"require "features/page_objects/notification"-RSpec.describe "edit work package", :js do+RSpec.describe "edit work package", :js, :with_cuprite do+ include Components::Autocompleter::NgSelectAutocompleteHelpers+let!(:standard_global_role) { create(:empty_global_role) }let(:dev_role) docreate(:project_role,@@ -271,7 +273,7 @@ RSpec.describe "edit work package", :js docompleter = wp_page.edit_field field_namecompleter.activate!- options = wp_page.visible_user_auto_completer_options+ options = visible_user_auto_completer_optionsexpected_options = [{ name: manager.name, email: nil }, # Manager's email should not be visible@@ -287,7 +289,7 @@ RSpec.describe "edit work package", :js docompleter = wp_page.edit_field field_namecompleter.activate!- options = wp_page.visible_user_auto_completer_options+ options = visible_user_auto_completer_optionsexpected_options = [# With the right permissions, you can see other users email addressdiff --git a/spec/support/components/autocompleter/ng_select_autocomplete_helpers.rb b/spec/support/components/autocompleter/ng_select_autocomplete_helpers.rbindex 1133b4cf0b6..d71554be04d 100644--- a/spec/support/components/autocompleter/ng_select_autocomplete_helpers.rb+++ b/spec/support/components/autocompleter/ng_select_autocomplete_helpers.rb@@ -118,5 +118,27 @@ module Components::Autocompleter# click the element to select ittarget_dropdown.find(".ng-option", text:, match: :first, wait: 15).clickend++ # 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.+ #+ # The options are returned as an Array of Hashes, like this example with two users:+ #+ # [+ # { name: "Bob", email: nil },+ # { name: "Alice", email: "[email protected]" }+ # ]+ #+ # The order of elements in the Array is equal to the visible order on the website.+ def visible_user_auto_completer_options+ find(".ng-dropdown-panel [role='listbox']").all(".ng-option[role='option']").map do |opt|+ name = opt.find(".op-user-autocompleter--name").text+ email_element = opt.all(".op-autocompleter__option-principal-email").first+ email = email_element&.text++ { name:, email: }+ end+ endendenddiff --git a/spec/support/pages/work_packages/abstract_work_package.rb b/spec/support/pages/work_packages/abstract_work_package.rbindex 5434ba29aad..14d2ddf8ff9 100644--- a/spec/support/pages/work_packages/abstract_work_package.rb+++ b/spec/support/pages/work_packages/abstract_work_package.rb@@ -332,28 +332,6 @@ module Pagesfind('[data-test-selector="mark-notification-read-button"]').clickend- # 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.- #- # The options are returned as an Array of Hashes, like this example with two users:- #- # [- # { name: "Bob", email: nil },- # { name: "Alice", email: "[email protected]" }- # ]- #- # The order of elements in the Array is equal to the visible order on the website.- def visible_user_auto_completer_options- find(".ng-dropdown-panel [role='listbox']").all(".ng-option[role='option']").map do |opt|- name = opt.find(".op-user-autocompleter--name").text- email_element = opt.all(".op-autocompleter__option-principal-email").first- email = email_element&.text-- { name:, email: }- end- end-privatedef create_page(_args)