diff --git a/spec/support/edit_fields/inline_project_edit_field.rb b/spec/support/edit_fields/inline_project_edit_field.rb new file mode 100644 index 00000000000..705df4b9944 --- /dev/null +++ b/spec/support/edit_fields/inline_project_edit_field.rb @@ -0,0 +1,42 @@ +# 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_relative "project_edit_field" + +# For work package table inline editing +class InlineProjectEditField < ProjectEditField + def autocompleter + field_container.find("op-project-autocompleter") + end + + def field_type + "op-project-autocompleter" + end +end diff --git a/spec/support/edit_fields/project_edit_field.rb b/spec/support/edit_fields/project_edit_field.rb index 7255d8ae18b..b69dfe835bd 100644 --- a/spec/support/edit_fields/project_edit_field.rb +++ b/spec/support/edit_fields/project_edit_field.rb @@ -1,16 +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_relative "select_edit_field" class ProjectEditField < SelectField def autocompleter - if @selector&.start_with?("op") - # Direct autocompleter selector (for settings pages) - field_container - else - # Inline edit container (for work package tables) - field_container.find("op-project-autocompleter") - end + field_container end def search_for(query) @@ -25,14 +47,12 @@ class ProjectEditField < SelectField def expect_option(name, workspace_badge: false) within(dropdown) do - # Find the option containing the name option = page.find(".ng-option", text: name) if workspace_badge expect(option).to have_octicon expect(option).to have_primer_text(workspace_badge, color: :muted) else - # Expect no octicon SVG expect(option).to have_no_octicon expect(option).to have_no_primer_text(color: :muted) end diff --git a/spec/support/pages/work_packages/work_packages_table.rb b/spec/support/pages/work_packages/work_packages_table.rb index 9199f0b885f..dce769771b8 100644 --- a/spec/support/pages/work_packages/work_packages_table.rb +++ b/spec/support/pages/work_packages/work_packages_table.rb @@ -391,7 +391,7 @@ module Pages when :estimatedTime, :remainingTime ProgressEditField.new container, key when :project - ProjectEditField.new container, key + InlineProjectEditField.new container, key else EditField.new container, key end