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

Add option grouping expectation to the Project custom fields dialog spec

Dombi Attila4348dc9e95e4
diff --git a/spec/features/projects/project_custom_fields/overview_page/dialog/inputs_spec.rb b/spec/features/projects/project_custom_fields/overview_page/dialog/inputs_spec.rb
index 9a9efb27ebb..8edfa4455cd 100644
--- a/spec/features/projects/project_custom_fields/overview_page/dialog/inputs_spec.rb
+++ b/spec/features/projects/project_custom_fields/overview_page/dialog/inputs_spec.rb
@@ -318,8 +318,7 @@ RSpec.describe "Edit project custom fields on project overview page", :js do
overview_page.open_edit_dialog_for_section(section)
field.search("Version 1")
-
- field.expect_option(first_version.name)
+ field.expect_option(first_version.name, grouping: project.name)
field.expect_no_option(version_in_other_project.name)
end
end
@@ -549,7 +548,7 @@ RSpec.describe "Edit project custom fields on project overview page", :js do
field.search("Version 1")
- field.expect_option(first_version.name)
+ field.expect_option(first_version.name, grouping: project.name)
field.expect_no_option(version_in_other_project.name)
end
end
diff --git a/spec/support/form_fields/primerized/autocomplete_field.rb b/spec/support/form_fields/primerized/autocomplete_field.rb
index f77ad03a098..eae6e58e13b 100644
--- a/spec/support/form_fields/primerized/autocomplete_field.rb
+++ b/spec/support/form_fields/primerized/autocomplete_field.rb
@@ -77,9 +77,16 @@ module FormFields
.to have_no_css(".ng-option", text: option, visible: :all, wait: 1)
end
- def expect_option(option)
- expect(page)
- .to have_css(".ng-option", text: option, visible: :visible)
+ def expect_option(option, grouping: nil)
+ if grouping
+ # Make sure the option is displayed under correct grouping title.
+ option_group = find(".ng-optgroup", text: grouping)
+ option = find(".ng-option.ng-option-child", text: option, visible: :visible)
+ expect(option_group).to eq option.find(:xpath, "preceding-sibling::*[1]")
+ else
+ expect(page)
+ .to have_css(".ng-option", text: option, visible: :visible)
+ end
end
def expect_visible