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
introducing capybara specs for overview and project settings page
Jonas Jabarie7922b70ea87
diff --git a/spec/factories/custom_field_factory.rb b/spec/factories/custom_field_factory.rbindex 44c88e2c787..6913ce7b4bb 100644--- a/spec/factories/custom_field_factory.rb+++ b/spec/factories/custom_field_factory.rb@@ -158,6 +158,22 @@ FactoryBot.define doendfactory :project_custom_field, class: 'ProjectCustomField' do+ project_custom_field_section++ transient do+ projects { [] }+ end++ # enable the the custom_field for the given projects+ after(:create) do |custom_field, evaluator|+ projects = Array(evaluator.projects)+ next if projects.blank?++ projects.each do |project|+ create(:project_custom_field_project_mapping, project:, project_custom_field: custom_field)+ end+ end+factory :boolean_project_custom_field, traits: [:boolean]factory :string_project_custom_field, traits: [:string]factory :text_project_custom_field, traits: [:text]diff --git a/spec/factories/custom_field_section.rb b/spec/factories/custom_field_section.rbnew file mode 100644index 00000000000..861b2f049d1--- /dev/null+++ b/spec/factories/custom_field_section.rb@@ -0,0 +1,37 @@+#-- copyright+# OpenProject is an open source project management software.+# Copyright (C) 2012-2023 the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# This program is distributed in the hope that it will be useful,+# but WITHOUT ANY WARRANTY; without even the implied warranty of+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+# GNU General Public License for more details.+#+# You should have received a copy of the GNU General Public License+# along with this program; if not, write to the Free Software+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.+#+# See COPYRIGHT and LICENSE files for more details.+#++++FactoryBot.define do+ factory :custom_field_section do+ sequence(:name) { |n| "Section No. #{n}" }+ created_at { Time.zone.now }+ updated_at { Time.zone.now }++ factory :project_custom_field_section, class: 'ProjectCustomFieldSection'+ end+enddiff --git a/spec/factories/project_custom_field_project_mapping.rb b/spec/factories/project_custom_field_project_mapping.rbnew file mode 100644index 00000000000..4564b7668d2--- /dev/null+++ b/spec/factories/project_custom_field_project_mapping.rb@@ -0,0 +1,34 @@+#-- copyright+# OpenProject is an open source project management software.+# Copyright (C) 2012-2023 the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# This program is distributed in the hope that it will be useful,+# but WITHOUT ANY WARRANTY; without even the implied warranty of+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+# GNU General Public License for more details.+#+# You should have received a copy of the GNU General Public License+# along with this program; if not, write to the Free Software+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.+#+# See COPYRIGHT and LICENSE files for more details.+#++++FactoryBot.define do+ factory :project_custom_field_project_mapping do+ project_custom_field+ project+ end+enddiff --git a/spec/features/projects/project_custom_fields/overview_page/edit_spec.rb b/spec/features/projects/project_custom_fields/overview_page/edit_spec.rbnew file mode 100644index 00000000000..1fbfd6d796b--- /dev/null+++ b/spec/features/projects/project_custom_fields/overview_page/edit_spec.rb@@ -0,0 +1,59 @@+#-- copyright+# OpenProject is an open source project management software.+# Copyright (C) 2012-2023 the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# This program is distributed in the hope that it will be useful,+# but WITHOUT ANY WARRANTY; without even the implied warranty of+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+# GNU General Public License for more details.+#+# You should have received a copy of the GNU General Public License+# along with this program; if not, write to the Free Software+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.+#+# See COPYRIGHT and LICENSE files for more details.+#++++require 'spec_helper'+require_relative 'shared_context'+require_relative 'overview_page'++RSpec.describe 'Edit project custom fields on project overview page', :js, :with_cuprite do+ include_context 'with seeded projects, members and project custom fields'++ let(:overview_page) { OverviewPage.new(project) }++ before do+ login_as admin+ end++ describe 'with enabled project attributes feature', with_flag: { project_attributes: true } do+ describe 'with sufficient permissions' do+ describe 'enables editing of project custom field values via dialog' do+ it 'opens a dialog showing inputs for project custom fields of a specific section' do+ overview_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+ end+ end++ expect(page).to have_css("modal-dialog#edit-project-attributes-dialog-#{section_for_input_fields.id}")+ end+ end+ end+ end+enddiff --git a/spec/features/projects/project_custom_fields/overview_page/overview_page.rb b/spec/features/projects/project_custom_fields/overview_page/overview_page.rbnew file mode 100644index 00000000000..d023fd74b2c--- /dev/null+++ b/spec/features/projects/project_custom_fields/overview_page/overview_page.rb@@ -0,0 +1,56 @@+#-- copyright+# OpenProject is an open source project management software.+# Copyright (C) 2012-2023 the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# This program is distributed in the hope that it will be useful,+# but WITHOUT ANY WARRANTY; without even the implied warranty of+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+# GNU General Public License for more details.+#+# You should have received a copy of the GNU General Public License+# along with this program; if not, write to the Free Software+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.+#+# See COPYRIGHT and LICENSE files for more details.+#+++class OverviewPage+ include Rails.application.routes.url_helpers+ include Capybara::DSL+ include Capybara::RSpecMatchers+ include RSpec::Matchers++ def initialize(project)+ @project = project+ end++ def visit_page+ visit project_path(@project.id)+ end++ def within_async_loaded_sidebar+ within '#project-attributes-sidebar' do+ expect(page).to have_css("[data-qa-selector='project-attributes-sidebar-async-content']")+ yield+ end+ end++ def within_custom_field_section_container(section, &)+ within("[data-qa-selector='project-custom-field-section-#{section.id}']", &)+ end++ def within_custom_field_container(custom_field, &)+ within("[data-qa-selector='project-custom-field-#{custom_field.id}']", &)+ end+enddiff --git a/spec/features/projects/project_custom_fields/overview_page/shared_context.rb b/spec/features/projects/project_custom_fields/overview_page/shared_context.rbnew file mode 100644index 00000000000..9053b5b014b--- /dev/null+++ b/spec/features/projects/project_custom_fields/overview_page/shared_context.rb@@ -0,0 +1,177 @@+#-- copyright+# OpenProject is an open source project management software.+# Copyright (C) 2012-2023 the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# This program is distributed in the hope that it will be useful,+# but WITHOUT ANY WARRANTY; without even the implied warranty of+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+# GNU General Public License for more details.+#+# You should have received a copy of the GNU General Public License+# along with this program; if not, write to the Free Software+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.+#+# See COPYRIGHT and LICENSE files for more details.+#++++RSpec.shared_context 'with seeded projects, members and project custom fields' do+ let(:project) { create(:project, name: 'Foo project', identifier: 'foo-project') }+ let(:other_project) { create(:project, name: 'Bar project', identifier: 'bar-project') }++ let(:first_version) { create(:version, name: 'Version 1', project:) }+ let(:second_version) { create(:version, name: 'Version 2', project:) }++ let!(:admin) do+ create(:admin)+ end++ let!(:member_in_project) do+ create(:user,+ firstname: 'Member 1',+ lastname: 'In Project',+ member_with_permissions: { project => %w[+ view_work_packages+ ] })+ end++ let!(:another_member_in_project) do+ create(:user,+ firstname: 'Member 2',+ lastname: 'In Project',+ member_with_permissions: { project => %w[+ view_work_packages+ ] })+ end++ let!(:section_for_input_fields) { create(:project_custom_field_section, name: 'Input fields') }+ let!(:section_for_select_fields) { create(:project_custom_field_section, name: 'Select fields') }+ let!(:section_for_multi_select_fields) { create(:project_custom_field_section, name: 'Multi select fields') }++ let!(:boolean_project_custom_field) do+ field = create(:boolean_project_custom_field, projects: [project], name: 'Boolean field',+ project_custom_field_section: section_for_input_fields)++ create(:custom_value, customized: project, custom_field: field, value: true)++ field+ end++ let!(:string_project_custom_field) do+ field = create(:string_project_custom_field, projects: [project], name: 'String field',+ project_custom_field_section: section_for_input_fields)++ create(:custom_value, customized: project, custom_field: field, value: 'Foo')++ field+ end++ let!(:integer_project_custom_field) do+ field = create(:integer_project_custom_field, projects: [project], name: 'Integer field',+ project_custom_field_section: section_for_input_fields)++ create(:custom_value, customized: project, custom_field: field, value: 123)++ field+ end++ let!(:float_project_custom_field) do+ field = create(:float_project_custom_field, projects: [project], name: 'Float field',+ project_custom_field_section: section_for_input_fields)++ create(:custom_value, customized: project, custom_field: field, value: 123.456)++ field+ end++ let!(:date_project_custom_field) do+ field = create(:date_project_custom_field, projects: [project], name: 'Date field',+ project_custom_field_section: section_for_input_fields)++ create(:custom_value, customized: project, custom_field: field, value: Date.new(2024, 1, 1))++ field+ end++ let!(:text_project_custom_field) do+ field = create(:text_project_custom_field, projects: [project], name: 'Text field',+ project_custom_field_section: section_for_input_fields)++ create(:custom_value, customized: project, custom_field: field, value: "Lorem\nipsum")++ field+ end++ let!(:list_project_custom_field) do+ field = create(:list_project_custom_field, projects: [project], name: 'List field',+ project_custom_field_section: section_for_select_fields,+ possible_values: ['Option 1', 'Option 2', 'Option 3'])++ create(:custom_value, customized: project, custom_field: field, value: field.custom_options.first)++ field+ end++ let!(:version_project_custom_field) do+ field = create(:version_project_custom_field, projects: [project], name: 'Version field',+ project_custom_field_section: section_for_select_fields)++ create(:custom_value, customized: project, custom_field: field, value: first_version.id)++ field+ end++ let!(:user_project_custom_field) do+ field = create(:user_project_custom_field, projects: [project], name: 'User field',+ project_custom_field_section: section_for_select_fields)++ create(:custom_value, customized: project, custom_field: field, value: member_in_project.id)++ field+ end++ let!(:multi_list_project_custom_field) do+ field = create(:list_project_custom_field, projects: [project], name: 'Multi list field',+ project_custom_field_section: section_for_multi_select_fields,+ possible_values: ['Option 1', 'Option 2', 'Option 3'],+ multi_value: true)++ create(:custom_value, customized: project, custom_field: field, value: field.custom_options.first.id)+ create(:custom_value, customized: project, custom_field: field, value: field.custom_options.second.id)++ field+ end++ let!(:multi_version_project_custom_field) do+ field = create(:version_project_custom_field, projects: [project], name: 'Multi version field',+ project_custom_field_section: section_for_multi_select_fields,+ multi_value: true)++ create(:custom_value, customized: project, custom_field: field, value: first_version.id)+ create(:custom_value, customized: project, custom_field: field, value: second_version.id)++ field+ end++ let!(:multi_user_project_custom_field) do+ field = create(:user_project_custom_field, projects: [project], name: 'Multi user field',+ project_custom_field_section: section_for_multi_select_fields,+ multi_value: true)++ create(:custom_value, customized: project, custom_field: field, value: member_in_project.id)+ create(:custom_value, customized: project, custom_field: field, value: another_member_in_project.id)++ field+ end+enddiff --git a/spec/features/projects/project_custom_fields/overview_page/show_spec.rb b/spec/features/projects/project_custom_fields/overview_page/show_spec.rbnew file mode 100644index 00000000000..f41ab4d3ded--- /dev/null+++ b/spec/features/projects/project_custom_fields/overview_page/show_spec.rb@@ -0,0 +1,850 @@+#-- copyright+# OpenProject is an open source project management software.+# Copyright (C) 2012-2023 the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# This program is distributed in the hope that it will be useful,+# but WITHOUT ANY WARRANTY; without even the implied warranty of+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+# GNU General Public License for more details.+#+# You should have received a copy of the GNU General Public License+# along with this program; if not, write to the Free Software+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.+#+# See COPYRIGHT and LICENSE files for more details.+#++++require 'spec_helper'+require_relative 'shared_context'+require_relative 'overview_page'++RSpec.describe 'Show project custom fields on project overview page', :js, :with_cuprite do+ include_context 'with seeded projects, members and project custom fields'++ let(:overview_page) { OverviewPage.new(project) }++ before do+ login_as admin+ end++ describe 'with disabled project attributes feature', with_flag: { project_attributes: false } do+ it 'does not show the project attributes sidebar' do+ overview_page.visit_page++ within '.op-grid-page' do+ expect(page).not_to have_css('#project-attributes-sidebar')+ end+ end+ end++ describe 'with enabled project attributes feature', with_flag: { project_attributes: true } do+ it 'does show the project attributes sidebar' do+ overview_page.visit_page++ within '.op-grid-page' do+ expect(page).to have_css('#project-attributes-sidebar')+ end+ end++ describe 'with correct scoping' do+ it 'shows enabled project custom fields in a sidebar grouped by section' do+ overview_page.visit_page++ overview_page.within_async_loaded_sidebar do+ expect(page).to have_css('.op-project-custom-field-section-container', count: 3)++ overview_page.within_custom_field_section_container(section_for_input_fields) do+ expect(page).to have_text 'Input fields'++ expect(page).to have_text 'Boolean field'+ expect(page).to have_text 'String field'+ expect(page).to have_text 'Integer field'+ expect(page).to have_text 'Float field'+ expect(page).to have_text 'Date field'+ expect(page).to have_text 'Text field'+ end++ overview_page.within_custom_field_section_container(section_for_select_fields) do+ expect(page).to have_text 'Select fields'++ expect(page).to have_text 'List field'+ expect(page).to have_text 'Version field'+ expect(page).to have_text 'User field'+ end++ overview_page.within_custom_field_section_container(section_for_multi_select_fields) do+ expect(page).to have_text 'Multi select fields'++ expect(page).to have_text 'Multi list field'+ expect(page).to have_text 'Multi version field'+ expect(page).to have_text 'Multi user field'+ end+ end+ end++ it 'does not show project custom fields not enabled for this project in a sidebar' do+ create(:string_project_custom_field, projects: [other_project], name: 'String field enabled for other project')++ overview_page.visit_page++ overview_page.within_async_loaded_sidebar do+ expect(page).not_to have_text 'String field enabled for other project'+ end+ end+ end++ describe 'with correct order' do+ it 'shows the project custom field sections in the correct order' do+ overview_page.visit_page++ overview_page.within_async_loaded_sidebar do+ sections = page.all('.op-project-custom-field-section-container')++ expect(sections.size).to eq(3)++ expect(sections[0].text).to include('Input fields')+ expect(sections[1].text).to include('Select fields')+ expect(sections[2].text).to include('Multi select fields')+ end++ section_for_input_fields.move_to_bottom++ overview_page.visit_page++ overview_page.within_async_loaded_sidebar do+ sections = page.all('.op-project-custom-field-section-container')++ expect(sections.size).to eq(3)++ expect(sections[0].text).to include('Select fields')+ expect(sections[1].text).to include('Multi select fields')+ expect(sections[2].text).to include('Input fields')+ end+ end++ it 'shows the project custom fields in the correct order within the sections' do+ overview_page.visit_page++ overview_page.within_async_loaded_sidebar do+ overview_page.within_custom_field_section_container(section_for_input_fields) do+ fields = page.all('.op-project-custom-field-container')++ expect(fields.size).to eq(6)++ 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+ end++ string_project_custom_field.move_to_bottom++ overview_page.visit_page++ overview_page.within_async_loaded_sidebar do+ overview_page.within_custom_field_section_container(section_for_input_fields) do+ fields = page.all('.op-project-custom-field-container')++ expect(fields.size).to eq(6)++ expect(fields[0].text).to include('Boolean 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('String field')+ end+ end+ end+ end++ describe 'with correct values' do+ describe 'with boolean CF' do+ # it_behaves_like 'a project custom field' do+ # let(subject) { boolean_project_custom_field }+ # end++ describe 'with value set by user' do+ it 'shows the correct value for the project custom field if given' do+ overview_page.visit_page++ overview_page.within_async_loaded_sidebar do+ overview_page.within_custom_field_container(boolean_project_custom_field) do+ expect(page).to have_text 'Boolean field'+ expect(page).to have_text 'Yes'+ end+ end+ end+ end++ describe 'with value unset by user' do+ # A boolean cannot be completely unset via UI, only toggle between true and false, no blank value possible+ before do+ boolean_project_custom_field.custom_values.where(customized: project).first.update!(value: false)+ end++ it 'shows the correct value for the project custom field if given' do+ overview_page.visit_page++ overview_page.within_async_loaded_sidebar do+ overview_page.within_custom_field_container(boolean_project_custom_field) do+ expect(page).to have_text 'Boolean field'+ expect(page).to have_text 'No'+ end+ end+ end+ end++ describe 'with no value set by user' do+ before do+ boolean_project_custom_field.custom_values.where(customized: project).destroy_all+ end++ it 'shows an N/A text for the project custom field if no value given' do+ overview_page.visit_page++ overview_page.within_async_loaded_sidebar do+ overview_page.within_custom_field_container(boolean_project_custom_field) do+ expect(page).to have_text 'Boolean field'+ expect(page).to have_text 'Not set yet'+ end+ end+ end++ it 'shows the default value for the project custom field if no value given' do+ boolean_project_custom_field.update!(default_value: true)++ overview_page.visit_page++ overview_page.within_async_loaded_sidebar do+ overview_page.within_custom_field_container(boolean_project_custom_field) do+ expect(page).to have_text 'Boolean field'+ expect(page).to have_text 'Yes'+ end+ end++ boolean_project_custom_field.update!(default_value: false)++ overview_page.visit_page++ overview_page.within_async_loaded_sidebar do+ overview_page.within_custom_field_container(boolean_project_custom_field) do+ expect(page).to have_text 'Boolean field'+ expect(page).to have_text 'No'+ end+ end+ end+ end+ end++ describe 'with string CF' do+ describe 'with value set by user' do+ it 'shows the correct value for the project custom field if given' do+ overview_page.visit_page++ overview_page.within_async_loaded_sidebar do+ overview_page.within_custom_field_container(string_project_custom_field) do+ expect(page).to have_text 'String field'+ expect(page).to have_text 'Foo'+ end+ end+ end+ end++ describe 'with value unset by user' do+ before do+ string_project_custom_field.custom_values.where(customized: project).first.update!(value: '')+ end++ it 'shows the correct value for the project custom field if given' do+ overview_page.visit_page++ overview_page.within_async_loaded_sidebar do+ overview_page.within_custom_field_container(string_project_custom_field) do+ expect(page).to have_text 'String field'+ expect(page).to have_text 'Not set yet'+ end+ end+ end+ end++ describe 'with no value set by user' do+ before do+ string_project_custom_field.custom_values.where(customized: project).destroy_all+ end++ it 'shows an N/A text for the project custom field if no value given' do+ overview_page.visit_page++ overview_page.within_async_loaded_sidebar do+ overview_page.within_custom_field_container(string_project_custom_field) do+ expect(page).to have_text 'String field'+ expect(page).to have_text 'Not set yet'+ end+ end+ end++ it 'shows the default value for the project custom field if no value given' do+ string_project_custom_field.update!(default_value: 'Bar')++ overview_page.visit_page++ overview_page.within_async_loaded_sidebar do+ overview_page.within_custom_field_container(string_project_custom_field) do+ expect(page).to have_text 'String field'+ expect(page).to have_text 'Bar'+ end+ end+ end+ end+ end++ describe 'with integer CF' do+ describe 'with value set by user' do+ it 'shows the correct value for the project custom field if given' do+ overview_page.visit_page++ overview_page.within_async_loaded_sidebar do+ overview_page.within_custom_field_container(integer_project_custom_field) do+ expect(page).to have_text 'Integer field'+ expect(page).to have_text '123'+ end+ end+ end+ end++ describe 'with value unset by user' do+ before do+ integer_project_custom_field.custom_values.where(customized: project).first.update!(value: '')+ end++ it 'shows the correct value for the project custom field if given' do+ overview_page.visit_page++ overview_page.within_async_loaded_sidebar do+ overview_page.within_custom_field_container(integer_project_custom_field) do+ expect(page).to have_text 'Integer field'+ expect(page).to have_text 'Not set yet'+ end+ end+ end+ end++ describe 'with no value set by user' do+ before do+ integer_project_custom_field.custom_values.where(customized: project).destroy_all+ end++ it 'shows an N/A text for the project custom field if no value given' do+ overview_page.visit_page++ overview_page.within_async_loaded_sidebar do+ overview_page.within_custom_field_container(integer_project_custom_field) do+ expect(page).to have_text 'Integer field'+ expect(page).to have_text 'Not set yet'+ end+ end+ end++ it 'shows the default value for the project custom field if no value given' do+ integer_project_custom_field.update!(default_value: 456)++ overview_page.visit_page++ overview_page.within_async_loaded_sidebar do+ overview_page.within_custom_field_container(integer_project_custom_field) do+ expect(page).to have_text 'Integer field'+ expect(page).to have_text '456'+ end+ end+ end+ end+ end++ describe 'with date CF' do+ describe 'with value set by user' do+ it 'shows the correct value for the project custom field if given' do+ overview_page.visit_page++ overview_page.within_async_loaded_sidebar do+ overview_page.within_custom_field_container(date_project_custom_field) do+ expect(page).to have_text 'Date field'+ expect(page).to have_text '01/01/2024'+ end+ end+ end+ end++ describe 'with value unset by user' do+ before do+ date_project_custom_field.custom_values.where(customized: project).first.update!(value: '')+ end++ it 'shows the correct value for the project custom field if given' do+ overview_page.visit_page++ overview_page.within_async_loaded_sidebar do+ overview_page.within_custom_field_container(date_project_custom_field) do+ expect(page).to have_text 'Date field'+ expect(page).to have_text 'Not set yet'+ end+ end+ end+ end++ describe 'with no value set by user' do+ before do+ date_project_custom_field.custom_values.where(customized: project).destroy_all+ end++ it 'shows an N/A text for the project custom field if no value given' do+ overview_page.visit_page++ overview_page.within_async_loaded_sidebar do+ overview_page.within_custom_field_container(date_project_custom_field) do+ expect(page).to have_text 'Date field'+ expect(page).to have_text 'Not set yet'+ end+ end+ end++ it 'shows the default value for the project custom field if no value given' do+ date_project_custom_field.update!(default_value: Date.new(2024, 2, 2))++ overview_page.visit_page++ overview_page.within_async_loaded_sidebar do+ overview_page.within_custom_field_container(date_project_custom_field) do+ expect(page).to have_text 'Date field'+ expect(page).to have_text '02/02/2024'+ end+ end+ end+ end+ end++ describe 'with float CF' do+ describe 'with value set by user' do+ it 'shows the correct value for the project custom field if given' do+ overview_page.visit_page++ overview_page.within_async_loaded_sidebar do+ overview_page.within_custom_field_container(float_project_custom_field) do+ expect(page).to have_text 'Float field'+ expect(page).to have_text '123.456'+ end+ end+ end+ end++ describe 'with value unset by user' do+ before do+ float_project_custom_field.custom_values.where(customized: project).first.update!(value: '')+ end++ it 'shows the correct value for the project custom field if given' do+ overview_page.visit_page++ overview_page.within_async_loaded_sidebar do+ overview_page.within_custom_field_container(float_project_custom_field) do+ expect(page).to have_text 'Float field'+ expect(page).to have_text 'Not set yet'+ end+ end+ end+ end++ describe 'with no value set by user' do+ before do+ float_project_custom_field.custom_values.where(customized: project).destroy_all+ end++ it 'shows an N/A text for the project custom field if no value given' do+ overview_page.visit_page++ overview_page.within_async_loaded_sidebar do+ overview_page.within_custom_field_container(float_project_custom_field) do+ expect(page).to have_text 'Float field'+ expect(page).to have_text 'Not set yet'+ end+ end+ end++ it 'shows the default value for the project custom field if no value given' do+ float_project_custom_field.update!(default_value: 456.789)++ overview_page.visit_page++ overview_page.within_async_loaded_sidebar do+ overview_page.within_custom_field_container(float_project_custom_field) do+ expect(page).to have_text 'Float field'+ expect(page).to have_text '456.789'+ end+ end+ end+ end+ end++ describe 'with text CF' do+ describe 'with value set by user' do+ it 'shows the correct value for the project custom field if given' do+ overview_page.visit_page++ overview_page.within_async_loaded_sidebar do+ overview_page.within_custom_field_container(text_project_custom_field) do+ expect(page).to have_text 'Text field'+ expect(page).to have_text "Lorem\nipsum"+ end+ end+ end+ end++ describe 'with value unset by user' do+ before do+ text_project_custom_field.custom_values.where(customized: project).first.update!(value: '')+ end++ it 'shows the correct value for the project custom field if given' do+ overview_page.visit_page++ overview_page.within_async_loaded_sidebar do+ overview_page.within_custom_field_container(text_project_custom_field) do+ expect(page).to have_text 'Text field'+ expect(page).to have_text 'Not set yet'+ end+ end+ end+ end++ describe 'with no value set by user' do+ before do+ text_project_custom_field.custom_values.where(customized: project).destroy_all+ end++ it 'shows an N/A text for the project custom field if no value given' do+ overview_page.visit_page++ overview_page.within_async_loaded_sidebar do+ overview_page.within_custom_field_container(text_project_custom_field) do+ expect(page).to have_text 'Text field'+ expect(page).to have_text 'Not set yet'+ end+ end+ end++ it 'shows the default value for the project custom field if no value given' do+ text_project_custom_field.update!(default_value: 'Dolor sit amet')++ overview_page.visit_page++ overview_page.within_async_loaded_sidebar do+ overview_page.within_custom_field_container(text_project_custom_field) do+ expect(page).to have_text 'Text field'+ expect(page).to have_text 'Dolor sit amet'+ end+ end+ end+ end+ end++ describe 'with list CF' do+ describe 'with value set by user' do+ it 'shows the correct value for the project custom field if given' do+ overview_page.visit_page++ overview_page.within_async_loaded_sidebar do+ overview_page.within_custom_field_container(list_project_custom_field) do+ expect(page).to have_text 'List field'+ expect(page).to have_text 'Option 1'+ end+ end+ end+ end++ describe 'with value unset by user' do+ before do+ list_project_custom_field.custom_values.where(customized: project).first.update!(value: '')+ end++ it 'shows the correct value for the project custom field if given' do+ overview_page.visit_page++ overview_page.within_async_loaded_sidebar do+ overview_page.within_custom_field_container(list_project_custom_field) do+ expect(page).to have_text 'List field'+ expect(page).to have_text 'Not set yet'+ end+ end+ end+ end++ describe 'with no value set by user' do+ before do+ list_project_custom_field.custom_values.where(customized: project).destroy_all+ end++ it 'shows an N/A text for the project custom field if no value given' do+ overview_page.visit_page++ overview_page.within_async_loaded_sidebar do+ overview_page.within_custom_field_container(list_project_custom_field) do+ expect(page).to have_text 'List field'+ expect(page).to have_text 'Not set yet'+ end+ end+ end++ it 'shows the default value for the project custom field if no value given' do+ list_project_custom_field.custom_options.first.update!(default_value: true)++ overview_page.visit_page++ overview_page.within_async_loaded_sidebar do+ overview_page.within_custom_field_container(list_project_custom_field) do+ expect(page).to have_text 'List field'+ expect(page).to have_text 'Option 1'+ end+ end+ end+ end+ end++ describe 'with version CF' do+ describe 'with value set by user' do+ it 'shows the correct value for the project custom field if given' do+ overview_page.visit_page++ overview_page.within_async_loaded_sidebar do+ overview_page.within_custom_field_container(version_project_custom_field) do+ expect(page).to have_text 'Version field'+ expect(page).to have_text 'Version 1'+ end+ end+ end+ end++ describe 'with value unset by user' do+ before do+ version_project_custom_field.custom_values.where(customized: project).first.update!(value: '')+ end++ it 'shows the correct value for the project custom field if given' do+ overview_page.visit_page++ overview_page.within_async_loaded_sidebar do+ overview_page.within_custom_field_container(version_project_custom_field) do+ expect(page).to have_text 'Version field'+ expect(page).to have_text 'Not set yet'+ end+ end+ end+ end++ describe 'with no value set by user' do+ before do+ version_project_custom_field.custom_values.where(customized: project).destroy_all+ end++ it 'shows an N/A text for the project custom field if no value given' do+ overview_page.visit_page++ overview_page.within_async_loaded_sidebar do+ overview_page.within_custom_field_container(version_project_custom_field) do+ expect(page).to have_text 'Version field'+ expect(page).to have_text 'Not set yet'+ end+ end+ end+ end+ end++ describe 'with user CF' do+ describe 'with value set by user' do+ it 'shows the correct value for the project custom field if given' do+ overview_page.visit_page++ overview_page.within_async_loaded_sidebar do+ overview_page.within_custom_field_container(user_project_custom_field) do+ expect(page).to have_text 'User field'+ expect(page).to have_text 'Member 1 In Project'+ end+ end+ end+ end++ describe 'with value unset by user' do+ before do+ user_project_custom_field.custom_values.where(customized: project).first.update!(value: '')+ end++ it 'shows the correct value for the project custom field if given' do+ overview_page.visit_page++ overview_page.within_async_loaded_sidebar do+ overview_page.within_custom_field_container(user_project_custom_field) do+ expect(page).to have_text 'User field'+ expect(page).to have_text 'Not set yet'+ end+ end+ end+ end++ describe 'with no value set by user' do+ before do+ user_project_custom_field.custom_values.where(customized: project).destroy_all+ end++ it 'shows an N/A text for the project custom field if no value given' do+ overview_page.visit_page++ overview_page.within_async_loaded_sidebar do+ overview_page.within_custom_field_container(user_project_custom_field) do+ expect(page).to have_text 'User field'+ expect(page).to have_text 'Not set yet'+ end+ end+ end+ end+ end++ describe 'with multi list CF' do+ describe 'with value set by user' do+ it 'shows the correct values for the project custom field if given' do+ overview_page.visit_page++ overview_page.within_async_loaded_sidebar do+ overview_page.within_custom_field_container(multi_list_project_custom_field) do+ expect(page).to have_text 'Multi list field'+ expect(page).to have_text 'Option 1, Option 2'+ end+ end+ end+ end++ describe 'with no value set by user' do+ before do+ multi_list_project_custom_field.custom_values.where(customized: project).destroy_all+ end++ it 'shows an N/A text for the project custom field if no value given' do+ overview_page.visit_page++ overview_page.within_async_loaded_sidebar do+ overview_page.within_custom_field_container(multi_list_project_custom_field) do+ expect(page).to have_text 'Multi list field'+ expect(page).to have_text 'Not set yet'+ end+ end+ end++ it 'shows the default value(s) for the project custom field if no value given' do+ multi_list_project_custom_field.custom_options.first.update!(default_value: true)+ multi_list_project_custom_field.custom_options.second.update!(default_value: true)++ overview_page.visit_page++ overview_page.within_async_loaded_sidebar do+ overview_page.within_custom_field_container(multi_list_project_custom_field) do+ expect(page).to have_text 'Multi list field'+ expect(page).to have_text 'Option 1, Option 2'+ end+ end+ end+ end+ end++ describe 'with multi version CF' do+ describe 'with value set by user' do+ it 'shows the correct values for the project custom field if given' do+ overview_page.visit_page++ overview_page.within_async_loaded_sidebar do+ overview_page.within_custom_field_container(multi_version_project_custom_field) do+ expect(page).to have_text 'Multi version field'+ expect(page).to have_text 'Version 1, Version 2'+ end+ end+ end+ end++ describe 'with no value set by user' do+ before do+ multi_version_project_custom_field.custom_values.where(customized: project).destroy_all+ end++ it 'shows an N/A text for the project custom field if no value given' do+ overview_page.visit_page++ overview_page.within_async_loaded_sidebar do+ overview_page.within_custom_field_container(multi_version_project_custom_field) do+ expect(page).to have_text 'Multi version field'+ expect(page).to have_text 'Not set yet'+ end+ end+ end+ end+ end++ describe 'with multi user CF' do+ describe 'with value set by user' do+ it 'shows the correct values for the project custom field if given' do+ overview_page.visit_page++ overview_page.within_async_loaded_sidebar do+ overview_page.within_custom_field_container(multi_user_project_custom_field) do+ expect(page).to have_text 'Multi user field'+ expect(page).to have_text 'Member 1 In Project, Member 2 In Project'+ end+ end+ end+ end++ describe 'with no value set by user' do+ before do+ multi_user_project_custom_field.custom_values.where(customized: project).destroy_all+ end++ it 'shows an N/A text for the project custom field if no value given' do+ overview_page.visit_page++ overview_page.within_async_loaded_sidebar do+ overview_page.within_custom_field_container(multi_user_project_custom_field) do+ expect(page).to have_text 'Multi user field'+ expect(page).to have_text 'Not set yet'+ end+ end+ end+ end+ end+ end+ end++ # TODO: share examples in order to reduce code duplication+ # shared_examples 'a project custom field' do+ # it 'shows the correct value for the project custom field if given' do+ # overview_page.visit_page++ # overview_page.within_async_loaded_sidebar do+ # overview_page.within_custom_field_container(custom_field) do+ # expect(page).to have_text custom_field.name+ # expect(page).to have_text custom_field.formatted_value+ # end+ # end+ # end+ # end+enddiff --git a/spec/features/projects/project_custom_fields/settings/mapping_spec.rb b/spec/features/projects/project_custom_fields/settings/mapping_spec.rbnew file mode 100644index 00000000000..f1bf221ad04--- /dev/null+++ b/spec/features/projects/project_custom_fields/settings/mapping_spec.rb@@ -0,0 +1,363 @@+#-- copyright+# OpenProject is an open source project management software.+# Copyright (C) 2012-2023 the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# This program is distributed in the hope that it will be useful,+# but WITHOUT ANY WARRANTY; without even the implied warranty of+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+# GNU General Public License for more details.+#+# You should have received a copy of the GNU General Public License+# along with this program; if not, write to the Free Software+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.+#+# See COPYRIGHT and LICENSE files for more details.+#++++require 'spec_helper'++RSpec.describe 'Projects custom fields mapping via project settings', :js, :with_cuprite do+ let(:project) { create(:project, name: 'Foo project', identifier: 'foo-project') }+ let(:other_project) { create(:project, name: 'Bar project', identifier: 'bar-project') }++ let!(:user_with_sufficient_permissions) do+ create(:user,+ firstname: 'Project',+ lastname: 'Admin',+ member_with_permissions: {+ project => %w[+ view_work_packages+ edit_project+ select_project_custom_fields+ ],+ other_project => %w[+ view_work_packages+ edit_project+ select_project_custom_fields+ ]+ })+ end++ let!(:member_in_project) do+ create(:user,+ firstname: 'Member 1',+ lastname: 'In Project',+ member_with_permissions: { project => %w[+ edit_project+ view_work_packages+ ] })+ end++ let!(:another_member_in_project) do+ create(:user,+ firstname: 'Member 2',+ lastname: 'In Project',+ member_with_permissions: { project => %w[+ view_work_packages+ ] })+ end++ let!(:section_for_input_fields) { create(:project_custom_field_section, name: 'Input fields') }+ let!(:section_for_select_fields) { create(:project_custom_field_section, name: 'Select fields') }+ let!(:section_for_multi_select_fields) { create(:project_custom_field_section, name: 'Multi select fields') }++ let!(:boolean_project_custom_field) do+ create(:boolean_project_custom_field, name: 'Boolean field',+ project_custom_field_section: section_for_input_fields)+ end++ let!(:string_project_custom_field) do+ create(:string_project_custom_field, name: 'String field',+ project_custom_field_section: section_for_input_fields)+ end++ let!(:list_project_custom_field) do+ create(:list_project_custom_field, name: 'List field',+ project_custom_field_section: section_for_select_fields,+ possible_values: ['Option 1', 'Option 2', 'Option 3'])+ end++ let!(:multi_list_project_custom_field) do+ create(:list_project_custom_field, name: 'Multi list field',+ project_custom_field_section: section_for_multi_select_fields,+ possible_values: ['Option 1', 'Option 2', 'Option 3'],+ multi_value: true)+ end++ describe 'with insufficient permissions' do+ before do+ login_as member_in_project # can edit project but is not allowed to select project custom fields+ end++ describe 'with enabled project attributes feature', with_flag: { project_attributes: true } do+ it 'does not show the menu entry in the project settings menu' do+ visit project_settings_general_path(project)++ within '#menu-sidebar' do+ expect(page).not_to have_css("li[data-name='settings_project_custom_fields']")+ end+ end++ it 'does not show the project custom fields page' do+ visit project_settings_project_custom_fields_path(project)++ expect(page).to have_content('You are not authorized to access this page.')+ end+ end+ end++ describe 'with sufficient permissions' do+ before do+ login_as user_with_sufficient_permissions+ end++ describe 'with disabled project attributes feature', with_flag: { project_attributes: false } do+ it 'does not show the menu entry in the project settings menu' do+ visit project_settings_general_path(project)++ within '#menu-sidebar' do+ expect(page).not_to have_css("li[data-name='settings_project_custom_fields']")+ end+ end+ end++ describe 'with enabled project attributes feature', with_flag: { project_attributes: true } do+ it 'does show the menu entry in the project settings menu' do+ visit project_settings_general_path(project)++ within '#menu-sidebar' do+ expect(page).to have_css("li[data-name='settings_project_custom_fields']")+ end+ end++ it 'shows all available project custom fields with their correct mapping state' do+ visit project_settings_project_custom_fields_path(project)++ within_custom_field_section_container(section_for_input_fields) do+ within_custom_field_container(boolean_project_custom_field) do+ expect(page).to have_content('Boolean field')+ expect_type("Bool")+ expect_unchecked_state+ end+ within_custom_field_container(string_project_custom_field) do+ expect(page).to have_content('String field')+ expect_type("String")+ expect_unchecked_state+ end+ end++ within_custom_field_section_container(section_for_select_fields) do+ within_custom_field_container(list_project_custom_field) do+ expect(page).to have_content('List field')+ expect_type("List")+ expect_unchecked_state+ end+ end++ within_custom_field_section_container(section_for_multi_select_fields) do+ within_custom_field_container(multi_list_project_custom_field) do+ expect(page).to have_content('Multi list field')+ expect_type("List")+ expect_unchecked_state+ end+ end+ end++ it 'toggles the mapping state of a project custom field for a specific project when clicked' do+ visit project_settings_project_custom_fields_path(project)++ within_custom_field_section_container(section_for_input_fields) do+ within_custom_field_container(boolean_project_custom_field) do+ expect_unchecked_state++ page.find("[data-qa-selector='toggle-project-custom-field-mapping-#{boolean_project_custom_field.id}']").click++ expect_checked_state # without reloading the page+ end+ end++ # propely persisted and visible after full page reload+ visit project_settings_project_custom_fields_path(project)++ within_custom_field_container(boolean_project_custom_field) do+ expect_checked_state+ end++ # only for this project+ visit project_settings_project_custom_fields_path(other_project)++ within_custom_field_container(boolean_project_custom_field) do+ expect_unchecked_state+ end+ end++ it 'enables all mapping states of a section for a specific project when bulk action button clicked' do+ visit project_settings_project_custom_fields_path(project)++ within_custom_field_section_container(section_for_input_fields) do+ page.find("[data-qa-selector='enable-all-project-custom-field-mappings-#{section_for_input_fields.id}']").click++ within_custom_field_container(boolean_project_custom_field) do+ expect_checked_state+ end+ within_custom_field_container(string_project_custom_field) do+ expect_checked_state+ end+ end++ within_custom_field_section_container(section_for_select_fields) do+ within_custom_field_container(list_project_custom_field) do+ expect_unchecked_state+ end+ end++ within_custom_field_section_container(section_for_multi_select_fields) do+ within_custom_field_container(multi_list_project_custom_field) do+ expect_unchecked_state+ end+ end+ end++ it 'disables all mapping states of a section for a specific project when bulk action button clicked' do+ visit project_settings_project_custom_fields_path(project)++ within_custom_field_section_container(section_for_input_fields) do+ page.find("[data-qa-selector='enable-all-project-custom-field-mappings-#{section_for_input_fields.id}']").click++ within_custom_field_container(boolean_project_custom_field) do+ expect_checked_state+ end+ within_custom_field_container(string_project_custom_field) do+ expect_checked_state+ end+ end++ within_custom_field_section_container(section_for_select_fields) do+ within_custom_field_container(list_project_custom_field) do+ expect_unchecked_state+ end+ end++ within_custom_field_section_container(section_for_multi_select_fields) do+ within_custom_field_container(multi_list_project_custom_field) do+ expect_unchecked_state+ end+ end++ within_custom_field_section_container(section_for_input_fields) do+ page.find("[data-qa-selector='disable-all-project-custom-field-mappings-#{section_for_input_fields.id}']").click++ within_custom_field_container(boolean_project_custom_field) do+ expect_unchecked_state+ end+ within_custom_field_container(string_project_custom_field) do+ expect_unchecked_state+ end+ end+ end++ it 'filters the project custom fields by name with given user input' do+ visit project_settings_project_custom_fields_path(project)++ fill_in 'project-custom-fields-mapping-filter', with: 'Boolean'++ within_custom_field_section_container(section_for_input_fields) do+ expect(page).to have_content('Boolean field')+ expect(page).not_to have_content('String field')+ end++ within_custom_field_section_container(section_for_select_fields) do+ expect(page).not_to have_content('List field')+ end++ within_custom_field_section_container(section_for_multi_select_fields) do+ expect(page).not_to have_content('Multi list field')+ end+ end++ it 'shows the project custom field sections in the correct order' do+ visit project_settings_project_custom_fields_path(project)++ sections = page.all('.op-project-custom-field-section')++ expect(sections.size).to eq(3)++ expect(sections[0].text).to include('Input fields')+ expect(sections[1].text).to include('Select fields')+ expect(sections[2].text).to include('Multi select fields')++ section_for_input_fields.move_to_bottom++ visit project_settings_project_custom_fields_path(project)++ sections = page.all('.op-project-custom-field-section')++ expect(sections.size).to eq(3)++ expect(sections[0].text).to include('Select fields')+ expect(sections[1].text).to include('Multi select fields')+ expect(sections[2].text).to include('Input fields')+ end++ it 'shows the project custom fields in the correct order within the sections' do+ visit project_settings_project_custom_fields_path(project)++ within_custom_field_section_container(section_for_input_fields) do+ custom_fields = page.all('.op-project-custom-field')++ expect(custom_fields.size).to eq(2)++ expect(custom_fields[0].text).to include('Boolean field')+ expect(custom_fields[1].text).to include('String field')+ end++ boolean_project_custom_field.move_to_bottom++ visit project_settings_project_custom_fields_path(project)++ within_custom_field_section_container(section_for_input_fields) do+ custom_fields = page.all('.op-project-custom-field')++ expect(custom_fields.size).to eq(2)++ expect(custom_fields[0].text).to include('String field')+ expect(custom_fields[1].text).to include('Boolean field')+ end+ end+ end+ end++ def expect_type(type)+ within "[data-qa-selector='custom-field-type']" do+ expect(page).to have_content(type)+ end+ end++ def expect_checked_state+ expect(page).to have_css('.octicon-check-circle')+ end++ def expect_unchecked_state+ expect(page).to have_css('.octicon-circle')+ end++ def within_custom_field_section_container(section, &)+ within("[data-qa-selector='project-custom-field-section-#{section.id}']", &)+ end++ def within_custom_field_container(custom_field, &)+ within("[data-qa-selector='project-custom-field-#{custom_field.id}']", &)+ end+enddiff --git a/spec/features/repositories/repository_settings_spec.rb b/spec/features/repositories/repository_settings_spec.rbindex bc2a64c0db2..16ce9e71475 100644--- a/spec/features/repositories/repository_settings_spec.rb+++ b/spec/features/repositories/repository_settings_spec.rb@@ -30,7 +30,7 @@ require 'spec_helper'require 'features/repositories/repository_settings_page'require 'features/support/components/danger_zone'-RSpec.describe 'Repository Settings', js: true do+RSpec.describe 'Repository Settings', :js dolet(:current_user) { create (:admin) }let(:project) { create(:project) }let(:settings_page) { RepositorySettingsPage.new(project) }@@ -54,7 +54,7 @@ RSpec.describe 'Repository Settings', js: true doshared_examples 'manages the repository' do |type|it 'displays the repository' do- expect(page).to have_selector('select[name="scm_vendor"]')+ expect(page).to have_css('select[name="scm_vendor"]')expect(find("#attributes-group--content-#{type}", visible: true)).not_to be_nilend@@ -84,7 +84,7 @@ RSpec.describe 'Repository Settings', js: true doelseSeleniumHubWaiter.waitfind('a.icon-remove', text: I18n.t(:button_remove)).click- expect(page).to have_selector('.op-toast.-warning')+ expect(page).to have_css('.op-toast.-warning')SeleniumHubWaiter.waitfind('a', text: I18n.t(:button_remove)).clickend@@ -105,7 +105,7 @@ RSpec.describe 'Repository Settings', js: true doshared_examples 'manages the repository with' do |name, type, _repository_type, _project_name|let(:repository) do- create("repository_#{name}".to_sym,+ create(:"repository_#{name}",scm_type: type,project:)end@@ -151,7 +151,7 @@ RSpec.describe 'Repository Settings', js: true doendend- context 'remote', webmock: true do+ context 'remote', :webmock dolet(:url) { 'http://myreposerver.example.com/api/' }let(:config) do{@@ -192,9 +192,9 @@ RSpec.describe 'Repository Settings', js: true dofill_in('repository-password-placeholder', with: 'password')click_button(I18n.t(:button_save))- expect(page).to have_selector('[name="repository[login]"][value="foobar"]')- expect(page).to have_selector('.op-toast',- text: I18n.t('repositories.update_settings_successful'))+ expect(page).to have_css('[name="repository[login]"][value="foobar"]')+ expect(page).to have_css('.op-toast',+ text: I18n.t('repositories.update_settings_successful'))endendend