Skip to content

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

[#66093] Feature spec for adding/removing errors due to user input

Tobias Dillmanneb7924cd5b5c
diff --git a/spec/features/projects/project_custom_fields/overview_page/sidebar_spec.rb b/spec/features/projects/project_custom_fields/overview_page/sidebar_spec.rb
index 0dff5fb910f..08e05476932 100644
--- a/spec/features/projects/project_custom_fields/overview_page/sidebar_spec.rb
+++ b/spec/features/projects/project_custom_fields/overview_page/sidebar_spec.rb
@@ -658,6 +658,48 @@ RSpec.describe "Show project custom fields on project overview page", :js do
end
end
end
+
+ describe "with errors caused by user input" do
+ it "updates calculated values, creating and removing errors as needed" do
+ overview_page.visit_page
+
+ # Remove value that is used in a formula:
+ overview_page.open_edit_dialog_for_section(section_for_input_fields)
+ page.fill_in(float_project_custom_field.name, with: "")
+ page.click_on "Save"
+
+ overview_page.within_project_attributes_sidebar do
+ overview_page.within_custom_field_container(calculated_from_int_project_custom_field) do
+ expect(page).to have_text "Calculated field using int"
+ expect(page).to have_text "234"
+ end
+
+ overview_page.within_custom_field_container(calculated_from_int_and_float_project_custom_field) do
+ expect(page).to have_text "Calculated field using int and float"
+ expect(page).to have_text I18n.t("calculated_values.errors.missing_value",
+ custom_field_name: float_project_custom_field.name)
+ end
+ end
+
+ # Change the value so that the calculation succeeds.
+ overview_page.open_edit_dialog_for_section(section_for_input_fields)
+ page.fill_in(float_project_custom_field.name, with: "0.2")
+ page.click_on "Save"
+
+ overview_page.within_project_attributes_sidebar do
+ overview_page.within_custom_field_container(calculated_from_int_project_custom_field) do
+ expect(page).to have_text "Calculated field using int"
+ expect(page).to have_text "234"
+ end
+
+ # The error is gone:
+ overview_page.within_custom_field_container(calculated_from_int_and_float_project_custom_field) do
+ expect(page).to have_text "Calculated field using int and float"
+ expect(page).to have_text "24.6"
+ end
+ end
+ end
+ end
end
describe "with list CF" do