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 `#invite_user!` as a shortcut to the action + expectation

Aaron Contreras33386f3d3eef
diff --git a/spec/features/work_packages/share/access_spec.rb b/spec/features/work_packages/share/access_spec.rb
index 1fdffdb2ea7..07ec599af97 100644
--- a/spec/features/work_packages/share/access_spec.rb
+++ b/spec/features/work_packages/share/access_spec.rb
@@ -92,8 +92,7 @@ RSpec.describe 'Shared Work Package Access',
work_package_page.click_share_button
share_modal.expect_open
- share_modal.invite_user(shared_with_user, 'View')
- share_modal.expect_shared_with(shared_with_user)
+ share_modal.invite_user!(shared_with_user, 'View')
end
using_session "shared-with user" do
diff --git a/spec/support/components/work_packages/share_modal.rb b/spec/support/components/work_packages/share_modal.rb
index 9ca54a2ce03..10e72533ac8 100644
--- a/spec/support/components/work_packages/share_modal.rb
+++ b/spec/support/components/work_packages/share_modal.rb
@@ -220,6 +220,16 @@ module Components
alias_method :invite_users, :invite_user
alias_method :invite_group, :invite_user
+ # Augments +invite_user+ by asserting that the modifications to the
+ # share have reflected in the modal's UI and we're able to continue
+ # with our spec without any waits or network related assertions.
+ #
+ # As a side benefit, it just keeps the spec file cleaner.
+ def invite_user!(user, role_name)
+ invite_user(user, role_name)
+ expect_shared_with(user, role_name)
+ end
+
def search_user(search_string)
search_autocomplete page.find('[data-test-selector="op-share-wp-invite-autocomplete"]'),
query: search_string,