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

Extend mentions_spec to cover mentioning users a work package is shared with

Aaron Contrerasa31ebab9e67e
diff --git a/spec/features/wysiwyg/mentions_spec.rb b/spec/features/wysiwyg/mentions_spec.rb
index 9f8be79997e..89ad1195242 100644
--- a/spec/features/wysiwyg/mentions_spec.rb
+++ b/spec/features/wysiwyg/mentions_spec.rb
@@ -39,6 +39,23 @@ RSpec.describe 'Wysiwyg work package mentions',
create(:user, firstname: 'Foo', lastname: 'Bar',
member_with_permissions: { project => %i[view_work_packages edit_work_packages] })
end
+ let!(:edit_work_package_role) { create(:edit_work_package_role) }
+ let!(:comment_work_package_role) { create(:comment_work_package_role) }
+ let!(:view_work_package_role) { create(:view_work_package_role) }
+
+ let!(:work_package_editor) do
+ create(:user, firstname: 'Bertram', lastname: 'Gilfoyle',
+ member_with_roles: { work_package => edit_work_package_role })
+ end
+ let!(:work_package_commenter) do
+ create(:user, firstname: 'Dinesh', lastname: 'Chugtai',
+ member_with_roles: { work_package => comment_work_package_role })
+ end
+ let!(:work_package_viewer) do
+ create(:user, firstname: 'Richard', lastname: 'Hendricks',
+ member_with_roles: { work_package => view_work_package_role })
+ end
+
let!(:group) { create(:group, firstname: 'Foogroup', lastname: 'Foogroup') }
let!(:group_role) { create(:project_role) }
let!(:group_member) do
@@ -77,58 +94,97 @@ RSpec.describe 'Wysiwyg work package mentions',
comment_field.clear with_backspace: true
comment_field.input_element.send_keys("@Foo")
- expect(page).to have_selector('.mention-list-item', text: user2.name)
- expect(page).to have_selector('.mention-list-item', text: group.name)
+ expect(page).to have_css('.mention-list-item', text: user2.name)
+ expect(page).to have_css('.mention-list-item', text: group.name)
page.find('.mention-list-item', text: user2.name).click
expect(page)
- .to have_selector('a.mention', text: '@Foo Bar')
+ .to have_css('a.mention', text: '@Foo Bar')
comment_field.submit_by_click if comment_field.active?
wp_page.expect_and_dismiss_toaster message: "The comment was successfully added."
expect(page)
- .to have_selector('a.user-mention', text: 'Foo Bar')
+ .to have_css('a.user-mention', text: 'Foo Bar')
# Mentioning myself works
comment_field.activate!
comment_field.clear with_backspace: true
comment_field.input_element.send_keys("@MeMyself")
- expect(page).to have_selector('.mention-list-item', text: user.name)
+ expect(page).to have_css('.mention-list-item', text: user.name)
page.find('.mention-list-item', text: user.name).click
expect(page)
- .to have_selector('a.mention', text: '@MeMyself AndI')
+ .to have_css('a.mention', text: '@MeMyself AndI')
comment_field.submit_by_click if comment_field.active?
wp_page.expect_and_dismiss_toaster message: "The comment was successfully added."
expect(page)
- .to have_selector('a.user-mention', text: 'MeMyself AndI')
+ .to have_css('a.user-mention', text: 'MeMyself AndI')
+
+ # Mentioning a work package editor or commenter works
+ #
+ # Editor
+ #
+ comment_field.activate!
+ comment_field.clear(with_backspace: true)
+ comment_field.input_element.send_keys("@Bertram Gilfoyle")
+ page.find(".mention-list-item", text: work_package_editor.name).click
+ expect(page)
+ .to have_css('a.mention', text: "@Bertram Gilfoyle")
+ comment_field.submit_by_click if comment_field.active?
+ wp_page.expect_and_dismiss_toaster message: "The comment was successfully added."
+
+ expect(page)
+ .to have_css('a.user-mention', text: 'Bertram Gilfoyle')
+ #
+ # Commenter
+ #
+ comment_field.activate!
+ comment_field.clear(with_backspace: true)
+ comment_field.input_element.send_keys("@Dinesh Chugtai")
+ page.find(".mention-list-item", text: work_package_commenter.name).click
+ expect(page)
+ .to have_css('a.mention', text: "@Dinesh Chugtai")
+ comment_field.submit_by_click if comment_field.active?
+ wp_page.expect_and_dismiss_toaster message: "The comment was successfully added."
+
+ expect(page)
+ .to have_css('a.user-mention', text: 'Dinesh Chugtai')
+
+ # Work Package viewers aren't mentionable
+ comment_field.activate!
+ comment_field.clear(with_backspace: true)
+ comment_field.input_element.send_keys("@Richard Hendricks")
+ page.driver.wait_for_reload
+ expect(page)
+ .not_to have_css(".mention-list-item", text: work_package_viewer.name)
+ comment_field.cancel_by_click
# Mentioning a group works
comment_field.activate!
comment_field.clear with_backspace: true
comment_field.input_element.send_keys(" @Foo")
- expect(page).to have_selector('.mention-list-item', text: user2.name)
- expect(page).to have_selector('.mention-list-item', text: group.name)
+ expect(page).to have_css('.mention-list-item', text: user2.name)
+ expect(page).to have_css('.mention-list-item', text: group.name)
page.find('.mention-list-item', text: group.name).click
expect(page)
- .to have_selector('a.mention', text: '@Foogroup')
+ .to have_css('a.mention', text: '@Foogroup')
comment_field.submit_by_click if comment_field.active?
wp_page.expect_and_dismiss_toaster message: "The comment was successfully added."
expect(page)
- .to have_selector('a.user-mention', text: 'Foogroup')
+ .to have_css('a.user-mention', text: 'Foogroup')
# The mention is still displayed as such when reentering the comment field
find('#activity-1 .op-user-activity')
@@ -139,17 +195,17 @@ RSpec.describe 'Wysiwyg work package mentions',
end
expect(page)
- .to have_selector('a.mention', text: '@Foo Bar')
+ .to have_css('a.mention', text: '@Foo Bar')
# Mentioning an emoji works
comment_field.activate!
comment_field.clear with_backspace: true
comment_field.input_element.send_keys(":thumbs")
- expect(page).to have_selector('.mention-list-item', text: '👍 thumbs_up')
- expect(page).to have_selector('.mention-list-item', text: '👎 thumbs_down')
+ expect(page).to have_css('.mention-list-item', text: '👍 thumbs_up')
+ expect(page).to have_css('.mention-list-item', text: '👎 thumbs_down')
page.find('.mention-list-item', text: '👍 thumbs_up').click
- expect(page).to have_selector('span', text: '👍')
+ expect(page).to have_css('span', text: '👍')
end
end