summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Bennett <lukeeeebennettplus@gmail.com>2016-07-25 04:34:49 +0100
committerLuke Bennett <lukeeeebennettplus@gmail.com>2016-07-25 04:40:09 +0100
commitef5a5d0ba30709f4e146ee31441d092759c32911 (patch)
treed79cdd1406b259f69fbb28a1224fa11c76cecd08
parent59ddf726a6866483c4ec9beaf27423206e3ed3e9 (diff)
downloadgitlab-ce-ef5a5d0ba30709f4e146ee31441d092759c32911.tar.gz
Tidying up spec for new implementation of css ID selectors
-rw-r--r--spec/features/merge_requests/diffs_spec.rb60
1 files changed, 38 insertions, 22 deletions
diff --git a/spec/features/merge_requests/diffs_spec.rb b/spec/features/merge_requests/diffs_spec.rb
index dbc50ea5265..f5e8677561f 100644
--- a/spec/features/merge_requests/diffs_spec.rb
+++ b/spec/features/merge_requests/diffs_spec.rb
@@ -30,12 +30,12 @@ feature 'Diffs URL', js: true, feature: true do
let(:notes_holder_input_class) { 'js-temp-notes-holder' }
let(:notes_holder_input_xpath) { './following-sibling::*[contains(concat(" ", @class, " "), " notes_holder ")]' }
let(:test_note_comment) { 'this is a test note!' }
- # line_holder = //*[contains(concat(" ", @class, " "), " line_holder "]
- # old_line = child::*[contains(concat(" ", @class, " "), " line_content ") and contains(concat(" ", @class, " "), " old ")]
- # new_line = child::*[contains(concat(" ", @class, " ")," line_content ") and contains(concat(" ", @class, " ")," new ")]
- # match_line = child::*[contains(concat(" ", @class, " ")," line_content ") and contains(concat(" ", @class, " ")," match ")]
- # unchanged_line = child::*[contains(concat(" ", @class, " ")," line_content ") and not(contains(concat(" ", @class, " ")," old ")) and not(contains(concat(" ", @class, " ")," new ")) and not(contains(concat(" ", @class, " ")," match ")) and boolean(node()[1])]
- # no_line = child::*[contains(concat(" ", @class, " ")," line_content ") and not(contains(concat(" ", @class, " ")," old ")) and not(contains(concat(" ", @class, " ")," new ")) and not(contains(concat(" ", @class, " ")," match ")) and not(boolean(node()[1]))]
+ # line_holder =
+ # old_line =
+ # new_line =
+ # match_line =
+ # unchanged_line =
+ # no_line =
context 'when hovering over the parallel view diff file' do
before(:each) do
@@ -146,35 +146,51 @@ feature 'Diffs URL', js: true, feature: true do
end
def should_allow_commenting(line_holder, diff_side = nil)
- line = get_line diff_side
+ line = get_line_components line_holder, diff_side
line[:content].hover
expect(line[:num]).to have_css comment_button_class
- line[:num].find(comment_button_class).trigger 'click'
- 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'
+ comment_on_line line_holder, line
wait_for_ajax
- expect(line_holder).to have_xpath notes_holder_input_xpath
- notes_holder_saved = line_holder.find(:xpath, notes_holder_input_xpath)
- expect(notes_holder_saved[:class].include? notes_holder_input_class).to be false
- expect(notes_holder_saved).to have_content test_note_comment
+ assert_comment_persistence
end
def should_not_allow_commenting(line_holder, diff_side = nil)
- line = get_line diff_side
+ line = get_line_components line_holder, diff_side
line[:content].hover
expect(line[:num]).not_to have_css comment_button_class
end
- def get_line(diff_side = nil)
+ def get_line_components(line_holder, diff_side = nil)
if diff_side.nil?
- { content: line_holder.first('.line_content'), num: line_holder.first('.diff-line-num') }
+ get_inline_line_components line_holder
else
- side_index = diff_side == 'left' ? 0 : 1
- { content: line_holder.all('.line_content')[side_index], num: line_holder.all('.diff-line-num')[side_index] }
+ get_parallel_line_components line_holder, diff_side
end
end
+
+ def get_inline_line_components(line_holder)
+ { content: line_holder.first('.line_content'), num: line_holder.first('.diff-line-num') }
+ end
+
+ def get_parallel_line_components(line_holder, diff_side = nil)
+ side_index = diff_side == 'left' ? 0 : 1
+ { content: line_holder.all('.line_content')[side_index], num: line_holder.all('.diff-line-num')[side_index] }
+ end
+
+ def comment_on_line(line_holder, line)
+ line[:num].find(comment_button_class).trigger 'click'
+ 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'
+ end
+
+ def assert_comment_persistence(line_holder)
+ expect(line_holder).to have_xpath notes_holder_input_xpath
+ notes_holder_saved = line_holder.find(:xpath, notes_holder_input_xpath)
+ expect(notes_holder_saved[:class].include? notes_holder_input_class).to be false
+ expect(notes_holder_saved).to have_content test_note_comment
+ end
end
end