Commit 66a6dfbc authored by Luke Bennett's avatar Luke Bennett

Added 'with an unfolded line should not allow commenting' scenario (line 125)

parent 7d654c0e
...@@ -17,6 +17,7 @@ feature 'Diff notes', js: true, feature: true do ...@@ -17,6 +17,7 @@ feature 'Diff notes', js: true, feature: true do
context 'when hovering over the parallel view diff file' do context 'when hovering over the parallel view diff file' do
before(:each) do before(:each) do
<<<<<<< 7d654c0e1810f2023a1deaeddd542c5c92d20f42
visit diffs_namespace_project_merge_request_path(@project.namespace, @project, @merge_request, view: 'parallel') visit diffs_namespace_project_merge_request_path(@project.namespace, @project, @merge_request, view: 'parallel')
end end
...@@ -27,51 +28,111 @@ feature 'Diff notes', js: true, feature: true do ...@@ -27,51 +28,111 @@ feature 'Diff notes', js: true, feature: true do
it 'should not allow commenting on the right side' do it 'should not allow commenting on the right side' do
should_not_allow_commenting(find('[id="6eb14e00385d2fb284765eb1cd8d420d33d63fc9_23_22"]').find(:xpath, '..'), 'right') should_not_allow_commenting(find('[id="6eb14e00385d2fb284765eb1cd8d420d33d63fc9_23_22"]').find(:xpath, '..'), 'right')
=======
visit diffs_namespace_project_merge_request_path(@project.namespace, @project, @merge_request)
click_link 'Side-by-side'
end
context 'with an old line on the left and no line on the right' do
let(:line_holder) { find('[id="6eb14e00385d2fb284765eb1cd8d420d33d63fc9_23_22"]').find(:xpath, '..') }
it 'should allow commenting on the left side' do
should_allow_commenting line_holder, 'left'
end
it 'should not allow commenting on the right side' do
should_not_allow_commenting line_holder, 'right'
>>>>>>> Added 'with an unfolded line should not allow commenting' scenario (line 125)
end end
end end
context 'with no line on the left and a new line on the right' do context 'with no line on the left and a new line on the right' do
<<<<<<< 7d654c0e1810f2023a1deaeddd542c5c92d20f42
it 'should not allow commenting on the left side' do it 'should not allow commenting on the left side' do
should_not_allow_commenting(find('[id="2f6fcd96b88b36ce98c38da085c795a27d92a3dd_15_15"]').find(:xpath, '..'), 'left') should_not_allow_commenting(find('[id="2f6fcd96b88b36ce98c38da085c795a27d92a3dd_15_15"]').find(:xpath, '..'), 'left')
end end
it 'should allow commenting on the right side' do it 'should allow commenting on the right side' do
should_allow_commenting(find('[id="2f6fcd96b88b36ce98c38da085c795a27d92a3dd_15_15"]').find(:xpath, '..'), 'right') should_allow_commenting(find('[id="2f6fcd96b88b36ce98c38da085c795a27d92a3dd_15_15"]').find(:xpath, '..'), 'right')
=======
let(:line_holder) { find('[id="2f6fcd96b88b36ce98c38da085c795a27d92a3dd_15_15"]').find(:xpath, '..') }
it 'should not allow commenting on the left side' do
should_not_allow_commenting line_holder, 'left'
end
it 'should allow commenting on the right side' do
should_allow_commenting line_holder, 'right'
>>>>>>> Added 'with an unfolded line should not allow commenting' scenario (line 125)
end end
end end
context 'with an old line on the left and a new line on the right' do context 'with an old line on the left and a new line on the right' do
<<<<<<< 7d654c0e1810f2023a1deaeddd542c5c92d20f42
it 'should allow commenting on the left side' do it 'should allow commenting on the left side' do
should_allow_commenting(find('[id="2f6fcd96b88b36ce98c38da085c795a27d92a3dd_9_9"]').find(:xpath, '..'), 'left') should_allow_commenting(find('[id="2f6fcd96b88b36ce98c38da085c795a27d92a3dd_9_9"]').find(:xpath, '..'), 'left')
end end
it 'should allow commenting on the right side' do it 'should allow commenting on the right side' do
should_allow_commenting(find('[id="2f6fcd96b88b36ce98c38da085c795a27d92a3dd_9_9"]').find(:xpath, '..'), 'right') should_allow_commenting(find('[id="2f6fcd96b88b36ce98c38da085c795a27d92a3dd_9_9"]').find(:xpath, '..'), 'right')
=======
let(:line_holder) { find('[id="2f6fcd96b88b36ce98c38da085c795a27d92a3dd_9_9"]').find(:xpath, '..') }
it 'should allow commenting on the left side' do
should_allow_commenting line_holder, 'left'
end
it 'should allow commenting on the right side' do
should_allow_commenting line_holder, 'right'
>>>>>>> Added 'with an unfolded line should not allow commenting' scenario (line 125)
end end
end end
context 'with an unchanged line on the left and an unchanged line on the right' do context 'with an unchanged line on the left and an unchanged line on the right' do
<<<<<<< 7d654c0e1810f2023a1deaeddd542c5c92d20f42
it 'should allow commenting on the left side' do it 'should allow commenting on the left side' do
should_allow_commenting(find('[id="2f6fcd96b88b36ce98c38da085c795a27d92a3dd_7_7"]', match: :first).find(:xpath, '..'), 'left') should_allow_commenting(find('[id="2f6fcd96b88b36ce98c38da085c795a27d92a3dd_7_7"]', match: :first).find(:xpath, '..'), 'left')
end end
it 'should allow commenting on the right side' do it 'should allow commenting on the right side' do
should_allow_commenting(find('[id="2f6fcd96b88b36ce98c38da085c795a27d92a3dd_7_7"]', match: :first).find(:xpath, '..'), 'right') should_allow_commenting(find('[id="2f6fcd96b88b36ce98c38da085c795a27d92a3dd_7_7"]', match: :first).find(:xpath, '..'), 'right')
=======
let(:line_holder) { first('[id="2f6fcd96b88b36ce98c38da085c795a27d92a3dd_7_7"]').find(:xpath, '..') }
it 'should allow commenting on the left side' do
should_allow_commenting line_holder, 'left'
end
it 'should allow commenting on the right side' do
should_allow_commenting line_holder, 'right'
>>>>>>> Added 'with an unfolded line should not allow commenting' scenario (line 125)
end end
end end
context 'with a match line' do context 'with a match line' do
<<<<<<< 7d654c0e1810f2023a1deaeddd542c5c92d20f42
it 'should not allow commenting on the left side' do it 'should not allow commenting on the left side' do
should_not_allow_commenting(find('.match', match: :first).find(:xpath, '..'), 'left') should_not_allow_commenting(find('.match', match: :first).find(:xpath, '..'), 'left')
end end
it 'should not allow commenting on the right side' do it 'should not allow commenting on the right side' do
should_not_allow_commenting(find('.match', match: :first).find(:xpath, '..'), 'right') should_not_allow_commenting(find('.match', match: :first).find(:xpath, '..'), 'right')
=======
let(:line_holder) { first('.match').find(:xpath, '..') }
it 'should not allow commenting on the left side' do
should_not_allow_commenting line_holder, 'left'
end
it 'should not allow commenting on the right side' do
should_not_allow_commenting line_holder, 'right'
>>>>>>> Added 'with an unfolded line should not allow commenting' scenario (line 125)
end end
end end
end end
context 'when hovering over the inline view diff file' do context 'when hovering over the inline view diff file' do
<<<<<<< 7d654c0e1810f2023a1deaeddd542c5c92d20f42
before do before do
visit diffs_namespace_project_merge_request_path(@project.namespace, @project, @merge_request, view: 'inline') visit diffs_namespace_project_merge_request_path(@project.namespace, @project, @merge_request, view: 'inline')
end end
...@@ -79,29 +140,80 @@ feature 'Diff notes', js: true, feature: true do ...@@ -79,29 +140,80 @@ feature 'Diff notes', js: true, feature: true do
context 'with a new line' do context 'with a new line' do
it 'should allow commenting' do it 'should allow commenting' do
should_allow_commenting(find('[id="2f6fcd96b88b36ce98c38da085c795a27d92a3dd_10_9"]')) should_allow_commenting(find('[id="2f6fcd96b88b36ce98c38da085c795a27d92a3dd_10_9"]'))
=======
let(:comment_button_class) { '.add-diff-note' }
before(:each) do
visit diffs_namespace_project_merge_request_path(@project.namespace, @project, @merge_request)
click_link 'Inline'
end
context 'with a new line' do
let(:line_holder) { find('[id="2f6fcd96b88b36ce98c38da085c795a27d92a3dd_10_9"]') }
it 'should allow commenting' do
should_allow_commenting line_holder
>>>>>>> Added 'with an unfolded line should not allow commenting' scenario (line 125)
end end
end end
context 'with an old line' do context 'with an old line' do
<<<<<<< 7d654c0e1810f2023a1deaeddd542c5c92d20f42
it 'should allow commenting' do it 'should allow commenting' do
should_allow_commenting(find('[id="6eb14e00385d2fb284765eb1cd8d420d33d63fc9_22_22"]')) should_allow_commenting(find('[id="6eb14e00385d2fb284765eb1cd8d420d33d63fc9_22_22"]'))
=======
let(:line_holder) { find('[id="6eb14e00385d2fb284765eb1cd8d420d33d63fc9_22_22"]') }
it 'should allow commenting' do
should_allow_commenting line_holder
>>>>>>> Added 'with an unfolded line should not allow commenting' scenario (line 125)
end end
end end
context 'with an unchanged line' do context 'with an unchanged line' do
<<<<<<< 7d654c0e1810f2023a1deaeddd542c5c92d20f42
it 'should allow commenting' do it 'should allow commenting' do
should_allow_commenting(find('[id="2f6fcd96b88b36ce98c38da085c795a27d92a3dd_7_7"]')) should_allow_commenting(find('[id="2f6fcd96b88b36ce98c38da085c795a27d92a3dd_7_7"]'))
=======
let(:line_holder) { find('[id="2f6fcd96b88b36ce98c38da085c795a27d92a3dd_7_7"]') }
it 'should allow commenting' do
should_allow_commenting line_holder
>>>>>>> Added 'with an unfolded line should not allow commenting' scenario (line 125)
end end
end end
context 'with a match line' do context 'with a match line' do
<<<<<<< 7d654c0e1810f2023a1deaeddd542c5c92d20f42
it 'should not allow commenting' do it 'should not allow commenting' do
should_not_allow_commenting(find('.match', match: :first)) should_not_allow_commenting(find('.match', match: :first))
=======
let(:line_holder) { first('.match') }
it 'should not allow commenting' do
should_not_allow_commenting line_holder
end
end
context 'with an unfolded line' do
before(:each) do
first('.js-unfold').click
wait_for_ajax
end
# The first `.js-unfold` unfolds upwards, therefore the first
# `.line_holder` will be an unfolded line.
let(:line_holder) { first('.line_holder[id="1"]') }
it 'should not allow commenting' do
should_not_allow_commenting line_holder
>>>>>>> Added 'with an unfolded line should not allow commenting' scenario (line 125)
end end
end end
end end
def should_allow_commenting(line_holder, diff_side = nil) def should_allow_commenting(line_holder, diff_side = nil)
<<<<<<< 7d654c0e1810f2023a1deaeddd542c5c92d20f42
line = get_line_components(line_holder, diff_side) line = get_line_components(line_holder, diff_side)
line[:content].hover line[:content].hover
expect(line[:num]).to have_css comment_button_class expect(line[:num]).to have_css comment_button_class
...@@ -113,33 +225,61 @@ feature 'Diff notes', js: true, feature: true do ...@@ -113,33 +225,61 @@ feature 'Diff notes', js: true, feature: true do
def should_not_allow_commenting(line_holder, diff_side = nil) def should_not_allow_commenting(line_holder, diff_side = nil)
line = get_line_components(line_holder, diff_side) line = get_line_components(line_holder, diff_side)
=======
line = get_line_components line_holder, diff_side
line[:content].hover
expect(line[:num]).to have_css comment_button_class
comment_on_line line_holder, line
wait_for_ajax
assert_comment_persistence line_holder
end
def should_not_allow_commenting(line_holder, diff_side = nil)
line = get_line_components line_holder, diff_side
>>>>>>> Added 'with an unfolded line should not allow commenting' scenario (line 125)
line[:content].hover line[:content].hover
expect(line[:num]).not_to have_css comment_button_class expect(line[:num]).not_to have_css comment_button_class
end end
def get_line_components(line_holder, diff_side = nil) def get_line_components(line_holder, diff_side = nil)
if diff_side.nil? if diff_side.nil?
<<<<<<< 7d654c0e1810f2023a1deaeddd542c5c92d20f42
get_inline_line_components(line_holder) get_inline_line_components(line_holder)
else else
get_parallel_line_components(line_holder, diff_side) get_parallel_line_components(line_holder, diff_side)
=======
get_inline_line_components line_holder
else
get_parallel_line_components line_holder, diff_side
>>>>>>> Added 'with an unfolded line should not allow commenting' scenario (line 125)
end end
end end
def get_inline_line_components(line_holder) def get_inline_line_components(line_holder)
<<<<<<< 7d654c0e1810f2023a1deaeddd542c5c92d20f42
{ content: line_holder.find('.line_content', match: :first), num: line_holder.find('.diff-line-num', match: :first) } { content: line_holder.find('.line_content', match: :first), num: line_holder.find('.diff-line-num', match: :first) }
=======
{ content: line_holder.first('.line_content'), num: line_holder.first('.diff-line-num') }
>>>>>>> Added 'with an unfolded line should not allow commenting' scenario (line 125)
end end
def get_parallel_line_components(line_holder, diff_side = nil) def get_parallel_line_components(line_holder, diff_side = nil)
side_index = diff_side == 'left' ? 0 : 1 side_index = diff_side == 'left' ? 0 : 1
<<<<<<< 7d654c0e1810f2023a1deaeddd542c5c92d20f42
# Wait for `.line_content` # Wait for `.line_content`
line_holder.find('.line_content', match: :first) line_holder.find('.line_content', match: :first)
# Wait for `.diff-line-num` # Wait for `.diff-line-num`
line_holder.find('.diff-line-num', match: :first) line_holder.find('.diff-line-num', match: :first)
=======
>>>>>>> Added 'with an unfolded line should not allow commenting' scenario (line 125)
{ content: line_holder.all('.line_content')[side_index], num: line_holder.all('.diff-line-num')[side_index] } { content: line_holder.all('.line_content')[side_index], num: line_holder.all('.diff-line-num')[side_index] }
end end
def comment_on_line(line_holder, line) def comment_on_line(line_holder, line)
line[:num].find(comment_button_class).trigger 'click' line[:num].find(comment_button_class).trigger 'click'
<<<<<<< 7d654c0e1810f2023a1deaeddd542c5c92d20f42
line_holder.find(:xpath, notes_holder_input_xpath) line_holder.find(:xpath, notes_holder_input_xpath)
notes_holder_input = line_holder.find(:xpath, notes_holder_input_xpath) notes_holder_input = line_holder.find(:xpath, notes_holder_input_xpath)
...@@ -148,13 +288,26 @@ feature 'Diff notes', js: true, feature: true do ...@@ -148,13 +288,26 @@ feature 'Diff notes', js: true, feature: true do
notes_holder_input.fill_in 'note[note]', with: test_note_comment notes_holder_input.fill_in 'note[note]', with: test_note_comment
click_button 'Comment' click_button 'Comment'
wait_for_ajax wait_for_ajax
=======
expect(line_holder).to have_xpath notes_holder_input_xpath
notes_holder_input = line_holder.find(:xpath, notes_holder_input_xpath)
expect(notes_holder_input[:class].include? notes_holder_input_class).to be true
notes_holder_input.fill_in 'note[note]', with: test_note_comment
click_button 'Comment'
>>>>>>> Added 'with an unfolded line should not allow commenting' scenario (line 125)
end end
def assert_comment_persistence(line_holder) def assert_comment_persistence(line_holder)
expect(line_holder).to have_xpath notes_holder_input_xpath expect(line_holder).to have_xpath notes_holder_input_xpath
notes_holder_saved = line_holder.find(:xpath, notes_holder_input_xpath) notes_holder_saved = line_holder.find(:xpath, notes_holder_input_xpath)
<<<<<<< 7d654c0e1810f2023a1deaeddd542c5c92d20f42
expect(notes_holder_saved[:class]).not_to include(notes_holder_input_class) expect(notes_holder_saved[:class]).not_to include(notes_holder_input_class)
=======
expect(notes_holder_saved[:class].include? notes_holder_input_class).to be false
>>>>>>> Added 'with an unfolded line should not allow commenting' scenario (line 125)
expect(notes_holder_saved).to have_content test_note_comment expect(notes_holder_saved).to have_content test_note_comment
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment