Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
2756e612
Commit
2756e612
authored
Apr 12, 2017
by
Rémy Coutable
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reorganize feature specs for MR notes
Signed-off-by:
Rémy Coutable
<
remy@rymai.me
>
parent
c3bb21ff
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
470 additions
and
523 deletions
+470
-523
spec/features/merge_requests/diff_notes_spec.rb
spec/features/merge_requests/diff_notes_spec.rb
+0
-238
spec/features/merge_requests/user_posts_diff_notes_spec.rb
spec/features/merge_requests/user_posts_diff_notes_spec.rb
+294
-0
spec/features/merge_requests/user_posts_notes.rb
spec/features/merge_requests/user_posts_notes.rb
+145
-0
spec/features/merge_requests/user_sees_system_notes_spec.rb
spec/features/merge_requests/user_sees_system_notes_spec.rb
+31
-0
spec/features/notes_on_merge_requests_spec.rb
spec/features/notes_on_merge_requests_spec.rb
+0
-285
No files found.
spec/features/merge_requests/diff_notes_spec.rb
deleted
100644 → 0
View file @
c3bb21ff
require
'spec_helper'
feature
'Diff notes'
,
js:
true
,
feature:
true
do
include
WaitForAjax
before
do
login_as
:admin
@merge_request
=
create
(
:merge_request
)
@project
=
@merge_request
.
source_project
end
context
'merge request diffs'
do
let
(
:comment_button_class
)
{
'.add-diff-note'
}
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!'
}
context
'when hovering over a parallel view diff file'
do
before
(
:each
)
do
visit
diffs_namespace_project_merge_request_path
(
@project
.
namespace
,
@project
,
@merge_request
,
view:
'parallel'
)
end
context
'with an old line on the left and no line on the right'
do
it
'should allow commenting on the left side'
do
should_allow_commenting
(
find
(
'[id="6eb14e00385d2fb284765eb1cd8d420d33d63fc9_23_22"]'
).
find
(
:xpath
,
'..'
),
'left'
)
end
it
'should not allow commenting on the right side'
do
should_not_allow_commenting
(
find
(
'[id="6eb14e00385d2fb284765eb1cd8d420d33d63fc9_23_22"]'
).
find
(
:xpath
,
'..'
),
'right'
)
end
end
context
'with no line on the left and a new line on the right'
do
it
'should not allow commenting on the left side'
do
should_not_allow_commenting
(
find
(
'[id="2f6fcd96b88b36ce98c38da085c795a27d92a3dd_15_15"]'
).
find
(
:xpath
,
'..'
),
'left'
)
end
it
'should allow commenting on the right side'
do
should_allow_commenting
(
find
(
'[id="2f6fcd96b88b36ce98c38da085c795a27d92a3dd_15_15"]'
).
find
(
:xpath
,
'..'
),
'right'
)
end
end
context
'with an old line on the left and a new line on the right'
do
it
'should allow commenting on the left side'
do
should_allow_commenting
(
find
(
'[id="2f6fcd96b88b36ce98c38da085c795a27d92a3dd_9_9"]'
).
find
(
:xpath
,
'..'
),
'left'
)
end
it
'should allow commenting on the right side'
do
should_allow_commenting
(
find
(
'[id="2f6fcd96b88b36ce98c38da085c795a27d92a3dd_9_9"]'
).
find
(
:xpath
,
'..'
),
'right'
)
end
end
context
'with an unchanged line on the left and an unchanged line on the right'
do
it
'should allow commenting on the left side'
do
should_allow_commenting
(
find
(
'[id="2f6fcd96b88b36ce98c38da085c795a27d92a3dd_7_7"]'
,
match: :first
).
find
(
:xpath
,
'..'
),
'left'
)
end
it
'should allow commenting on the right side'
do
should_allow_commenting
(
find
(
'[id="2f6fcd96b88b36ce98c38da085c795a27d92a3dd_7_7"]'
,
match: :first
).
find
(
:xpath
,
'..'
),
'right'
)
end
end
context
'with a match line'
do
it
'should not allow commenting on the left side'
do
should_not_allow_commenting
(
find
(
'.match'
,
match: :first
).
find
(
:xpath
,
'..'
),
'left'
)
end
it
'should not allow commenting on the right side'
do
should_not_allow_commenting
(
find
(
'.match'
,
match: :first
).
find
(
:xpath
,
'..'
),
'right'
)
end
end
context
'with an unfolded line'
do
before
(
:each
)
do
find
(
'.js-unfold'
,
match: :first
).
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 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'
)
end
end
end
context
'when hovering over an inline view diff file'
do
before
do
visit
diffs_namespace_project_merge_request_path
(
@project
.
namespace
,
@project
,
@merge_request
,
view:
'inline'
)
end
context
'with a new line'
do
it
'should allow commenting'
do
should_allow_commenting
(
find
(
'[id="2f6fcd96b88b36ce98c38da085c795a27d92a3dd_10_9"]'
))
end
end
context
'with an old line'
do
it
'should allow commenting'
do
should_allow_commenting
(
find
(
'[id="6eb14e00385d2fb284765eb1cd8d420d33d63fc9_22_22"]'
))
end
end
context
'with an unchanged line'
do
it
'should allow commenting'
do
should_allow_commenting
(
find
(
'[id="2f6fcd96b88b36ce98c38da085c795a27d92a3dd_7_7"]'
))
end
end
context
'with a match line'
do
it
'should not allow commenting'
do
should_not_allow_commenting
(
find
(
'.match'
,
match: :first
))
end
end
context
'with an unfolded line'
do
before
(
:each
)
do
find
(
'.js-unfold'
,
match: :first
).
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
end
end
context
'when hovering over a diff discussion'
do
before
do
visit
diffs_namespace_project_merge_request_path
(
@project
.
namespace
,
@project
,
@merge_request
,
view:
'inline'
)
should_allow_commenting
(
find
(
'[id="2f6fcd96b88b36ce98c38da085c795a27d92a3dd_7_7"]'
))
visit
namespace_project_merge_request_path
(
@project
.
namespace
,
@project
,
@merge_request
)
end
it
'should not allow commenting'
do
should_not_allow_commenting
(
find
(
'.line_holder'
,
match: :first
))
end
end
end
context
'when the MR only supports legacy diff notes'
do
before
do
@merge_request
.
merge_request_diff
.
update_attributes
(
start_commit_sha:
nil
)
visit
diffs_namespace_project_merge_request_path
(
@project
.
namespace
,
@project
,
@merge_request
,
view:
'inline'
)
end
context
'with a new line'
do
it
'should allow commenting'
do
should_allow_commenting
(
find
(
'[id="2f6fcd96b88b36ce98c38da085c795a27d92a3dd_10_9"]'
))
end
end
context
'with an old line'
do
it
'should allow commenting'
do
should_allow_commenting
(
find
(
'[id="6eb14e00385d2fb284765eb1cd8d420d33d63fc9_22_22"]'
))
end
end
context
'with an unchanged line'
do
it
'should allow commenting'
do
should_allow_commenting
(
find
(
'[id="2f6fcd96b88b36ce98c38da085c795a27d92a3dd_7_7"]'
))
end
end
context
'with a match line'
do
it
'should not allow commenting'
do
should_not_allow_commenting
(
find
(
'.match'
,
match: :first
))
end
end
end
def
should_allow_commenting
(
line_holder
,
diff_side
=
nil
)
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
)
assert_comment_persistence
(
line_holder
)
end
def
should_not_allow_commenting
(
line_holder
,
diff_side
=
nil
)
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_components
(
line_holder
,
diff_side
=
nil
)
if
diff_side
.
nil?
get_inline_line_components
(
line_holder
)
else
get_parallel_line_components
(
line_holder
,
diff_side
)
end
end
def
get_inline_line_components
(
line_holder
)
{
content:
line_holder
.
find
(
'.line_content'
,
match: :first
),
num:
line_holder
.
find
(
'.diff-line-num'
,
match: :first
)
}
end
def
get_parallel_line_components
(
line_holder
,
diff_side
=
nil
)
side_index
=
diff_side
==
'left'
?
0
:
1
# Wait for `.line_content`
line_holder
.
find
(
'.line_content'
,
match: :first
)
# Wait for `.diff-line-num`
line_holder
.
find
(
'.diff-line-num'
,
match: :first
)
{
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'
line_holder
.
find
(
:xpath
,
notes_holder_input_xpath
)
notes_holder_input
=
line_holder
.
find
(
:xpath
,
notes_holder_input_xpath
)
expect
(
notes_holder_input
[
:class
]).
to
include
(
notes_holder_input_class
)
notes_holder_input
.
fill_in
'note[note]'
,
with:
test_note_comment
click_button
'Comment'
wait_for_ajax
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
]).
not_to
include
(
notes_holder_input_class
)
expect
(
notes_holder_saved
).
to
have_content
test_note_comment
end
end
end
spec/features/merge_requests/user_posts_diff_notes_spec.rb
0 → 100644
View file @
2756e612
This diff is collapsed.
Click to expand it.
spec/features/merge_requests/user_posts_notes.rb
0 → 100644
View file @
2756e612
require
'spec_helper'
describe
'Merge requests > User posts notes'
,
:js
do
let
(
:project
)
{
create
(
:project
)
}
let
(
:merge_request
)
do
create
(
:merge_request
,
source_project:
project
,
target_project:
project
)
end
let!
(
:note
)
do
create
(
:note_on_merge_request
,
:with_attachment
,
noteable:
merge_request
,
project:
project
)
end
before
do
login_as
:admin
visit
namespace_project_merge_request_path
(
project
.
namespace
,
project
,
merge_request
)
end
subject
{
page
}
describe
'the note form'
do
it
'is valid'
do
is_expected
.
to
have_css
(
'.js-main-target-form'
,
visible:
true
,
count:
1
)
expect
(
find
(
'.js-main-target-form .js-comment-button'
).
value
).
to
eq
(
'Comment'
)
page
.
within
(
'.js-main-target-form'
)
do
expect
(
page
).
not_to
have_link
(
'Cancel'
)
end
end
describe
'with text'
do
before
do
page
.
within
(
'.js-main-target-form'
)
do
fill_in
'note[note]'
,
with:
'This is awesome'
end
end
it
'has enable submit button and preview button'
do
page
.
within
(
'.js-main-target-form'
)
do
expect
(
page
).
not_to
have_css
(
'.js-comment-button[disabled]'
)
expect
(
page
).
to
have_css
(
'.js-md-preview-button'
,
visible:
true
)
end
end
end
end
describe
'when posting a note'
do
before
do
page
.
within
(
'.js-main-target-form'
)
do
fill_in
'note[note]'
,
with:
'This is awesome!'
find
(
'.js-md-preview-button'
).
click
click_button
'Comment'
end
end
it
'is added and form reset'
do
is_expected
.
to
have_content
(
'This is awesome!'
)
page
.
within
(
'.js-main-target-form'
)
do
expect
(
page
).
to
have_no_field
(
'note[note]'
,
with:
'This is awesome!'
)
expect
(
page
).
to
have_css
(
'.js-md-preview'
,
visible: :hidden
)
end
page
.
within
(
'.js-main-target-form'
)
do
is_expected
.
to
have_css
(
'.js-note-text'
,
visible:
true
)
end
end
end
describe
'when editing a note'
do
it
'there should be a hidden edit form'
do
is_expected
.
to
have_css
(
'.note-edit-form:not(.mr-note-edit-form)'
,
visible:
false
,
count:
1
)
is_expected
.
to
have_css
(
'.note-edit-form.mr-note-edit-form'
,
visible:
false
,
count:
1
)
end
describe
'editing the note'
do
before
do
find
(
'.note'
).
hover
find
(
'.js-note-edit'
).
click
end
it
'shows the note edit form and hide the note body'
do
page
.
within
(
"#note_
#{
note
.
id
}
"
)
do
expect
(
find
(
'.current-note-edit-form'
,
visible:
true
)).
to
be_visible
expect
(
find
(
'.note-edit-form'
,
visible:
true
)).
to
be_visible
expect
(
find
(
:css
,
'.note-body > .note-text'
,
visible:
false
)).
not_to
be_visible
end
end
it
'resets the edit note form textarea with the original content of the note if cancelled'
do
within
(
'.current-note-edit-form'
)
do
fill_in
'note[note]'
,
with:
'Some new content'
find
(
'.btn-cancel'
).
click
expect
(
find
(
'.js-note-text'
,
visible:
false
).
text
).
to
eq
''
end
end
it
'allows using markdown buttons after saving a note and then trying to edit it again'
do
page
.
within
(
'.current-note-edit-form'
)
do
fill_in
'note[note]'
,
with:
'This is the new content'
find
(
'.btn-save'
).
click
end
find
(
'.note'
).
hover
find
(
'.js-note-edit'
).
click
page
.
within
(
'.current-note-edit-form'
)
do
expect
(
find
(
'#note_note'
).
value
).
to
eq
(
'This is the new content'
)
find
(
'.js-md:first-child'
).
click
expect
(
find
(
'#note_note'
).
value
).
to
eq
(
'This is the new content****'
)
end
end
it
'appends the edited at time to the note'
do
page
.
within
(
'.current-note-edit-form'
)
do
fill_in
'note[note]'
,
with:
'Some new content'
find
(
'.btn-save'
).
click
end
page
.
within
(
"#note_
#{
note
.
id
}
"
)
do
is_expected
.
to
have_css
(
'.note_edited_ago'
)
expect
(
find
(
'.note_edited_ago'
).
text
).
to
match
(
/less than a minute ago/
)
end
end
end
describe
'deleting an attachment'
do
before
do
find
(
'.note'
).
hover
find
(
'.js-note-edit'
).
click
end
it
'shows the delete link'
do
page
.
within
(
'.note-attachment'
)
do
is_expected
.
to
have_css
(
'.js-note-attachment-delete'
)
end
end
it
'removes the attachment div and resets the edit form'
do
find
(
'.js-note-attachment-delete'
).
click
is_expected
.
not_to
have_css
(
'.note-attachment'
)
is_expected
.
not_to
have_css
(
'.current-note-edit-form'
)
wait_for_ajax
end
end
end
end
spec/features/merge_requests/user_sees_system_notes_spec.rb
0 → 100644
View file @
2756e612
require
'spec_helper'
feature
'Merge requests > User sees system notes'
do
let
(
:public_project
)
{
create
(
:project
,
:public
)
}
let
(
:private_project
)
{
create
(
:project
,
:private
)
}
let
(
:issue
)
{
create
(
:issue
,
project:
private_project
)
}
let
(
:merge_request
)
{
create
(
:merge_request
,
source_project:
public_project
,
source_branch:
'markdown'
)
}
let!
(
:note
)
{
create
(
:note_on_merge_request
,
:system
,
noteable:
merge_request
,
project:
public_project
,
note:
"mentioned in
#{
issue
.
to_reference
(
public_project
)
}
"
)
}
context
'when logged-in as a member of the private project'
do
before
do
user
=
create
(
:user
)
private_project
.
add_developer
(
user
)
login_as
(
user
)
end
it
'shows the system note'
do
visit
namespace_project_merge_request_path
(
public_project
.
namespace
,
public_project
,
merge_request
)
expect
(
page
).
to
have_css
(
'.system-note'
)
end
end
context
'when not logged-in'
do
it
'hides the system note'
do
visit
namespace_project_merge_request_path
(
public_project
.
namespace
,
public_project
,
merge_request
)
expect
(
page
).
not_to
have_css
(
'.system-note'
)
end
end
end
spec/features/notes_on_merge_requests_spec.rb
deleted
100644 → 0
View file @
c3bb21ff
require
'spec_helper'
describe
'Comments'
,
feature:
true
do
include
RepoHelpers
include
WaitForAjax
describe
'On a merge request'
,
js:
true
,
feature:
true
do
let!
(
:project
)
{
create
(
:project
)
}
let!
(
:merge_request
)
do
create
(
:merge_request
,
source_project:
project
,
target_project:
project
)
end
let!
(
:note
)
do
create
(
:note_on_merge_request
,
:with_attachment
,
noteable:
merge_request
,
project:
project
)
end
before
do
login_as
:admin
visit
namespace_project_merge_request_path
(
project
.
namespace
,
project
,
merge_request
)
end
subject
{
page
}
describe
'the note form'
do
it
'is valid'
do
is_expected
.
to
have_css
(
'.js-main-target-form'
,
visible:
true
,
count:
1
)
expect
(
find
(
'.js-main-target-form .js-comment-button'
).
value
).
to
eq
(
'Comment'
)
page
.
within
(
'.js-main-target-form'
)
do
expect
(
page
).
not_to
have_link
(
'Cancel'
)
end
end
describe
'with text'
do
before
do
page
.
within
(
'.js-main-target-form'
)
do
fill_in
'note[note]'
,
with:
'This is awesome'
end
end
it
'has enable submit button and preview button'
do
page
.
within
(
'.js-main-target-form'
)
do
expect
(
page
).
not_to
have_css
(
'.js-comment-button[disabled]'
)
expect
(
page
).
to
have_css
(
'.js-md-preview-button'
,
visible:
true
)
end
end
end
end
describe
'when posting a note'
do
before
do
page
.
within
(
'.js-main-target-form'
)
do
fill_in
'note[note]'
,
with:
'This is awsome!'
find
(
'.js-md-preview-button'
).
click
click_button
'Comment'
end
end
it
'is added and form reset'
do
is_expected
.
to
have_content
(
'This is awsome!'
)
page
.
within
(
'.js-main-target-form'
)
do
expect
(
page
).
to
have_no_field
(
'note[note]'
,
with:
'This is awesome!'
)
expect
(
page
).
to
have_css
(
'.js-md-preview'
,
visible: :hidden
)
end
page
.
within
(
'.js-main-target-form'
)
do
is_expected
.
to
have_css
(
'.js-note-text'
,
visible:
true
)
end
end
end
describe
'when editing a note'
,
js:
true
do
it
'there should be a hidden edit form'
do
is_expected
.
to
have_css
(
'.note-edit-form:not(.mr-note-edit-form)'
,
visible:
false
,
count:
1
)
is_expected
.
to
have_css
(
'.note-edit-form.mr-note-edit-form'
,
visible:
false
,
count:
1
)
end
describe
'editing the note'
do
before
do
find
(
'.note'
).
hover
find
(
'.js-note-edit'
).
click
end
it
'shows the note edit form and hide the note body'
do
page
.
within
(
"#note_
#{
note
.
id
}
"
)
do
expect
(
find
(
'.current-note-edit-form'
,
visible:
true
)).
to
be_visible
expect
(
find
(
'.note-edit-form'
,
visible:
true
)).
to
be_visible
expect
(
find
(
:css
,
'.note-body > .note-text'
,
visible:
false
)).
not_to
be_visible
end
end
it
'resets the edit note form textarea with the original content of the note if cancelled'
do
within
(
'.current-note-edit-form'
)
do
fill_in
'note[note]'
,
with:
'Some new content'
find
(
'.btn-cancel'
).
click
expect
(
find
(
'.js-note-text'
,
visible:
false
).
text
).
to
eq
''
end
end
it
'allows using markdown buttons after saving a note and then trying to edit it again'
do
page
.
within
(
'.current-note-edit-form'
)
do
fill_in
'note[note]'
,
with:
'This is the new content'
find
(
'.btn-save'
).
click
end
find
(
'.note'
).
hover
find
(
'.js-note-edit'
).
click
page
.
within
(
'.current-note-edit-form'
)
do
expect
(
find
(
'#note_note'
).
value
).
to
eq
(
'This is the new content'
)
find
(
'.js-md:first-child'
).
click
expect
(
find
(
'#note_note'
).
value
).
to
eq
(
'This is the new content****'
)
end
end
it
'appends the edited at time to the note'
do
page
.
within
(
'.current-note-edit-form'
)
do
fill_in
'note[note]'
,
with:
'Some new content'
find
(
'.btn-save'
).
click
end
page
.
within
(
"#note_
#{
note
.
id
}
"
)
do
is_expected
.
to
have_css
(
'.note_edited_ago'
)
expect
(
find
(
'.note_edited_ago'
).
text
).
to
match
(
/less than a minute ago/
)
end
end
end
describe
'deleting an attachment'
do
before
do
find
(
'.note'
).
hover
find
(
'.js-note-edit'
).
click
end
it
'shows the delete link'
do
page
.
within
(
'.note-attachment'
)
do
is_expected
.
to
have_css
(
'.js-note-attachment-delete'
)
end
end
it
'removes the attachment div and resets the edit form'
do
find
(
'.js-note-attachment-delete'
).
click
is_expected
.
not_to
have_css
(
'.note-attachment'
)
is_expected
.
not_to
have_css
(
'.current-note-edit-form'
)
wait_for_ajax
end
end
end
end
describe
'Handles cross-project system notes'
,
js:
true
,
feature:
true
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:project
)
{
create
(
:project
,
:public
)
}
let
(
:project2
)
{
create
(
:project
,
:private
)
}
let
(
:issue
)
{
create
(
:issue
,
project:
project2
)
}
let
(
:merge_request
)
{
create
(
:merge_request
,
source_project:
project
,
source_branch:
'markdown'
)
}
let!
(
:note
)
{
create
(
:note_on_merge_request
,
:system
,
noteable:
merge_request
,
project:
project
,
note:
"mentioned in
#{
issue
.
to_reference
(
project
)
}
"
)
}
it
'shows the system note'
do
login_as
:admin
visit
namespace_project_merge_request_path
(
project
.
namespace
,
project
,
merge_request
)
expect
(
page
).
to
have_css
(
'.system-note'
)
end
it
'hides redacted system note'
do
visit
namespace_project_merge_request_path
(
project
.
namespace
,
project
,
merge_request
)
expect
(
page
).
not_to
have_css
(
'.system-note'
)
end
end
describe
'On a merge request diff'
,
js:
true
,
feature:
true
do
let
(
:merge_request
)
{
create
(
:merge_request
)
}
let
(
:project
)
{
merge_request
.
source_project
}
before
do
login_as
:admin
visit
diffs_namespace_project_merge_request_path
(
project
.
namespace
,
project
,
merge_request
)
end
subject
{
page
}
describe
'when adding a note'
do
before
do
click_diff_line
end
describe
'the notes holder'
do
it
{
is_expected
.
to
have_css
(
'.js-temp-notes-holder'
)
}
it
'has .new_note css class'
do
page
.
within
(
'.js-temp-notes-holder'
)
do
expect
(
subject
).
to
have_css
(
'.new-note'
)
end
end
end
describe
'the note form'
do
it
"does not add a second form for same row"
do
click_diff_line
is_expected
.
to
have_css
(
"form[data-line-code='
#{
line_code
}
']"
,
count:
1
)
end
it
'is removed when canceled'
do
is_expected
.
to
have_css
(
'.js-temp-notes-holder'
)
page
.
within
(
"form[data-line-code='
#{
line_code
}
']"
)
do
find
(
'.js-close-discussion-note-form'
).
trigger
(
'click'
)
end
is_expected
.
to
have_no_css
(
'.js-temp-notes-holder'
)
end
end
end
describe
'with muliple note forms'
do
before
do
click_diff_line
click_diff_line
(
line_code_2
)
end
it
{
is_expected
.
to
have_css
(
'.js-temp-notes-holder'
,
count:
2
)
}
describe
'previewing them separately'
do
before
do
# add two separate texts and trigger previews on both
page
.
within
(
"tr[id='
#{
line_code
}
'] + .js-temp-notes-holder"
)
do
fill_in
'note[note]'
,
with:
'One comment on line 7'
find
(
'.js-md-preview-button'
).
click
end
page
.
within
(
"tr[id='
#{
line_code_2
}
'] + .js-temp-notes-holder"
)
do
fill_in
'note[note]'
,
with:
'Another comment on line 10'
find
(
'.js-md-preview-button'
).
click
end
end
end
describe
'posting a note'
do
before
do
page
.
within
(
"tr[id='
#{
line_code_2
}
'] + .js-temp-notes-holder"
)
do
fill_in
'note[note]'
,
with:
'Another comment on line 10'
click_button
(
'Comment'
)
end
end
it
'adds as discussion'
do
is_expected
.
to
have_content
(
'Another comment on line 10'
)
is_expected
.
to
have_css
(
'.notes_holder'
)
is_expected
.
to
have_css
(
'.notes_holder .note'
,
count:
1
)
is_expected
.
to
have_button
(
'Reply...'
)
end
it
'adds code to discussion'
do
click_button
'Reply...'
page
.
within
(
first
(
'.js-discussion-note-form'
))
do
fill_in
'note[note]'
,
with:
'```{{ test }}```'
click_button
(
'Comment'
)
end
expect
(
page
).
to
have_content
(
'{{ test }}'
)
end
end
end
end
def
line_code
sample_compare
.
changes
.
first
[
:line_code
]
end
def
line_code_2
sample_compare
.
changes
.
last
[
:line_code
]
end
def
click_diff_line
(
data
=
line_code
)
find
(
".line_holder[id='
#{
data
}
'] td.line_content"
).
hover
find
(
".line_holder[id='
#{
data
}
'] button"
).
trigger
(
'click'
)
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment