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
Re-work feature specs with new modal interface
Aaron Contrerasd34d79b19372
diff --git a/spec/support/edit_fields/progress_edit_modal.rb b/spec/support/edit_fields/progress_edit_modal.rbnew file mode 100644index 00000000000..2693e9d32a7--- /dev/null+++ b/spec/support/edit_fields/progress_edit_modal.rb@@ -0,0 +1,109 @@+# frozen_string_literal: true++# -- copyright+# OpenProject is an open source project management software.+# Copyright (C) 2024 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 "edit_field"++class ProgressEditModal+ include Capybara::DSL+ include Capybara::RSpecMatchers+ include RSpec::Matchers++ MODAL_ID = "work_package_progress_modal"+ FIELD_NAME_MAP = {+ "estimatedTime" => :estimated_hours,+ "remainingTime" => :remaining_hours+ }.freeze++ def initialize(property_name,+ selector: nil)+ @property_name = property_name.to_s+ @field_name = "work_package_#{FIELD_NAME_MAP[@property_name]}"+ @selector = selector || ".inline-edit--display-field.#{@property_name}"+ end++ # Generate+ def update(value, save: true, expect_failure: false)+ retry_block do+ activate_modal++ within_modal do+ set_value value+ save! if save+ expect_state! open: expect_failure || !save+ end+ end+ end++ private++ attr_reader :property_name,+ :field_name,+ :selector++ def activate_modal+ display_field.click+ end++ def display_field+ page.find(selector)+ end++ def within_modal(&)+ within(modal, &)+ end++ def modal+ page.find_by_id(MODAL_ID)+ end++ def set_value(value)+ page.fill_in field_name, with: value+ end++ def field+ page.find_field(field_name)+ end++ def save!+ submit_by_enter+ end++ def submit_by_enter+ field.native.send_keys :return+ end++ def expect_state!(open:)+ if open+ expect(page).to have_css("##{MODAL_ID}", :visible)+ else+ expect(page).to have_no_css("##{MODAL_ID}", wait: 0)+ end+ end+enddiff --git a/spec/support/pages/work_packages/abstract_work_package.rb b/spec/support/pages/work_packages/abstract_work_package.rbindex 5e5df98cb47..96bb0c236f7 100644--- a/spec/support/pages/work_packages/abstract_work_package.rb+++ b/spec/support/pages/work_packages/abstract_work_package.rb@@ -138,6 +138,7 @@ module Pagesdef expect_no_attribute(label)expect(page).to have_no_css(".inline-edit--container.#{label.downcase}")end+alias :expect_attribute_hidden :expect_no_attributedef expect_activity(user, number: nil)@@ -213,10 +214,12 @@ module Pageswork_package_custom_field(key, $1)when :date, :startDate, :dueDate, :combinedDateDateEditField.new container, key, is_milestone: work_package&.milestone?+ when :estimatedTime, :remainingTime+ ProgressEditModal.new keywhen :descriptionTextEditorField.new container, key- # The AbstractWorkPackageCreate pages do not require a special WorkPackageStatusField,- # because the status field on the create pages is a simple EditField.+ # The AbstractWorkPackageCreate pages do not require a special WorkPackageStatusField,+ # because the status field on the create pages is a simple EditField.when :statusif create_page?EditField.new container, key, create_form: true