Skip to content
Snippets Groups Projects
Commit 50dfdf02 authored by Luke "Jared" Bennett's avatar Luke "Jared" Bennett Committed by Paco Guzman
Browse files

fix up tests

Added more exceptions

Added handling inline view type
parent 914bb05d
No related branches found
No related tags found
No related merge requests found
Loading
@@ -8,11 +8,16 @@ class @FilesCommentButton
Loading
@@ -8,11 +8,16 @@ class @FilesCommentButton
@LINE_HOLDER_CLASS = '.line_holder' @LINE_HOLDER_CLASS = '.line_holder'
@LINE_NUMBER_CLASS = 'diff-line-num' @LINE_NUMBER_CLASS = 'diff-line-num'
@LINE_CONTENT_CLASS = 'line_content' @LINE_CONTENT_CLASS = 'line_content'
@UNFOLDABLE_LINE_CLASS = 'js-unfold'
@EMPTY_CELL_CLASS = 'empty-cell'
@OLD_LINE_CLASS = 'old_line'
@LINE_COLUMN_CLASSES = ".#{@LINE_NUMBER_CLASS}, .line_content" @LINE_COLUMN_CLASSES = ".#{@LINE_NUMBER_CLASS}, .line_content"
@TEXT_FILE_SELECTOR = '.text-file' @TEXT_FILE_SELECTOR = '.text-file'
   
@DEBOUNCE_TIMEOUT_DURATION = 150 @DEBOUNCE_TIMEOUT_DURATION = 150
   
@VIEW_TYPE = $('input#view[type=hidden]').val()
$(document) $(document)
.on 'mouseover', @LINE_COLUMN_CLASSES, @debounceRender .on 'mouseover', @LINE_COLUMN_CLASSES, @debounceRender
.on 'mouseleave', @LINE_COLUMN_CLASSES, @destroy .on 'mouseleave', @LINE_COLUMN_CLASSES, @destroy
Loading
@@ -38,13 +43,13 @@ class @FilesCommentButton
Loading
@@ -38,13 +43,13 @@ class @FilesCommentButton
id: id:
noteable: textFileElement.attr 'data-noteable-id' noteable: textFileElement.attr 'data-noteable-id'
commit: textFileElement.attr 'data-commit-id' commit: textFileElement.attr 'data-commit-id'
discussion: lineContentElement.attr('data-discussion-id') || lineHolderElement.attr('data-discussion-id') discussion: lineContentElement.attr('data-discussion-id') or lineHolderElement.attr('data-discussion-id')
type: type:
noteable: textFileElement.attr 'data-noteable-type' noteable: textFileElement.attr 'data-noteable-type'
note: textFileElement.attr 'data-note-type' note: textFileElement.attr 'data-note-type'
line: lineContentElement.attr 'data-line-type' line: lineContentElement.attr 'data-line-type'
code: code:
line: lineContentElement.attr('data-line-code') || lineHolderElement.attr('id') line: lineContentElement.attr('data-line-code') or lineHolderElement.attr('id')
return return
   
destroy: (e) => destroy: (e) =>
Loading
@@ -70,14 +75,17 @@ class @FilesCommentButton
Loading
@@ -70,14 +75,17 @@ class @FilesCommentButton
$(hoveredElement.parent()) $(hoveredElement.parent())
   
getLineNum: (hoveredElement) -> getLineNum: (hoveredElement) ->
return hoveredElement if hoveredElement.hasClass @LINE_NUMBER_CLASS if @VIEW_TYPE is 'inline' and hoveredElement.hasClass @OLD_LINE_CLASS
$(hoveredElement).next ".#{@LINE_NUMBER_CLASS}"
$(hoveredElement).prev('.' + @LINE_NUMBER_CLASS) else if hoveredElement.hasClass @LINE_NUMBER_CLASS
hoveredElement
else
$(hoveredElement).prev ".#{@LINE_NUMBER_CLASS}"
   
getLineContent: (hoveredElement) -> getLineContent: (hoveredElement) ->
return hoveredElement if hoveredElement.hasClass @LINE_CONTENT_CLASS return hoveredElement if hoveredElement.hasClass @LINE_CONTENT_CLASS
   
$(hoveredElement).next('.' + @LINE_CONTENT_CLASS) $(hoveredElement).next ".#{@LINE_CONTENT_CLASS}"
   
isMovingToSameType: (e) -> isMovingToSameType: (e) ->
newLineNum = @getLineNum($(e.toElement)) newLineNum = @getLineNum($(e.toElement))
Loading
@@ -85,4 +93,6 @@ class @FilesCommentButton
Loading
@@ -85,4 +93,6 @@ class @FilesCommentButton
(newLineNum).is @getLineNum($(e.currentTarget)) (newLineNum).is @getLineNum($(e.currentTarget))
   
shouldRender: (e, buttonParentElement) -> shouldRender: (e, buttonParentElement) ->
(!buttonParentElement.hasClass('empty-cell') and $(@COMMENT_BUTTON_CLASS, buttonParentElement).length is 0) (!buttonParentElement.hasClass(@EMPTY_CELL_CLASS) and \
!buttonParentElement.hasClass(@UNFOLDABLE_LINE_CLASS) and \
$(@COMMENT_BUTTON_CLASS, buttonParentElement).length is 0)
Loading
@@ -39,7 +39,7 @@ module DiffHelper
Loading
@@ -39,7 +39,7 @@ module DiffHelper
end end
   
def unfold_bottom_class(bottom) def unfold_bottom_class(bottom)
bottom ? 'js-unfold-bottom' : '' bottom ? 'js-unfold js-unfold-bottom' : ''
end end
   
def unfold_class(unfold) def unfold_class(unfold)
Loading
Loading
Loading
@@ -25,8 +25,7 @@ module SharedDiffNote
Loading
@@ -25,8 +25,7 @@ module SharedDiffNote
   
page.within("form[id$='#{sample_commit.line_code}-true']") do page.within("form[id$='#{sample_commit.line_code}-true']") do
fill_in "note[note]", with: "Typo, please fix" fill_in "note[note]", with: "Typo, please fix"
find(".js-comment-button").trigger("click") find(".js-comment-button").click
sleep 0.05
end end
end end
end end
Loading
@@ -35,7 +34,7 @@ module SharedDiffNote
Loading
@@ -35,7 +34,7 @@ module SharedDiffNote
click_parallel_diff_line(sample_commit.del_line_code, 'old') click_parallel_diff_line(sample_commit.del_line_code, 'old')
page.within("#{diff_file_selector} form[id$='#{sample_commit.del_line_code}-true']") do page.within("#{diff_file_selector} form[id$='#{sample_commit.del_line_code}-true']") do
fill_in "note[note]", with: "Old comment" fill_in "note[note]", with: "Old comment"
find(".js-comment-button").trigger("click") find(".js-comment-button").click
end end
end end
   
Loading
@@ -43,7 +42,7 @@ module SharedDiffNote
Loading
@@ -43,7 +42,7 @@ module SharedDiffNote
click_parallel_diff_line(sample_commit.line_code, 'new') click_parallel_diff_line(sample_commit.line_code, 'new')
page.within("#{diff_file_selector} form[id$='#{sample_commit.line_code}-true']") do page.within("#{diff_file_selector} form[id$='#{sample_commit.line_code}-true']") do
fill_in "note[note]", with: "New comment" fill_in "note[note]", with: "New comment"
find(".js-comment-button").trigger("click") find(".js-comment-button").click
end end
end end
   
Loading
@@ -211,7 +210,7 @@ module SharedDiffNote
Loading
@@ -211,7 +210,7 @@ module SharedDiffNote
end end
   
step 'I click side-by-side diff button' do step 'I click side-by-side diff button' do
find('#parallel-diff-btn').trigger('click') find('#parallel-diff-btn').click
end end
   
step 'I see side-by-side diff button' do step 'I see side-by-side diff button' do
Loading
@@ -223,12 +222,12 @@ module SharedDiffNote
Loading
@@ -223,12 +222,12 @@ module SharedDiffNote
end end
   
def click_diff_line(code) def click_diff_line(code)
find(".line_holder[id='#{code}'] td:nth-of-type(1)").hover find(".line_holder[id='#{code}'] td:nth-of-type(1)").trigger 'mouseover'
find(".line_holder[id='#{code}'] button").trigger('click') find(".line_holder[id='#{code}'] button").trigger 'click'
end end
   
def click_parallel_diff_line(code, line_type) def click_parallel_diff_line(code, line_type)
find(".line_content.parallel.#{line_type}[data-line-code='#{code}']").trigger('mouseover') find(".line_content.parallel.#{line_type}[data-line-code='#{code}']").trigger 'mouseover'
find(".line_holder.parallel button[data-line-code='#{code}']").trigger('click') find(".line_holder.parallel button[data-line-code='#{code}']").trigger 'click'
end end
end end
Loading
@@ -59,7 +59,7 @@ describe DiffHelper do
Loading
@@ -59,7 +59,7 @@ describe DiffHelper do
end end
   
it 'should return js class when bottom lines should be unfolded' do it 'should return js class when bottom lines should be unfolded' do
expect(unfold_bottom_class(true)).to eq('js-unfold-bottom') expect(unfold_bottom_class(true)).to include('js-unfold-bottom')
end end
end end
   
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment