diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-07-20 15:26:25 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-07-20 15:26:25 +0300 |
commit | a09983ae35713f5a2bbb100981116d31ce99826e (patch) | |
tree | 2ee2af7bd104d57086db360a7e6d8c9d5d43667a /spec/features/merge_request/user_comments_on_diff_spec.rb | |
parent | 18c5ab32b738c0b6ecb4d0df3994000482f34bd8 (diff) |
Add latest changes from gitlab-org/gitlab@13-2-stable-ee
Diffstat (limited to 'spec/features/merge_request/user_comments_on_diff_spec.rb')
-rw-r--r-- | spec/features/merge_request/user_comments_on_diff_spec.rb | 53 |
1 files changed, 51 insertions, 2 deletions
diff --git a/spec/features/merge_request/user_comments_on_diff_spec.rb b/spec/features/merge_request/user_comments_on_diff_spec.rb index 9cd3c7eaf76..30bf82e3665 100644 --- a/spec/features/merge_request/user_comments_on_diff_spec.rb +++ b/spec/features/merge_request/user_comments_on_diff_spec.rb @@ -117,9 +117,58 @@ RSpec.describe 'User comments on a diff', :js do context 'when adding multiline comments' do it 'saves a multiline comment' do click_diff_line(find("[id='#{sample_commit.line_code}']")) + add_comment('-13', '+14') + end + + context 'when in side-by-side view' do + before do + visit(diffs_project_merge_request_path(project, merge_request, view: 'parallel')) + end + + # In `files/ruby/popen.rb` + it 'allows comments for changes involving both sides' do + # click +15, select -13 add and verify comment + click_diff_line(find('div[data-path="files/ruby/popen.rb"] .new_line a[data-linenumber="15"]').find(:xpath, '../..'), 'right') + add_comment('-13', '+15') + end + + it 'allows comments to start above hidden lines and end below' do + # click +28, select 21 add and verify comment + click_diff_line(find('div[data-path="files/ruby/popen.rb"] .new_line a[data-linenumber="28"]').find(:xpath, '../..'), 'right') + add_comment('21', '+28') + end + + it 'allows comments on previously hidden lines at the top of a file' do + # Click -9, expand up, select 1 add and verify comment + page.within('[data-path="files/ruby/popen.rb"]') do + all('.js-unfold-all')[0].click + end + click_diff_line(find('div[data-path="files/ruby/popen.rb"] .old_line a[data-linenumber="9"]').find(:xpath, '../..'), 'left') + add_comment('1', '-9') + end + + it 'allows comments on previously hidden lines the middle of a file' do + # Click 27, expand up, select 18, add and verify comment + page.within('[data-path="files/ruby/popen.rb"]') do + all('.js-unfold-all')[1].click + end + click_diff_line(find('div[data-path="files/ruby/popen.rb"] .old_line a[data-linenumber="21"]').find(:xpath, '../..'), 'left') + add_comment('18', '21') + end + + it 'allows comments on previously hidden lines at the bottom of a file' do + # Click +28, expand down, select 37 add and verify comment + page.within('[data-path="files/ruby/popen.rb"]') do + all('.js-unfold-down')[1].click + end + click_diff_line(find('div[data-path="files/ruby/popen.rb"] .old_line a[data-linenumber="30"]').find(:xpath, '../..'), 'left') + add_comment('+28', '37') + end + end + def add_comment(start_line, end_line) page.within('.discussion-form') do - find('#comment-line-start option', text: '-13').select_option + find('#comment-line-start option', exact_text: start_line).select_option end page.within('.js-discussion-note-form') do @@ -131,7 +180,7 @@ RSpec.describe 'User comments on a diff', :js do page.within('.notes_holder') do expect(page).to have_content('Line is wrong') - expect(page).to have_content('Comment on lines -13 to +14') + expect(page).to have_content("Comment on lines #{start_line} to #{end_line}") end visit(merge_request_path(merge_request)) |