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 feature spec for enabling/disabling calculated value fields
Ivan Kuchine6361d7ffb25
diff --git a/spec/features/projects/project_custom_fields/settings/mapping_spec.rb b/spec/features/projects/project_custom_fields/settings/mapping_spec.rbindex fd64f6acc1f..8d99a46f946 100644--- a/spec/features/projects/project_custom_fields/settings/mapping_spec.rb+++ b/spec/features/projects/project_custom_fields/settings/mapping_spec.rb@@ -405,6 +405,95 @@ RSpec.describe "Projects custom fields mapping via project settings", :js doendendend++ describe "calculated value fields", with_flag: { calculated_value_project_attribute: true } do+ let!(:admin) do+ create(:admin)+ end++ let!(:section_with_calculated_fields) { create(:project_custom_field_section, name: "Section with calculated fields") }++ let!(:calculated_field1) do+ create(:calculated_value_project_custom_field,+ name: "Calculated field 1",+ formula: "123 + 456",+ project_custom_field_section: section_with_calculated_fields)+ end++ let!(:calculated_field2) do+ create(:calculated_value_project_custom_field,+ name: "Calculated field 2",+ formula: "6 * 7",+ project_custom_field_section: section_with_calculated_fields)+ end++ let(:overview_page) { Pages::Projects::Show.new(project) }++ before do+ login_as admin+ end++ it "calculates field when switched individually" do+ visit project_settings_project_custom_fields_path(project)++ page+ .find("[data-test-selector='toggle-project-custom-field-mapping-#{calculated_field1.id}'] > button")+ .click++ overview_page.visit_page++ overview_page.within_custom_field_container(calculated_field1) do+ expect(page).to have_text "Calculated field 1"+ expect(page).to have_text "579"+ end+ overview_page.expect_no_custom_field(calculated_field2)++ visit project_settings_project_custom_fields_path(project)++ page+ .find("[data-test-selector='toggle-project-custom-field-mapping-#{calculated_field1.id}'] > button")+ .click++ overview_page.visit_page++ overview_page.expect_no_custom_field(calculated_field1)+ overview_page.expect_no_custom_field(calculated_field2)+ end++ it "calculates fields when switched in bulk" do+ visit project_settings_project_custom_fields_path(project)++ within_custom_field_section_container(section_with_calculated_fields) do+ page+ .find("[data-test-selector='enable-all-project-custom-field-mappings-#{section_with_calculated_fields.id}']")+ .click+ end++ overview_page.visit_page++ overview_page.within_custom_field_container(calculated_field1) do+ expect(page).to have_text "Calculated field 1"+ expect(page).to have_text "579"+ end+ overview_page.within_custom_field_container(calculated_field2) do+ expect(page).to have_text "Calculated field 2"+ expect(page).to have_text "42"+ end++ visit project_settings_project_custom_fields_path(project)++ within_custom_field_section_container(section_with_calculated_fields) do+ page+ .find("[data-test-selector='disable-all-project-custom-field-mappings-#{section_with_calculated_fields.id}']")+ .click+ end++ overview_page.visit_page++ overview_page.expect_no_custom_field(calculated_field1)+ overview_page.expect_no_custom_field(calculated_field2)+ end+ endenddef expect_type(type)