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 frontend spec
as-op6bb9b3886b11
diff --git a/app/components/work_packages/types/export_template_list_component.html.erb b/app/components/work_packages/types/export_template_list_component.html.erbindex 25ab0e64d30..75c03fd5e32 100644--- a/app/components/work_packages/types/export_template_list_component.html.erb+++ b/app/components/work_packages/types/export_template_list_component.html.erb@@ -47,7 +47,7 @@ See COPYRIGHT and LICENSE files for more details.font_weight: :bold,color: :subtle,"aria-label": t("projects.settings.actions.label_enable_all"),- data: { "turbo-method": :put, "turbo-stream": true }+ data: { "turbo-method": :put, "turbo-stream": true, test_selector: "enable-all-pdf-export-templates" })) do |button|button.with_leading_visual_icon(icon: "check-circle", color: :subtle)@@ -63,7 +63,7 @@ See COPYRIGHT and LICENSE files for more details.font_weight: :bold,color: :subtle,"aria-label": t("projects.settings.actions.label_disable_all"),- data: { "turbo-method": :put, "turbo-stream": true }+ data: { "turbo-method": :put, "turbo-stream": true, test_selector: "disable-all-pdf-export-templates" })) do |button|button.with_leading_visual_icon(icon: "x-circle", color: :subtle)diff --git a/app/components/work_packages/types/export_template_list_component.rb b/app/components/work_packages/types/export_template_list_component.rbindex 93a26c3ac22..d8c98231e2b 100644--- a/app/components/work_packages/types/export_template_list_component.rb+++ b/app/components/work_packages/types/export_template_list_component.rb@@ -52,7 +52,8 @@ module WorkPackages{"is-drag-and-drop-target": true,"target-container-accessor": "& > ul",- "target-allowed-drag-type": "template"+ "target-allowed-drag-type": "template",+ test_selector: "pdf-export-template-rows"}end@@ -60,7 +61,8 @@ module WorkPackages{"draggable-id": template.id,"draggable-type": "template",- "drop-url": drop_type_pdf_export_template_path(type_id: @type.id, id: template.id)+ "drop-url": drop_type_pdf_export_template_path(type_id: @type.id, id: template.id),+ test_selector: "pdf-export-template-row-#{template.id}"}endenddiff --git a/app/components/work_packages/types/export_template_row_component.html.erb b/app/components/work_packages/types/export_template_row_component.html.erbindex c30f06bdf23..89278f32145 100644--- a/app/components/work_packages/types/export_template_row_component.html.erb+++ b/app/components/work_packages/types/export_template_row_component.html.erb@@ -49,9 +49,10 @@ See COPYRIGHT and LICENSE files for more details.src: toggle_type_pdf_export_template_path(type_id: @type.id, id: @template.id),csrf_token: form_authenticity_token,data: { "turbo-method": :post, "turbo-stream": true },- checked: active_in_type?,+ checked: @template.enabled,size: :small,status_label_position: :start,+ test_selector: "toggle-pdf-export-template-row-#{@template.id}",classes: "op-primer-adjustments__toggle-switch--hidden-loading-indicator"))enddiff --git a/app/components/work_packages/types/export_template_row_component.rb b/app/components/work_packages/types/export_template_row_component.rbindex b99cab5d3ca..07d9a9aaff2 100644--- a/app/components/work_packages/types/export_template_row_component.rb+++ b/app/components/work_packages/types/export_template_row_component.rb@@ -40,12 +40,6 @@ module WorkPackages@template = template@type = typeend-- private-- def active_in_type?- @template.enabled- endendendenddiff --git a/spec/features/types/export_configuration_spec.rb b/spec/features/types/export_configuration_spec.rbnew file mode 100644index 00000000000..143ce920b5d--- /dev/null+++ b/spec/features/types/export_configuration_spec.rb@@ -0,0 +1,98 @@+# 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 "spec_helper"++RSpec.describe "type export configuration tab", :js do+ shared_let(:admin) { create(:admin) }+ let(:type) { create(:type) }++ let!(:project) { create(:project, types: [type]) }++ before do+ login_as(admin)+ visit edit_tab_type_path(id: type.id, tab: "export_configuration")+ end++ def within_pdf_export_template_container(template_id, &)+ within("[data-test-selector='pdf-export-template-row-#{template_id}']", &)+ end++ def toggle_pdf_export_template(template_id)+ page+ .find("[data-test-selector='toggle-pdf-export-template-row-#{template_id}'] > button")+ .click+ end++ def expect_checked_state+ expect(page).to have_css(".ToggleSwitch-statusOn")+ end++ def expect_unchecked_state+ expect(page).to have_css(".ToggleSwitch-statusOff")+ end++ it "disables/enables all" do+ page.find("[data-test-selector='disable-all-pdf-export-templates']").click+ type.reload+ expect(type.pdf_export_templates.list_enabled.length).to eq(0)+ page.find("[data-test-selector='enable-all-pdf-export-templates']").click+ type.reload+ expect(type.pdf_export_templates.list_enabled.length).to eq(type.pdf_export_templates.list.length)+ end++ it "disables/enables one" do+ first = type.pdf_export_templates.list_enabled.first+ within_pdf_export_template_container(first.id) do+ expect_checked_state+ toggle_pdf_export_template(first.id)+ expect_unchecked_state+ type.reload+ expect(type.pdf_export_templates.list.first.enabled).to be(false)+ toggle_pdf_export_template(first.id)+ expect_checked_state+ type.reload+ expect(type.pdf_export_templates.list.first.enabled).to be(true)+ end+ end++ it "reorders by drag and drop" do+ first_id = type.pdf_export_templates.list_enabled.first.id+ second_id = type.pdf_export_templates.list_enabled[1].id+ source = page.find("[data-test-selector='pdf-export-template-row-#{first_id}'] .DragHandle")+ target = page.find("[data-test-selector='pdf-export-template-row-#{second_id}'] .DragHandle")+ source.native.drag_to(target.native, delay: 0.1)+ sleep 1++ type.reload+ expect(type.pdf_export_templates.list[1].id).to eq(first_id)+ expect(type.pdf_export_templates.list.first.id).to eq(second_id)+ end+end