Skip to content
Snippets Groups Projects

Users can apply multiple suggestions at once.

Merged Jesse Hall requested to merge jessehall3/gitlab-ee:25486-batch-suggestions into master
1 file
+ 71
0
Compare changes
  • Side-by-side
  • Inline
@@ -93,6 +93,100 @@ describe 'User comments on a diff', :js do
end
end
context 'applying suggestions in batches' do
def hash(path)
diff_file = merge_request.diffs(paths: [path]).diff_files.first
Digest::SHA1.hexdigest(diff_file.file_path)
end
file1 = 'files/ruby/popen.rb'
file2 = 'files/ruby/regex.rb'
let(:files) do
[
{
hash: hash(file1),
line_code: "#{hash(file1)}_12_12"
},
{
hash: hash(file2),
line_code: "#{hash(file2)}_21_21"
}
]
end
it 'can add and remove suggestions from a batch' do
files.each_with_index do |file, index|
page.within("[id='#{file[:hash]}']") do
find("button[title='Show full file']").click
wait_for_requests
click_diff_line(find("[id='#{file[:line_code]}']"))
page.within('.js-discussion-note-form') do
fill_in('note_note', with: "```suggestion\n# change to a comment\n```")
click_button('Add comment now')
wait_for_requests
end
end
page.within("[id='#{file[:hash]}']") do
expect(page).not_to have_content('Applied')
click_button('Add suggestion to batch')
wait_for_requests
expect(page).to have_content('Remove from batch')
expect(page).to have_content("Apply suggestions #{index + 1}")
end
end
page.within("[id='#{files[0][:hash]}']") do
click_button('Remove from batch')
wait_for_requests
expect(page).to have_content('Apply suggestion')
expect(page).to have_content('Add suggestion to batch')
end
page.within("[id='#{files[1][:hash]}']") do
expect(page).to have_content('Remove from batch')
expect(page).to have_content('Apply suggestions 1')
end
end
it 'can apply multiple suggestions as a batch' do
files.each_with_index do |file, index|
page.within("[id='#{file[:hash]}']") do
find("button[title='Show full file']").click
wait_for_requests
click_diff_line(find("[id='#{file[:line_code]}']"))
page.within('.js-discussion-note-form') do
fill_in('note_note', with: "```suggestion\n# change to a comment\n```")
click_button('Add comment now')
wait_for_requests
end
end
page.within("[id='#{file[:hash]}']") do
click_button('Add suggestion to batch')
wait_for_requests
end
end
expect(page).not_to have_content('Applied')
page.within("[id='#{files[0][:hash]}']") do
click_button('Apply suggestions 2')
wait_for_requests
end
expect(page).to have_content('Applied').twice
end
end
context 'multiple suggestions in expanded lines' do
# https://gitlab.com/gitlab-org/gitlab/issues/38277
it 'suggestions are appliable', :quarantine do
Loading