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
feature spec for all actions except moving using handler
Ivan Kuchind9e750c28c4c
diff --git a/app/components/settings/project_life_cycle_step_definitions/index_component.html.erb b/app/components/settings/project_life_cycle_step_definitions/index_component.html.erbindex c09c6bd2505..05f8a68de37 100644--- a/app/components/settings/project_life_cycle_step_definitions/index_component.html.erb+++ b/app/components/settings/project_life_cycle_step_definitions/index_component.html.erb@@ -104,6 +104,7 @@ See COPYRIGHT and LICENSE files for more details.component.with_row(data: {"projects--settings--border-box-filter-target": "searchItem",+ test_selector: "project-life-cycle-step-definition",**draggable_item_config(definition)}) dodiff --git a/app/components/settings/project_life_cycle_step_definitions/row_component.html.erb b/app/components/settings/project_life_cycle_step_definitions/row_component.html.erbindex 6d177f9e583..645d282ed37 100644--- a/app/components/settings/project_life_cycle_step_definitions/row_component.html.erb+++ b/app/components/settings/project_life_cycle_step_definitions/row_component.html.erb@@ -37,7 +37,7 @@ See COPYRIGHT and LICENSE files for more details.))endend- title_container.with_column(classes: "ellipsis") do+ title_container.with_column(classes: "ellipsis", test_selector: "project-life-cycle-step-definition-name") dorender(if allowed_to_customize_life_cycle?Primer::Beta::Link.new(diff --git a/spec/features/admin/project_life_cycle_step_definitions_spec.rb b/spec/features/admin/project_life_cycle_step_definitions_spec.rbnew file mode 100644index 00000000000..ef0ecf2c210--- /dev/null+++ b/spec/features/admin/project_life_cycle_step_definitions_spec.rb@@ -0,0 +1,134 @@+# -- copyright+# OpenProject is an open source project management software.+# Copyright (C) 2010-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 "spec_helper"++RSpec.describe "Projects life cycle settings", :js, :with_cuprite, with_flag: { stages_and_gates: true } do+ shared_let(:initiating_stage) { create(:project_stage_definition, name: "Initiating") }+ shared_let(:ready_to_execute_gate) { create(:project_gate_definition, name: "Ready to Execute") }+ shared_let(:executing_stage) { create(:project_stage_definition, name: "Executing") }++ let(:definitions_page) { Pages::Admin::Settings::ProjectLifeCycleStepDefinitions.new }++ context "as non admin" do+ current_user { create(:user) }++ it "does not allow the user to access the page" do+ definitions_page.visit!++ definitions_page.expect_listed([])++ definitions_page.expect_flash(message: "You are not authorized to access this page", type: :error)+ end+ end++ context "as admin without activated enterprise token" do+ current_user { create(:admin) }++ it "allows viewing definitions" do+ definitions_page.visit!++ definitions_page.expect_listed(["Initiating", "Ready to Execute", "Executing"])++ definitions_page.expect_no_controls+ end+ end++ context "as admin with activated enterprise token", with_ee: %i[customize_life_cycle] do+ current_user { create(:admin) }++ before do+ create(:color, name: "Azure", hexcode: "#0056b9")+ create(:color, name: "Gold", hexcode: "#ffd800")+ end++ it "allows managing definitions" do+ definitions_page.visit!+ definitions_page.expect_listed(["Initiating", "Ready to Execute", "Executing"])++ # filtering+ definitions_page.filter_with("ing")+ definitions_page.expect_listed(["Initiating", "Executing"])++ definitions_page.expect_no_ordering_controls++ definitions_page.clear_filter+ definitions_page.expect_listed(["Initiating", "Ready to Execute", "Executing"])++ # editing steps+ definitions_page.click_definition("Ready to Execute")+ fill_in "Name", with: "Ready to Process"+ click_on "Update"++ definitions_page.click_definition_action("Executing", action: "Edit")+ fill_in "Name", with: "Processing"+ click_on "Update"++ definitions_page.expect_listed(["Initiating", "Ready to Process", "Processing"])++ # creating steps+ definitions_page.add("Stage")+ fill_in "Name", with: "Imagining"+ definitions_page.select_color("Azure")+ click_on "Create"++ definitions_page.add("Gate")+ fill_in "Name", with: "Ready to Initiate"+ definitions_page.select_color("Gold")+ click_on "Create"++ definitions_page.expect_listed(["Initiating", "Ready to Process", "Processing", "Imagining", "Ready to Initiate"])++ # moving+ definitions_page.click_definition_action("Processing", action: "Move to bottom")+ wait_for_network_idle+ definitions_page.expect_listed(["Initiating", "Ready to Process", "Imagining", "Ready to Initiate", "Processing"])++ definitions_page.click_definition_action("Imagining", action: "Move to top")+ wait_for_network_idle+ definitions_page.expect_listed(["Imagining", "Initiating", "Ready to Process", "Ready to Initiate", "Processing"])++ definitions_page.click_definition_action("Ready to Process", action: "Move down")+ wait_for_network_idle+ definitions_page.expect_listed(["Imagining", "Initiating", "Ready to Initiate", "Ready to Process", "Processing"])++ definitions_page.click_definition_action("Ready to Initiate", action: "Move up")+ wait_for_network_idle+ definitions_page.expect_listed(["Imagining", "Ready to Initiate", "Initiating", "Ready to Process", "Processing"])++ definitions_page.reload!+ definitions_page.expect_listed(["Imagining", "Ready to Initiate", "Initiating", "Ready to Process", "Processing"])++ # deleting+ accept_confirm I18n.t(:text_are_you_sure_with_project_life_cycle_step) do+ definitions_page.click_definition_action("Initiating", action: "Delete")+ end+ definitions_page.expect_listed(["Imagining", "Ready to Initiate", "Ready to Process", "Processing"])+ end+ end+enddiff --git a/spec/support/pages/admin/settings/project_life_cycle_step_definitions.rb b/spec/support/pages/admin/settings/project_life_cycle_step_definitions.rbnew file mode 100644index 00000000000..1a8b073cff1--- /dev/null+++ b/spec/support/pages/admin/settings/project_life_cycle_step_definitions.rb@@ -0,0 +1,95 @@+#-- 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/pages/page"++module Pages+ module Admin+ module Settings+ class ProjectLifeCycleStepDefinitions < ::Pages::Page+ def path = "/admin/settings/project_life_cycle"++ def expect_listed(names)+ page.document.synchronize do+ found = page.all("[data-test-selector=project-life-cycle-step-definition-name]").collect(&:text)++ raise Capybara::ExpectationNotMet, "Expected #{names}, got #{found}" unless found == names+ end+ end++ def expect_no_controls+ within "#content-body" do+ expect(page).to have_no_css(".DragHandle")+ expect(page).to have_no_css("action-menu")+ end+ end++ def expect_no_ordering_controls+ within "#content-body" do+ expect(page).to have_no_css(".DragHandle")+ end+ end++ def filter_with(string)+ fill_in I18n.t("settings.project_life_cycle_step_definitions.filter.label"), with: string+ end++ def clear_filter+ find("button[aria-label=Clear]").click+ end++ def add(name)+ menu = page.find("action-menu", text: "Add")+ menu.click_on("Add")+ menu.click_on(name)+ end++ def click_definition(name)+ page.find("[data-test-selector=project-life-cycle-step-definition-name]", text: name).click_link_or_button+ end++ def click_definition_action(name, action:)+ menu = page+ .find("[data-test-selector=project-life-cycle-step-definition-name]", text: name)+ .ancestor("[data-test-selector=project-life-cycle-step-definition]")+ .find("action-menu")++ menu.click_link_or_button++ menu.click_on(action)+ end++ def select_color(color)+ input = find("label", text: "Color").ancestor(".FormControl").find("input")+ input.fill_in(with: color)+ input.send_keys(:return)+ end+ end+ end+ end+end