diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-07-12 15:11:02 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-07-12 15:11:02 +0300 |
commit | 3d6dddf134ebb82f2a9894cad738c84ff9d6e723 (patch) | |
tree | 64e9b716ec79c086c10ef88f36daac05abb75437 /spec/features | |
parent | 447c1bba679be70f9c311326ca03923c6988f127 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/features')
-rw-r--r-- | spec/features/projects/issues/design_management/user_views_design_spec.rb | 71 | ||||
-rw-r--r-- | spec/features/projects/work_items/work_item_spec.rb | 2 |
2 files changed, 72 insertions, 1 deletions
diff --git a/spec/features/projects/issues/design_management/user_views_design_spec.rb b/spec/features/projects/issues/design_management/user_views_design_spec.rb index 268c209cba1..bd9d1092e17 100644 --- a/spec/features/projects/issues/design_management/user_views_design_spec.rb +++ b/spec/features/projects/issues/design_management/user_views_design_spec.rb @@ -5,16 +5,67 @@ require 'spec_helper' RSpec.describe 'User views issue designs', :js, feature_category: :design_management do include DesignManagementTestHelpers + let_it_be(:user) { create(:user) } + let_it_be(:guest_user) { create(:user) } let_it_be(:project) { create(:project_empty_repo, :public) } let_it_be(:issue) { create(:issue, project: project) } let_it_be(:design) { create(:design, :with_file, issue: issue) } + let_it_be(:note) { create(:diff_note_on_design, noteable: design, author: user) } + + def add_diff_note_emoji(diff_note, emoji_name) + page.within(first(".image-notes li#note_#{diff_note.id}.design-note")) do + page.find('[data-testid="note-emoji-button"] .note-emoji-button').click + + page.within('ul.dropdown-menu') do + page.find('input[type="search"]').set(emoji_name) + page.find('button[data-testid="emoji-button"]:first-child').click + end + end + end + + def remove_diff_note_emoji(diff_note, emoji_name) + page.within(first(".image-notes li#note_#{diff_note.id}.design-note")) do + page.find(".awards button[data-emoji-name='#{emoji_name}']").click + end + end + + before_all do + project.add_maintainer(user) + project.add_guest(guest_user) + end before do enable_design_management + sign_in(user) + visit project_issue_path(project, issue) end + shared_examples 'design discussion emoji awards' do + it 'allows user to add emoji reaction to a comment' do + click_link design.filename + + add_diff_note_emoji(note, 'thumbsup') + + expect(page.find("li#note_#{note.id} .awards")).to have_selector('button[title="You reacted with :thumbsup:"]') + end + + it 'allows user to remove emoji reaction from a comment' do + click_link design.filename + + add_diff_note_emoji(note, 'thumbsup') + + # Wait for emoji to be added + wait_for_requests + + remove_diff_note_emoji(note, 'thumbsup') + + # Only award emoji that was present has been removed + expect(page.find("li#note_#{note.id}")).not_to have_selector('.awards') + end + end + it 'opens design detail' do click_link design.filename @@ -25,6 +76,26 @@ RSpec.describe 'User views issue designs', :js, feature_category: :design_manage expect(page).to have_selector('.js-design-image') end + it 'shows a comment within design' do + click_link design.filename + + expect(page.find('.image-notes .design-note .note-text')).to have_content(note.note) + end + + it_behaves_like 'design discussion emoji awards' + + context 'when user is guest' do + before do + enable_design_management + + sign_in(guest_user) + + visit project_issue_path(project, issue) + end + + it_behaves_like 'design discussion emoji awards' + end + context 'when svg file is loaded in design detail' do let_it_be(:file) { Rails.root.join('spec/fixtures/svg_without_attr.svg') } let_it_be(:design) { create(:design, :with_file, filename: 'svg_without_attr.svg', file: file, issue: issue) } diff --git a/spec/features/projects/work_items/work_item_spec.rb b/spec/features/projects/work_items/work_item_spec.rb index 1aa9ae3ac3f..e996a76b1c5 100644 --- a/spec/features/projects/work_items/work_item_spec.rb +++ b/spec/features/projects/work_items/work_item_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe 'Work item', :js, feature_category: :team_planning, quarantine: 'https://gitlab.com/gitlab-org/gitlab/-/issues/416663' do +RSpec.describe 'Work item', :js, feature_category: :team_planning do let_it_be_with_reload(:user) { create(:user) } let_it_be_with_reload(:user2) { create(:user, name: 'John') } |