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 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.rb
index 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 do
end
let(: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 do
login_as user
diff --git a/modules/dashboards/spec/features/project_description_spec.rb b/modules/dashboards/spec/features/project_description_spec.rb
index 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 do
manage_dashboards]
end
- let(:role) do
- FactoryBot.create(:role, permissions: permissions)
+ let(:editing_permissions) do
+ %i[view_dashboards
+ manage_dashboards
+ edit_project]
end
let(:user) do
FactoryBot.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) do
Pages::Dashboard.new(project)
end
- before do
- login_as user
-
+ def add_project_description_widget
dashboard_page.visit!
- end
-
- it 'can add the widget and see the description in it' do
dashboard_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
+ end
end
end
+
+ 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
+
end
diff --git a/modules/my_page/spec/features/my/custom_text_spec.rb b/modules/my_page/spec/features/my/custom_text_spec.rb
index 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 do
end
let(: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 do
login_as user