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] Update project list spec for error dialog

Tobias Dillmann1c49828f7c44
diff --git a/app/components/projects/row_component.rb b/app/components/projects/row_component.rb
index c6b26ca50cd..29a0f20a607 100644
--- a/app/components/projects/row_component.rb
+++ b/app/components/projects/row_component.rb
@@ -97,9 +97,11 @@ module Projects
errors = cf.calculated_value_errors.where(project:)
if errors.any?
- render(Primer::Alpha::Dialog.new(title: I18n.t("calculated_values.error_dialog.title"))) do |dialog|
+ render(Primer::Alpha::Dialog.new(title: I18n.t("calculated_values.error_dialog.title"),
+ data: { test_selector: "calculated-value-error-dialog-#{cf.id}" })) do |dialog|
dialog.with_show_button(icon: "alert-fill",
"aria-label": I18n.t("calculated_values.error_dialog.title"),
+ data: { test_selector: "calculated-value-error-btn-#{cf.id}" },
scheme: :invisible)
dialog.with_body { errors.map(&:error_message).join(" ") }
end
diff --git a/spec/features/projects/lists/columns_spec.rb b/spec/features/projects/lists/columns_spec.rb
index f1c5bbd500d..8f11a4dd791 100644
--- a/spec/features/projects/lists/columns_spec.rb
+++ b/spec/features/projects/lists/columns_spec.rb
@@ -439,19 +439,22 @@ RSpec.describe "Projects lists columns", :js, with_settings: { login_required?:
end
context "when there is a calculation error" do
+ let!(:integer_custom_field) { create(:integer_project_custom_field) }
let!(:division_by_zero_calculated_value) do
create(:calculated_value_project_custom_field,
name: "Calculated value error field",
- formula: "6 / 0",
+ formula: "6 / {{cf_#{integer_custom_field.id}}}",
projects: [project])
end
before do
login_as(admin)
- project.calculate_custom_fields([division_by_zero_calculated_value])
+ project.custom_field_values = { integer_custom_field.id => 0 }
project.save!
+ project.calculate_custom_fields([division_by_zero_calculated_value])
+
projects_page.visit!
end
@@ -461,9 +464,14 @@ RSpec.describe "Projects lists columns", :js, with_settings: { login_required?:
projects_page.within_row(project) do
expect(page)
.to have_css(".name", text: project.name)
- expect(page)
- .to have_css(".cf_#{division_by_zero_calculated_value.id}", text: I18n.t("calculated_values.errors.mathematical"))
+
+ error_button = page.find_test_selector("calculated-value-error-btn-#{division_by_zero_calculated_value.id}")
+ expect(error_button).to be_present
+ error_button.click
end
+
+ expect(page).to have_test_selector("calculated-value-error-dialog-#{division_by_zero_calculated_value.id}",
+ text: I18n.t("calculated_values.errors.mathematical"))
end
end
end