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

added missing validation specs

Jonas Jabari5c5aae175d11
diff --git a/spec/features/projects/project_custom_fields/overview_page/dialog/validation_spec.rb b/spec/features/projects/project_custom_fields/overview_page/dialog/validation_spec.rb
index c4d20d686bb..55726a53539 100644
--- a/spec/features/projects/project_custom_fields/overview_page/dialog/validation_spec.rb
+++ b/spec/features/projects/project_custom_fields/overview_page/dialog/validation_spec.rb
@@ -247,5 +247,83 @@ RSpec.describe 'Edit project custom fields on project overview page', :js do
end
end
end
+
+ describe 'with select fields' do
+ let(:section) { section_for_select_fields }
+ let(:dialog) { Components::Projects::ProjectCustomFields::EditDialog.new(project, section) }
+
+ shared_examples 'a custom field select' do
+ it 'shows an error if the value is invalid' do
+ custom_field.update!(is_required: true)
+ custom_field.custom_values.destroy_all
+
+ overview_page.open_edit_dialog_for_section(section)
+
+ dialog.submit
+
+ field.expect_error(I18n.t('activerecord.errors.messages.blank'))
+ end
+ end
+
+ describe 'with list CF' do
+ let(:custom_field) { list_project_custom_field }
+ let(:field) { FormFields::Primerized::AutocompleteField.new(custom_field) }
+
+ it_behaves_like 'a custom field select'
+ end
+
+ describe 'with version CF' do
+ let(:custom_field) { version_project_custom_field }
+ let(:field) { FormFields::Primerized::AutocompleteField.new(custom_field) }
+
+ it_behaves_like 'a custom field select'
+ end
+
+ describe 'with user CF' do
+ let(:custom_field) { user_project_custom_field }
+ let(:field) { FormFields::Primerized::AutocompleteField.new(custom_field) }
+
+ it_behaves_like 'a custom field select'
+ end
+ end
+
+ describe 'with multi select fields' do
+ let(:section) { section_for_multi_select_fields }
+ let(:dialog) { Components::Projects::ProjectCustomFields::EditDialog.new(project, section) }
+
+ shared_examples 'a custom field multi select' do
+ it 'shows an error if the value is invalid' do
+ custom_field.update!(is_required: true)
+ custom_field.custom_values.destroy_all
+
+ overview_page.open_edit_dialog_for_section(section)
+
+ dialog.submit
+
+ field.expect_error(I18n.t('activerecord.errors.messages.blank'))
+ end
+ end
+
+ describe 'with multi list CF' do
+ let(:custom_field) { multi_list_project_custom_field }
+ let(:field) { FormFields::Primerized::AutocompleteField.new(custom_field) }
+
+ it_behaves_like 'a custom field multi select'
+ end
+
+ describe 'with multi version CF' do
+ let(:custom_field) { multi_version_project_custom_field }
+ let(:field) { FormFields::Primerized::AutocompleteField.new(custom_field) }
+
+ it_behaves_like 'a custom field multi select'
+ end
+
+ describe 'with multi user CF' do
+ let(:custom_field) { multi_user_project_custom_field }
+ let(:field) { FormFields::Primerized::AutocompleteField.new(custom_field) }
+
+ it_behaves_like 'a custom field multi select'
+ end
+ end
end
end
diff --git a/spec/support/form_fields/primerized/autocomplete_field.rb b/spec/support/form_fields/primerized/autocomplete_field.rb
index 4873ebf5b11..fb1d325310d 100644
--- a/spec/support/form_fields/primerized/autocomplete_field.rb
+++ b/spec/support/form_fields/primerized/autocomplete_field.rb
@@ -63,6 +63,11 @@ module FormFields
def expect_visible
expect(field_container).to have_css('ng-select')
end
+
+ def expect_error(string = nil)
+ expect(field_container).to have_css('.FormControl-inlineValidation')
+ expect(field_container).to have_content(string) if string
+ end
end
end
end