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
Add specs for stages and gates edit dialog
Dombi Attila5ad737835807
diff --git a/app/models/project/life_cycle_step.rb b/app/models/project/life_cycle_step.rbindex 30fbd04ece8..28b6a1fa9a8 100644--- a/app/models/project/life_cycle_step.rb+++ b/app/models/project/life_cycle_step.rb@@ -33,7 +33,7 @@ class Project::LifeCycleStep < ApplicationRecordclass_name: "Project::LifeCycleStepDefinition"has_many :work_packages, inverse_of: :project_life_cycle_step, dependent: :nullify- delegate :name, to: :definition+ delegate :name, :position, to: :definitionattr_readonly :definition_id, :typediff --git a/spec/features/projects/life_cycle/overview_page/dialog/update_spec.rb b/spec/features/projects/life_cycle/overview_page/dialog/update_spec.rbnew file mode 100644index 00000000000..8e57f6c3aaf--- /dev/null+++ b/spec/features/projects/life_cycle/overview_page/dialog/update_spec.rb@@ -0,0 +1,73 @@+#-- 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"+require_relative "../shared_context"++RSpec.describe "Edit project stages and gates on project overview page", :js, :with_cuprite,+ with_flag: { stages_and_gates: true } do+ include_context "with seeded projects and stages and gates"+ let(:user) { create(:admin) }+ let(:overview_page) { Pages::Projects::Show.new(project) }++ before do+ # TODO: Could this work for all feature specs?+ allow(User).to receive(:current).and_return user+ overview_page.visit_page+ end++ describe "with the dialog open" do+ context "when all LifeCycleSteps are blank" do+ before do+ Project::LifeCycleStep.update_all(start_date: nil, end_date: nil)+ end++ it "shows all the Project::LifeCycleSteps without a value" do+ dialog = overview_page.open_edit_dialog_for_life_cycles++ dialog.expect_input("Initiating", value: "", type: :stage, position: 1)+ dialog.expect_input("Ready for Planning", value: "", type: :gate, position: 2)+ dialog.expect_input("Planning", value: "", type: :stage, position: 3)+ dialog.expect_input("Ready for Executing", value: "", type: :gate, position: 4)+ dialog.expect_input("Executing", value: "", type: :stage, position: 5)+ dialog.expect_input("Ready for Closing", value: "", type: :gate, position: 6)+ dialog.expect_input("Closing", value: "", type: :stage, position: 7)+ end+ end++ context "when all LifeCycleSteps have a value" do+ it "shows all the Project::LifeCycleSteps including value" do+ dialog = overview_page.open_edit_dialog_for_life_cycles++ project.available_life_cycle_steps.each do |step|+ dialog.expect_input_for(step)+ end+ end+ end+ end+enddiff --git a/spec/support/components/projects/project_life_cycles/edit_dialog.rb b/spec/support/components/projects/project_life_cycles/edit_dialog.rbnew file mode 100644index 00000000000..d91435aa8cb--- /dev/null+++ b/spec/support/components/projects/project_life_cycles/edit_dialog.rb@@ -0,0 +1,106 @@+# -- 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 "support/components/common/modal"+require "support/components/autocompleter/ng_select_autocomplete_helpers"+module Components+ module Projects+ module ProjectLifeCycles+ class EditDialog < Components::Common::Modal+ def dialog_css_selector+ "dialog#edit-project-life-cycles-dialog"+ end++ def async_content_container_css_selector+ "#{dialog_css_selector} [data-test-selector='async-dialog-content']"+ end++ def within_dialog(&)+ within(dialog_css_selector, &)+ end++ def within_async_content(close_after_yield: false, &)+ within(async_content_container_css_selector, &)+ close if close_after_yield+ end++ def close+ within_dialog do+ page.find(".close-button").click+ end+ end+ alias_method :close_via_icon, :close++ def close_via_button+ within(dialog_css_selector) do+ click_link_or_button "Cancel"+ end+ end++ def submit+ within(dialog_css_selector) do+ page.find("[data-test-selector='save-project-life-cycles-button']").click+ end+ end++ def expect_open+ expect(page).to have_css(dialog_css_selector)+ end++ def expect_closed+ expect(page).to have_no_css(dialog_css_selector)+ end++ def expect_async_content_loaded+ expect(page).to have_css(async_content_container_css_selector)+ end++ def expect_input(label, value:, type:, position:)+ field = type == :stage ? :date_range : :date+ expect(page).to have_field(+ label,+ with: value,+ name: "project[available_life_cycle_steps_attributes][#{position - 1}][#{field}]"+ )+ end++ def expect_input_for(step)+ options = if step.is_a?(Project::Stage)+ value = "#{step.start_date.strftime('%Y-%m-%d')} - #{step.end_date.strftime('%Y-%m-%d')}"+ { type: :stage, value: }+ else+ value = step.date.strftime("%Y-%m-%d")+ { type: :gate, value: }+ end++ expect_input(step.name, position: step.position, **options)+ end+ end+ end+ end+enddiff --git a/spec/support/pages/projects/show.rb b/spec/support/pages/projects/show.rbindex fb246d90ec5..bae1d5210bb 100644--- a/spec/support/pages/projects/show.rb+++ b/spec/support/pages/projects/show.rb@@ -33,11 +33,9 @@ module Pagesclass Show < ::Pages::Pageattr_reader :project- # rubocop:disable Lint/MissingSuperdef initialize(project)@project = projectend- # rubocop:enable Lint/MissingSuperdef pathproject_path(project)@@ -87,6 +85,14 @@ module Pagesexpect(page).to have_css("[data-test-selector='async-dialog-content']", wait: 5)end+ def open_edit_dialog_for_life_cycles+ within_life_cycles_sidebar do+ page.find("[data-test-selector='project-life-cycles-edit-button']").click+ end++ Components::Projects::ProjectLifeCycles::EditDialog.new.tap(&:expect_open)+ end+def within_life_cycles_sidebar(&)within "#project-life-cycles-sidebar" doexpect(page).to have_css("[data-test-selector='project-life-cycles-sidebar-async-content']")