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
adding more specs for project custom fields on overview page
Jonas Jabari8a6068f5b893
diff --git a/modules/overviews/app/components/project_custom_fields/sections/edit_dialog_component.html.erb b/modules/overviews/app/components/project_custom_fields/sections/edit_dialog_component.html.erbindex 93ab06ee19c..a2e06e95b84 100644--- a/modules/overviews/app/components/project_custom_fields/sections/edit_dialog_component.html.erb+++ b/modules/overviews/app/components/project_custom_fields/sections/edit_dialog_component.html.erb@@ -11,22 +11,22 @@collection.with_component(Primer::Alpha::Dialog::Body.new(style: "max-height: 500px;")) doflex_layout(my: 3) do |flex|@active_project_custom_fields_of_section.each do |project_custom_field|- flex.with_row(mb: 2) do+ flex.with_row(mb: 2, classes: 'op-project-custom-field-input-container', data: { qa_selector: "project-custom-field-input-container-#{project_custom_field.id}" }) dorender_custom_field_value_input(f, project_custom_field, project_custom_field_values_for(project_custom_field.id))endendendendcollection.with_component(Primer::Alpha::Dialog::Footer.new) do- component_collection do |collection1|- collection1.with_component(Primer::ButtonComponent.new(+ component_collection do |footer_collection|+ footer_collection.with_component(Primer::ButtonComponent.new(data: {'close-dialog-id': "edit-project-attributes-dialog-#{@project_custom_field_section.id}"})) dot("button_cancel")end- collection1.with_component(Primer::ButtonComponent.new(scheme: :primary, type: :submit)) do+ footer_collection.with_component(Primer::ButtonComponent.new(scheme: :primary, type: :submit)) dot("button_save")endenddiff --git a/spec/features/projects/project_custom_fields/overview_page/edit_spec.rb b/spec/features/projects/project_custom_fields/overview_page/edit_spec.rbindex 1fbfd6d796b..414424a812d 100644--- a/spec/features/projects/project_custom_fields/overview_page/edit_spec.rb+++ b/spec/features/projects/project_custom_fields/overview_page/edit_spec.rb@@ -45,13 +45,117 @@ RSpec.describe 'Edit project custom fields on project overview page', :js, :withit 'opens a dialog showing inputs for project custom fields of a specific section' dooverview_page.visit_page- overview_page.within_async_loaded_sidebar do- overview_page.within_custom_field_section_container(section_for_input_fields) do- page.find("[data-qa-selector='project-custom-field-section-edit-button']").click+ overview_page.open_edit_dialog_for_section(section_for_input_fields)++ expect(page).to have_css("modal-dialog#edit-project-attributes-dialog-#{section_for_input_fields.id}")+ end++ it 'renders the dialog body asynchronically' do+ overview_page.visit_page++ expect(page).to have_no_css('#project-custom-fields-sections-edit-dialog-component', visible: :all)++ overview_page.open_edit_dialog_for_section(section_for_input_fields)++ expect(page).to have_css('#project-custom-fields-sections-edit-dialog-component', visible: :visible)+ end++ it 'can be closed via close icon or cancel button' do+ overview_page.visit_page++ overview_page.open_edit_dialog_for_section(section_for_input_fields)++ within("modal-dialog#edit-project-attributes-dialog-#{section_for_input_fields.id}") do+ page.find(".close-button").click+ end++ expect(page).to have_no_css("modal-dialog#edit-project-attributes-dialog-#{section_for_input_fields.id}")++ overview_page.open_edit_dialog_for_section(section_for_input_fields)++ within("modal-dialog#edit-project-attributes-dialog-#{section_for_input_fields.id}") do+ click_link_or_button 'Cancel'+ end++ expect(page).to have_no_css("modal-dialog#edit-project-attributes-dialog-#{section_for_input_fields.id}")+ end++ it 'shows only the project custom fields of the specific section within the dialog' do+ overview_page.visit_page++ overview_page.open_edit_dialog_for_section(section_for_input_fields)++ overview_page.within_edit_dialog_for_section(section_for_input_fields) do+ (input_fields + select_fields + multi_select_fields).each do |project_custom_field|+ if input_fields.include?(project_custom_field)+ expect(page).to have_content(project_custom_field.name)+ else+ expect(page).to have_no_content(project_custom_field.name)+ endendend- expect(page).to have_css("modal-dialog#edit-project-attributes-dialog-#{section_for_input_fields.id}")+ overview_page.close_edit_dialog_for_section(section_for_input_fields)++ overview_page.open_edit_dialog_for_section(section_for_select_fields)++ overview_page.within_edit_dialog_for_section(section_for_select_fields) do+ (input_fields + select_fields + multi_select_fields).each do |project_custom_field|+ if select_fields.include?(project_custom_field)+ expect(page).to have_content(project_custom_field.name)+ else+ expect(page).to have_no_content(project_custom_field.name)+ end+ end+ end++ overview_page.close_edit_dialog_for_section(section_for_select_fields)++ overview_page.open_edit_dialog_for_section(section_for_multi_select_fields)++ overview_page.within_edit_dialog_for_section(section_for_multi_select_fields) do+ (input_fields + select_fields + multi_select_fields).each do |project_custom_field|+ if multi_select_fields.include?(project_custom_field)+ expect(page).to have_content(project_custom_field.name)+ else+ expect(page).to have_no_content(project_custom_field.name)+ end+ end+ end+ end++ it 'shows the inputs in the correct order defined by the position of project custom field in a section' do+ overview_page.visit_page++ overview_page.open_edit_dialog_for_section(section_for_input_fields)++ overview_page.within_edit_dialog_for_section(section_for_input_fields) do+ fields = page.all('.op-project-custom-field-input-container')++ expect(fields[0].text).to include('Boolean field')+ expect(fields[1].text).to include('String field')+ expect(fields[2].text).to include('Integer field')+ expect(fields[3].text).to include('Float field')+ expect(fields[4].text).to include('Date field')+ expect(fields[5].text).to include('Text field')+ end++ overview_page.close_edit_dialog_for_section(section_for_input_fields)++ boolean_project_custom_field.move_to_bottom++ overview_page.open_edit_dialog_for_section(section_for_input_fields)++ overview_page.within_edit_dialog_for_section(section_for_input_fields) do+ fields = page.all('.op-project-custom-field-input-container')++ expect(fields[0].text).to include('String field')+ expect(fields[1].text).to include('Integer field')+ expect(fields[2].text).to include('Float field')+ expect(fields[3].text).to include('Date field')+ expect(fields[4].text).to include('Text field')+ expect(fields[5].text).to include('Boolean field')+ endendendenddiff --git a/spec/features/projects/project_custom_fields/overview_page/overview_page.rb b/spec/features/projects/project_custom_fields/overview_page/overview_page.rbindex d023fd74b2c..85b3aa23f8c 100644--- a/spec/features/projects/project_custom_fields/overview_page/overview_page.rb+++ b/spec/features/projects/project_custom_fields/overview_page/overview_page.rb@@ -53,4 +53,22 @@ class OverviewPagedef within_custom_field_container(custom_field, &)within("[data-qa-selector='project-custom-field-#{custom_field.id}']", &)end++ def open_edit_dialog_for_section(section)+ within_async_loaded_sidebar do+ within_custom_field_section_container(section) do+ page.find("[data-qa-selector='project-custom-field-section-edit-button']").click+ end+ end+ end++ def close_edit_dialog_for_section(section)+ within("modal-dialog#edit-project-attributes-dialog-#{section.id}") do+ page.find(".close-button").click+ end+ end++ def within_edit_dialog_for_section(section, &)+ within("modal-dialog#edit-project-attributes-dialog-#{section.id}", &)+ endenddiff --git a/spec/features/projects/project_custom_fields/overview_page/shared_context.rb b/spec/features/projects/project_custom_fields/overview_page/shared_context.rbindex 9053b5b014b..0033eefa9cb 100644--- a/spec/features/projects/project_custom_fields/overview_page/shared_context.rb+++ b/spec/features/projects/project_custom_fields/overview_page/shared_context.rb@@ -174,4 +174,31 @@ RSpec.shared_context 'with seeded projects, members and project custom fields' dfieldend++ let!(:input_fields) do+ [+ boolean_project_custom_field,+ string_project_custom_field,+ integer_project_custom_field,+ float_project_custom_field,+ date_project_custom_field,+ text_project_custom_field+ ]+ end++ let!(:select_fields) do+ [+ list_project_custom_field,+ version_project_custom_field,+ user_project_custom_field+ ]+ end++ let!(:multi_select_fields) do+ [+ multi_list_project_custom_field,+ multi_version_project_custom_field,+ multi_user_project_custom_field+ ]+ endenddiff --git a/spec/features/projects/project_custom_fields/overview_page/show_spec.rb b/spec/features/projects/project_custom_fields/overview_page/show_spec.rbindex f41ab4d3ded..3895e3048f7 100644--- a/spec/features/projects/project_custom_fields/overview_page/show_spec.rb+++ b/spec/features/projects/project_custom_fields/overview_page/show_spec.rb@@ -44,7 +44,7 @@ RSpec.describe 'Show project custom fields on project overview page', :js, :withoverview_page.visit_pagewithin '.op-grid-page' do- expect(page).not_to have_css('#project-attributes-sidebar')+ expect(page).to have_no_css('#project-attributes-sidebar')endendend@@ -100,7 +100,7 @@ RSpec.describe 'Show project custom fields on project overview page', :js, :withoverview_page.visit_pageoverview_page.within_async_loaded_sidebar do- expect(page).not_to have_text 'String field enabled for other project'+ expect(page).to have_no_text 'String field enabled for other project'endendend