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
Add test to cover inline edit of project description in dashboard widget
Henriette Dingerbb5a215ce184
diff --git a/modules/dashboards/spec/features/custom_text_spec.rb b/modules/dashboards/spec/features/custom_text_spec.rbindex f81a7df48d2..c2c346968a9 100644--- a/modules/dashboards/spec/features/custom_text_spec.rb+++ b/modules/dashboards/spec/features/custom_text_spec.rb@@ -52,7 +52,7 @@ describe 'Project description widget on dashboard', type: :feature, js: true doendlet(:image_fixture) { Rails.root.join('spec/fixtures/files/image.png') }let(:editor) { ::Components::WysiwygEditor.new 'body' }- let(:field) { WorkPackageEditorField.new(page, 'description', selector: '.inline-edit--active-field') }+ let(:field) { TextEditorField.new(page, 'description', selector: '.inline-edit--active-field') }before dologin_as userdiff --git a/modules/dashboards/spec/features/project_description_spec.rb b/modules/dashboards/spec/features/project_description_spec.rbindex 7328df632bb..65bd4ab4c99 100644--- a/modules/dashboards/spec/features/project_description_spec.rb+++ b/modules/dashboards/spec/features/project_description_spec.rb@@ -41,34 +41,81 @@ describe 'Project description widget on dashboard', type: :feature, js: true domanage_dashboards]end- let(:role) do- FactoryBot.create(:role, permissions: permissions)+ let(:editing_permissions) do+ %i[view_dashboards+ manage_dashboards+ edit_project]endlet(:user) doFactoryBot.create(:user, member_in_project: project, member_with_permissions: permissions)end++ let(:second_user) do+ FactoryBot.create(:user, member_in_project: project, member_with_permissions: editing_permissions)+ end+let(:dashboard_page) doPages::Dashboard.new(project)end- before do- login_as user-+ def add_project_description_widgetdashboard_page.visit!- end-- it 'can add the widget and see the description in it' dodashboard_page.add_widget(1, 1, :within, "Project description")sleep(0.1)+ end++ context 'without editing permissions' do+ before do+ login_as user+ add_project_description_widget+ end++ it 'can add the widget, but not edit the description' do+ # As the user lacks the manage_public_queries and save_queries permission, no other widget is present+ description_widget = Components::Grids::GridArea.new('.grid--area.-widgeted:nth-of-type(1)')- # As the user lacks the manage_public_queries and save_queries permission, no other widget is present- description_widget = Components::Grids::GridArea.new('.grid--area.-widgeted:nth-of-type(1)')+ within(description_widget.area) do+ # The description is visible+ expect(page)+ .to have_content(project_description)- within(description_widget.area) do- expect(page)- .to have_content(project_description)+ # The description is not editable+ field = TextEditorField.new dashboard_page, 'description'+ field.activate! expect_open: false+ endendend++ context 'with editing permissions' do+ before do+ login_as second_user+ add_project_description_widget+ end++ it 'can edit the description' do+ # As the user lacks the manage_public_queries and save_queries permission, no other widget is present+ description_widget = Components::Grids::GridArea.new('.grid--area.-widgeted:nth-of-type(1)')++ within(description_widget.area) do+ # Open description field+ field = TextEditorField.new dashboard_page, 'description'+ field.activate!+ sleep(0.1)++ # Change the value+ field.expect_value(project_description)+ field.set_value 'A completely new description which is super cool.'+ field.save!++ # The edit field is toggled and the value saved.+ expect(page).to have_content('A completely new description which is super cool.')+ expect(page).to have_selector(field.selector)+ expect(page).not_to have_selector(field.input_selector)+ end++ end+ end+enddiff --git a/modules/my_page/spec/features/my/custom_text_spec.rb b/modules/my_page/spec/features/my/custom_text_spec.rbindex 1f0bd623e48..c7348fd328f 100644--- a/modules/my_page/spec/features/my/custom_text_spec.rb+++ b/modules/my_page/spec/features/my/custom_text_spec.rb@@ -51,7 +51,7 @@ describe 'Custom text widget on my page', type: :feature, js: true doendlet(:image_fixture) { Rails.root.join('spec/fixtures/files/image.png') }let(:editor) { ::Components::WysiwygEditor.new 'body' }- let(:field) { WorkPackageEditorField.new(page, 'description', selector: '.inline-edit--active-field') }+ let(:field) { TextEditorField.new(page, 'description', selector: '.inline-edit--active-field') }before dologin_as user