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 specs to cover granular update sorting behavior
Aaron Contreras7e3767f29f77
diff --git a/app/components/work_packages/share/modal_body_component.rb b/app/components/work_packages/share/modal_body_component.rbindex b9ee9b07e19..803f3b1fbb1 100644--- a/app/components/work_packages/share/modal_body_component.rb+++ b/app/components/work_packages/share/modal_body_component.rb@@ -53,6 +53,10 @@ module WorkPackagestrueend+ def insert_target_modifier_id+ 'op-share-wp-active-shares'+ end+# There is currently no available system argument for setting an id on the# rendered <ul> tag that houses the row slots on Primer::Beta::BorderBox components.def invited_user_list(&)diff --git a/spec/features/work_packages/share_spec.rb b/spec/features/work_packages/share_spec.rbindex 5b4cdf674fe..01ad1121471 100644--- a/spec/features/work_packages/share_spec.rb+++ b/spec/features/work_packages/share_spec.rb@@ -71,7 +71,7 @@ RSpec.describe 'Work package sharing',let!(:shared_project_user) { create(:user, firstname: 'Shared Project', lastname: 'User') }let!(:not_shared_yet_with_user) { create(:user, firstname: 'Not shared Yet', lastname: 'User') }- current_user { create(:user) }+ current_user { create(:user, firstname: 'Signed in', lastname: 'User') }context 'when having share permission' doit 'allows seeing and administrating sharing' do@@ -83,36 +83,32 @@ RSpec.describe 'Work package sharing',click_button 'Share'share_modal.expect_open- share_modal.expect_shared_with(view_user, 'View')- share_modal.expect_shared_with(comment_user, 'Comment')- share_modal.expect_shared_with(edit_user, 'Edit')- share_modal.expect_shared_with(shared_project_user, 'Edit')+ share_modal.expect_shared_with(comment_user, 'Comment', position: 1)+ share_modal.expect_shared_with(edit_user, 'Edit', position: 2)+ share_modal.expect_shared_with(shared_project_user, 'Edit', position: 3)# The current users share is also displayed but not editable- share_modal.expect_shared_with(current_user, editable: false)+ share_modal.expect_shared_with(current_user, position: 4, editable: false)+ share_modal.expect_shared_with(view_user, 'View', position: 5)share_modal.expect_not_shared_with(non_shared_project_user)share_modal.expect_not_shared_with(not_shared_yet_with_user)share_modal.expect_shared_count_of(5)- # Inviting a user will lead to that user being listed together with the rest of the shared with users.+ # Inviting a user will lead to that user being prepended to the list together with the rest of the shared with users.share_modal.invite_user(not_shared_yet_with_user, 'View')- share_modal.expect_shared_with(not_shared_yet_with_user, 'View')-+ share_modal.expect_shared_with(not_shared_yet_with_user, 'View', position: 1)share_modal.expect_shared_count_of(6)# Removing a share will lead to that user being removed from the list of shared with users.share_modal.remove_user(edit_user)-share_modal.expect_not_shared_with(edit_user)-share_modal.expect_shared_count_of(5)# Adding a user multiple times will lead to the user's role being updated.share_modal.invite_user(not_shared_yet_with_user, 'Edit')-- share_modal.expect_shared_with(not_shared_yet_with_user, 'Edit')+ share_modal.expect_shared_with(not_shared_yet_with_user, 'Edit', position: 1)# Sent out email only on first share and not again when updating.perform_enqueued_jobs@@ -120,8 +116,7 @@ RSpec.describe 'Work package sharing',# Updating the shareshare_modal.change_role(not_shared_yet_with_user, 'Comment')-- share_modal.expect_shared_with(not_shared_yet_with_user, 'Comment')+ share_modal.expect_shared_with(not_shared_yet_with_user, 'Comment', position: 1)# Sent out email only on first share and not again when updating so the# count should still be 1.@@ -134,15 +129,15 @@ RSpec.describe 'Work package sharing',click_button 'Share'# These users were not changed- share_modal.expect_shared_with(view_user, 'View')- share_modal.expect_shared_with(comment_user, 'Comment')- share_modal.expect_shared_with(shared_project_user, 'Edit')- share_modal.expect_shared_with(current_user, editable: false)+ share_modal.expect_shared_with(comment_user, 'Comment', position: 1)# This user's role was updated- share_modal.expect_shared_with(not_shared_yet_with_user, 'Comment')+ share_modal.expect_shared_with(not_shared_yet_with_user, 'Comment', position: 2)+ share_modal.expect_shared_with(shared_project_user, 'Edit', position: 3)+ share_modal.expect_shared_with(current_user, position: 4, editable: false)+ share_modal.expect_shared_with(view_user, 'View', position: 5)+# This user's share was revokedshare_modal.expect_not_shared_with(edit_user)-# This user has never been addedshare_modal.expect_not_shared_with(non_shared_project_user)diff --git a/spec/support/components/work_packages/share_modal.rb b/spec/support/components/work_packages/share_modal.rbindex 48c063a547d..8eb49db7e4d 100644--- a/spec/support/components/work_packages/share_modal.rb+++ b/spec/support/components/work_packages/share_modal.rb@@ -82,12 +82,20 @@ module Componentsmodal_element.send_keys(:escape)end- def expect_shared_with(user, role_name = nil, editable: true)- within active_list do+ def expect_shared_with(user, role_name = nil, position: nil, editable: true)+ within shares_list doexpect(page).to have_text(user.name)end+ if position+ within shares_list do+ expect(page)+ .to have_selector("li:nth-child(#{position})", text: user.name),+ "Expected #{user.name} to be ##{position} on the shares list."+ end+ end+if role_namewithin user_row(user) doexpect(page)@@ -104,7 +112,7 @@ module Componentsenddef expect_not_shared_with(user)- within active_list do+ within shares_list doexpect(page).not_to have_text(user.name)end@@ -131,6 +139,10 @@ module Componentsmodal_element.find('[data-test-selector="op-share-wp-active-list"]')end++ def shares_list+ active_list.find_by_id('op-share-wp-active-shares')+ endendendend