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

Extract opening the share modal into the WorkPackage page object

Aaron Contreras721b26baf1cf
diff --git a/spec/features/work_packages/share/bulk_sharing_spec.rb b/spec/features/work_packages/share/bulk_sharing_spec.rb
index 9ebf4ff8cfa..b25eb14eada 100644
--- a/spec/features/work_packages/share/bulk_sharing_spec.rb
+++ b/spec/features/work_packages/share/bulk_sharing_spec.rb
@@ -77,7 +77,8 @@ RSpec.describe 'Work Packages', 'Bulk Sharing',
it 'allows administrating shares in bulk' do
work_package_page.visit!
- click_button 'Share'
+ work_package_page.click_share_button
+
share_modal.expect_open
share_modal.expect_shared_count_of(3)
@@ -257,7 +258,8 @@ RSpec.describe 'Work Packages', 'Bulk Sharing',
share_modal.close
share_modal.expect_closed
- click_button 'Share'
+
+ work_package_page.click_share_button
share_modal.expect_open
share_modal.expect_shared_count_of(3)
@@ -287,7 +289,7 @@ RSpec.describe 'Work Packages', 'Bulk Sharing',
it 'does not allow bulk sharing' do
work_package_page.visit!
- click_button 'Share'
+ work_package_page.click_share_button
share_modal.expect_open
share_modal.expect_shared_count_of(3)
diff --git a/spec/features/work_packages/share/enterprise_restriction_spec.rb b/spec/features/work_packages/share/enterprise_restriction_spec.rb
index 76b1cfccd1d..497f866a6ed 100644
--- a/spec/features/work_packages/share/enterprise_restriction_spec.rb
+++ b/spec/features/work_packages/share/enterprise_restriction_spec.rb
@@ -55,7 +55,8 @@ RSpec.describe 'Work Package Sharing Enterprise Restriction',
before do
work_package_page.visit!
- click_button 'Share'
+ work_package_page.click_share_button
+
share_modal.expect_open
end
diff --git a/spec/features/work_packages/share/filter_spec.rb b/spec/features/work_packages/share/filter_spec.rb
index 8e4cec39b13..f2225070822 100644
--- a/spec/features/work_packages/share/filter_spec.rb
+++ b/spec/features/work_packages/share/filter_spec.rb
@@ -79,7 +79,7 @@ RSpec.describe 'Work package sharing',
context 'when having share permission' do
before do
work_package_page.visit!
- click_button 'Share'
+ work_package_page.click_share_button
end
it 'allows to filter for the type' do
diff --git a/spec/features/work_packages/share/multi_invite_spec.rb b/spec/features/work_packages/share/multi_invite_spec.rb
index e7f804fd34e..0a4088d09a7 100644
--- a/spec/features/work_packages/share/multi_invite_spec.rb
+++ b/spec/features/work_packages/share/multi_invite_spec.rb
@@ -82,7 +82,7 @@ RSpec.describe 'Work package sharing',
# Clicking on the share button opens a modal which lists all of the users a work package
# is explicitly shared with.
# Project members are not listed unless the work package is also shared with them explicitly.
- click_button 'Share'
+ work_package_page.click_share_button
aggregate_failures "Inviting multiple users or groups at once" do
share_modal.expect_shared_count_of(1)
@@ -135,7 +135,7 @@ RSpec.describe 'Work package sharing',
end
share_modal.close
- click_button 'Share'
+ work_package_page.click_share_button
aggregate_failures "Re-opening the modal after changes performed" do
# This user preserved
@@ -161,7 +161,7 @@ RSpec.describe 'Work package sharing',
before do
work_package_page.visit!
- click_button 'Share'
+ work_package_page.click_share_button
end
it 'allows adding multiple users and updates the modal correctly' do
@@ -193,7 +193,7 @@ RSpec.describe 'Work package sharing',
it 'allows creating multiple users at once' do
work_package_page.visit!
- click_button 'Share'
+ work_package_page.click_share_button
share_modal.expect_open
share_modal.expect_shared_count_of(1)
@@ -233,7 +233,7 @@ RSpec.describe 'Work package sharing',
it 'allows sharing with an existing user and creating a new one at the same time' do
work_package_page.visit!
- click_button 'Share'
+ work_package_page.click_share_button
share_modal.expect_open
share_modal.expect_shared_count_of(1)
@@ -267,7 +267,7 @@ RSpec.describe 'Work package sharing',
it 'shows a warning as soon as you reach the user limit' do
work_package_page.visit!
- click_button 'Share'
+ work_package_page.click_share_button
share_modal.expect_open
share_modal.expect_shared_count_of(1)
diff --git a/spec/features/work_packages/share_spec.rb b/spec/features/work_packages/share_spec.rb
index 63cf4b8e8ba..40bc61eed14 100644
--- a/spec/features/work_packages/share_spec.rb
+++ b/spec/features/work_packages/share_spec.rb
@@ -94,7 +94,7 @@ RSpec.describe 'Work package sharing',
# Clicking on the share button opens a modal which lists all of the users a work package
# is explicitly shared with.
# Project members are not listed unless the work package is also shared with them explicitly.
- click_button 'Share'
+ work_package_page.click_share_button
aggregate_failures "Initial shares list" do
share_modal.expect_title(I18n.t('js.work_packages.sharing.title'))
@@ -225,7 +225,7 @@ RSpec.describe 'Work package sharing',
end
share_modal.close
- click_button 'Share'
+ work_package_page.click_share_button
aggregate_failures "Re-opening the modal after changes performed" do
# This user preserved its group independent share
@@ -255,8 +255,7 @@ RSpec.describe 'Work package sharing',
it "lets the sharer know a user needs to be selected to share the work package with them" do
work_package_page.visit!
-
- click_button 'Share'
+ work_package_page.click_share_button
share_modal.expect_open
share_modal.click_share
@@ -342,7 +341,7 @@ RSpec.describe 'Work package sharing',
before do
work_package_page.visit!
- click_button 'Share'
+ work_package_page.click_share_button
end
it 'allows inviting and directly sharing with a user who is not part of the instance yet' do
@@ -390,7 +389,7 @@ RSpec.describe 'Work package sharing',
context 'when lacking global invite permission' do
it 'does not allow creating a user who is not part of the instance yet' do
work_package_page.visit!
- click_button 'Share'
+ work_package_page.click_share_button
share_modal.expect_open
share_modal.expect_shared_count_of(6)
diff --git a/spec/support/pages/work_packages/full_work_package.rb b/spec/support/pages/work_packages/full_work_package.rb
index e07e391c90d..4a89b79536d 100644
--- a/spec/support/pages/work_packages/full_work_package.rb
+++ b/spec/support/pages/work_packages/full_work_package.rb
@@ -38,6 +38,18 @@ module Pages
find_by_id('toolbar-items')
end
+ def click_share_button
+ within toolbar do
+ # The request to the capabilities endpoint determines
+ # whether the "Share" button is rendered or not.
+ # Instead of waiting for an idle network (which may
+ # include waiting for other network requests unrelated to
+ # sharing), waiting for the button to be present makes
+ # the spec a tad faster.
+ click_button('Share', wait: 10)
+ end
+ end
+
private
def container