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
move pattern input spec to file for all calculated value specs
Ivan Kuchina4b4ae6e308f
diff --git a/spec/features/admin/custom_fields/projects/calculated_value_spec.rb b/spec/features/admin/custom_fields/projects/calculated_value_spec.rbindex a9a4fc71dd1..11f83cde5d3 100644--- a/spec/features/admin/custom_fields/projects/calculated_value_spec.rb+++ b/spec/features/admin/custom_fields/projects/calculated_value_spec.rb@@ -34,12 +34,7 @@ require_relative "shared_context"RSpec.describe "Edit project custom field calculated value", :js, with_flag: { calculated_value_project_attribute: true } doinclude_context "with seeded project custom fields"- let!(:calculated_value) do- create(:calculated_value_project_custom_field,- name: "Calculated value field",- formula: "42 + 1",- project_custom_field_section: section_for_input_fields)- end+ let(:calculated_value) { calculated_from_int_project_custom_field }context "with insufficient permissions" doit "is not accessible" do@@ -135,6 +130,38 @@ RSpec.describe "Edit project custom field calculated value", :js, with_flag: { cexpect(calculated_value.reload.formula_string).to eq(formula)end++ context "when editing the formula" do+ using CustomFieldFormulaReferencing++ it "allows using the pattern input component" do+ expect(page).to have_css(".PageHeader-title", text: calculated_value.name)++ expect(page).to have_css("input#custom_field_formula[value='#{integer_project_custom_field} * 2']",+ visible: :hidden)++ # Suggestions drop down is hidden+ expect(page).to have_no_css(".op-pattern-input--suggestions-dropdown .ActionListItem")++ pattern_input = page.find(".op-pattern-input--text-field")+ pattern_input.click+ pattern_input.send_keys(" + ")+ expect(page).to have_no_css(".op-pattern-input--suggestions-dropdown .ActionListItem")++ # Open suggestion list+ pattern_input.send_keys("/")+ within ".op-pattern-input--suggestions-dropdown" do+ expect(page).to have_css(".ActionListItem", text: float_project_custom_field.name)+ click_on(float_project_custom_field.name)+ end++ click_on("Save")+ wait_for_network_idle++ new_formula = calculated_value.reload.formula_string+ expect(new_formula).to eq("#{integer_project_custom_field} * 2 + #{float_project_custom_field}")+ end+ endendcontext "without the feature flag", with_flag: { calculated_value_project_attribute: false } dodiff --git a/spec/features/admin/custom_fields/projects/edit_spec.rb b/spec/features/admin/custom_fields/projects/edit_spec.rbindex 25f7efd2b67..f1fee9d9bc2 100644--- a/spec/features/admin/custom_fields/projects/edit_spec.rb+++ b/spec/features/admin/custom_fields/projects/edit_spec.rb@@ -102,50 +102,5 @@ RSpec.describe "Edit project custom fields", :js doexpect(page).to have_css(".PageHeader-title", text: original_name)expect(boolean_project_custom_field.reload.name).to eq(original_name)end-- context "when editing a calculated value" do- using CustomFieldFormulaReferencing-- let!(:calculated_from_int_project_custom_field) do- create(- :calculated_value_project_custom_field,- :skip_validations,- name: "Calculated field using int",- formula: "#{integer_project_custom_field} * 2",- project_custom_field_section: section_for_input_fields- )- end-- before do- login_as(admin)- visit edit_admin_settings_project_custom_field_path(calculated_from_int_project_custom_field)- end-- it "allows editing the formula via pattern input component" do- expect(page).to have_css(".PageHeader-title", text: calculated_from_int_project_custom_field.name)-- expect(page).to have_css("input#custom_field_formula[value='#{integer_project_custom_field} * 2']",- visible: :hidden)-- # Suggestions drop down is hidden- expect(page).to have_no_css(".op-pattern-input--suggestions-dropdown .ActionListItem")-- pattern_input = page.find(".op-pattern-input--text-field")- pattern_input.click- pattern_input.send_keys(" + ")- expect(page).to have_no_css(".op-pattern-input--suggestions-dropdown .ActionListItem")-- # Open suggestion list- pattern_input.send_keys("/")- within ".op-pattern-input--suggestions-dropdown" do- expect(page).to have_css(".ActionListItem", text: float_project_custom_field.name)- click_on(float_project_custom_field.name)- end-- click_on("Save")- new_formula = calculated_from_int_project_custom_field.reload.formula_string- expect(new_formula).to eq("#{integer_project_custom_field} * 2 + #{float_project_custom_field}")- end- endendend