2017-08-01 18:03:07 +00:00
|
|
|
require 'rails_helper'
|
2017-03-08 16:07:26 +00:00
|
|
|
|
2017-08-01 18:03:07 +00:00
|
|
|
describe 'Merge request > User sees avatars on diff notes', :js do
|
2017-06-07 18:33:50 +00:00
|
|
|
include NoteInteractionHelpers
|
|
|
|
|
2017-07-26 21:52:10 +00:00
|
|
|
let(:project) { create(:project, :public, :repository) }
|
2017-08-01 18:03:07 +00:00
|
|
|
let(:user) { project.creator }
|
2017-03-08 16:07:26 +00:00
|
|
|
let(:merge_request) { create(:merge_request_with_diffs, source_project: project, author: user, title: "Bug NS-04") }
|
|
|
|
let(:path) { "files/ruby/popen.rb" }
|
|
|
|
let(:position) do
|
|
|
|
Gitlab::Diff::Position.new(
|
|
|
|
old_path: path,
|
|
|
|
new_path: path,
|
|
|
|
old_line: nil,
|
|
|
|
new_line: 9,
|
|
|
|
diff_refs: merge_request.diff_refs
|
|
|
|
)
|
|
|
|
end
|
|
|
|
let!(:note) { create(:diff_note_on_merge_request, project: project, noteable: merge_request, position: position) }
|
|
|
|
|
|
|
|
before do
|
2018-07-11 14:36:08 +00:00
|
|
|
project.add_maintainer(user)
|
2017-06-21 23:44:10 +00:00
|
|
|
sign_in user
|
2017-08-29 14:54:06 +00:00
|
|
|
|
2017-09-22 18:15:43 +00:00
|
|
|
set_cookie('sidebar_collapsed', 'true')
|
2017-03-08 16:07:26 +00:00
|
|
|
end
|
|
|
|
|
2017-03-09 09:47:01 +00:00
|
|
|
context 'discussion tab' do
|
|
|
|
before do
|
2017-07-06 16:20:50 +00:00
|
|
|
visit project_merge_request_path(project, merge_request)
|
2017-03-09 09:47:01 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not show avatars on discussion tab' do
|
|
|
|
expect(page).not_to have_selector('.js-avatar-container')
|
|
|
|
expect(page).not_to have_selector('.diff-comment-avatar-holders')
|
|
|
|
end
|
|
|
|
|
2018-06-21 12:22:40 +00:00
|
|
|
it 'does not render avatars after commenting on discussion tab' do
|
2017-03-09 09:47:01 +00:00
|
|
|
click_button 'Reply...'
|
|
|
|
|
|
|
|
page.within('.js-discussion-note-form') do
|
|
|
|
find('.note-textarea').native.send_keys('Test comment')
|
|
|
|
|
|
|
|
click_button 'Comment'
|
|
|
|
end
|
|
|
|
|
|
|
|
expect(page).to have_content('Test comment')
|
|
|
|
expect(page).not_to have_selector('.js-avatar-container')
|
|
|
|
expect(page).not_to have_selector('.diff-comment-avatar-holders')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'commit view' do
|
|
|
|
before do
|
2017-07-06 16:20:50 +00:00
|
|
|
visit project_commit_path(project, merge_request.commits.first.id)
|
2017-03-09 09:47:01 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not render avatar after commenting' do
|
2017-08-24 06:38:09 +00:00
|
|
|
first('.diff-line-num').click
|
2017-03-09 09:47:01 +00:00
|
|
|
find('.js-add-diff-note-button').click
|
|
|
|
|
|
|
|
page.within('.js-discussion-note-form') do
|
|
|
|
find('.note-textarea').native.send_keys('test comment')
|
|
|
|
|
|
|
|
click_button 'Comment'
|
|
|
|
|
2017-05-17 18:25:13 +00:00
|
|
|
wait_for_requests
|
2017-03-09 09:47:01 +00:00
|
|
|
end
|
|
|
|
|
2017-07-06 16:20:50 +00:00
|
|
|
visit project_merge_request_path(project, merge_request)
|
2017-03-09 09:47:01 +00:00
|
|
|
|
|
|
|
expect(page).to have_content('test comment')
|
|
|
|
expect(page).not_to have_selector('.js-avatar-container')
|
|
|
|
expect(page).not_to have_selector('.diff-comment-avatar-holders')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-06-21 12:22:40 +00:00
|
|
|
%w(parallel).each do |view|
|
2017-03-08 16:07:26 +00:00
|
|
|
context "#{view} view" do
|
|
|
|
before do
|
2017-07-06 16:20:50 +00:00
|
|
|
visit diffs_project_merge_request_path(project, merge_request, view: view)
|
2017-03-08 16:07:26 +00:00
|
|
|
|
2017-05-17 18:25:13 +00:00
|
|
|
wait_for_requests
|
2018-10-03 09:05:43 +00:00
|
|
|
|
|
|
|
find('.js-toggle-tree-list').click
|
2017-03-08 16:07:26 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows note avatar' do
|
2017-09-28 14:55:25 +00:00
|
|
|
page.within find_line(position.line_code(project.repository)) do
|
2017-10-02 17:51:16 +00:00
|
|
|
find('.diff-notes-collapse').send_keys(:return)
|
2017-03-08 16:07:26 +00:00
|
|
|
|
2018-11-07 17:20:17 +00:00
|
|
|
expect(page).to have_selector('.js-diff-comment-avatar img', count: 1)
|
2017-03-08 16:07:26 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows comment on note avatar' do
|
2017-09-28 14:55:25 +00:00
|
|
|
page.within find_line(position.line_code(project.repository)) do
|
2017-10-02 17:51:16 +00:00
|
|
|
find('.diff-notes-collapse').send_keys(:return)
|
2018-11-07 17:20:17 +00:00
|
|
|
first('.js-diff-comment-avatar img').hover
|
2017-03-08 16:07:26 +00:00
|
|
|
end
|
2018-11-07 17:20:17 +00:00
|
|
|
|
|
|
|
expect(page).to have_content "#{note.author.name}: #{note.note.truncate(17)}"
|
2017-03-08 16:07:26 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'toggles comments when clicking avatar' do
|
2017-09-28 14:55:25 +00:00
|
|
|
page.within find_line(position.line_code(project.repository)) do
|
2017-10-02 17:51:16 +00:00
|
|
|
find('.diff-notes-collapse').send_keys(:return)
|
2017-03-08 16:07:26 +00:00
|
|
|
end
|
|
|
|
|
2018-06-21 12:22:40 +00:00
|
|
|
expect(page).not_to have_selector('.notes_holder')
|
2017-03-08 16:07:26 +00:00
|
|
|
|
2017-09-28 14:55:25 +00:00
|
|
|
page.within find_line(position.line_code(project.repository)) do
|
2018-11-07 17:20:17 +00:00
|
|
|
first('.js-diff-comment-avatar img').click
|
2017-03-08 16:07:26 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
expect(page).to have_selector('.notes_holder')
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'removes avatar when note is deleted' do
|
2017-06-07 18:33:50 +00:00
|
|
|
open_more_actions_dropdown(note)
|
|
|
|
|
2017-03-08 16:07:26 +00:00
|
|
|
page.within find(".note-row-#{note.id}") do
|
2017-08-15 20:44:57 +00:00
|
|
|
accept_confirm { find('.js-note-delete').click }
|
2017-03-08 16:07:26 +00:00
|
|
|
end
|
|
|
|
|
2017-05-17 18:25:13 +00:00
|
|
|
wait_for_requests
|
2017-03-08 16:07:26 +00:00
|
|
|
|
2017-09-28 14:55:25 +00:00
|
|
|
page.within find_line(position.line_code(project.repository)) do
|
2018-11-07 17:20:17 +00:00
|
|
|
expect(page).not_to have_selector('.js-diff-comment-avatar img')
|
2017-03-08 16:07:26 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'adds avatar when commenting' do
|
|
|
|
click_button 'Reply...'
|
|
|
|
|
|
|
|
page.within '.js-discussion-note-form' do
|
|
|
|
find('.js-note-text').native.send_keys('Test')
|
|
|
|
|
|
|
|
click_button 'Comment'
|
|
|
|
|
2017-05-17 18:25:13 +00:00
|
|
|
wait_for_requests
|
2017-03-08 16:07:26 +00:00
|
|
|
end
|
|
|
|
|
2017-09-28 14:55:25 +00:00
|
|
|
page.within find_line(position.line_code(project.repository)) do
|
2017-10-02 17:51:16 +00:00
|
|
|
find('.diff-notes-collapse').send_keys(:return)
|
2017-03-08 16:07:26 +00:00
|
|
|
|
2018-11-07 17:20:17 +00:00
|
|
|
expect(page).to have_selector('.js-diff-comment-avatar img', count: 2)
|
2017-03-08 16:07:26 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'adds multiple comments' do
|
|
|
|
3.times do
|
|
|
|
click_button 'Reply...'
|
|
|
|
|
|
|
|
page.within '.js-discussion-note-form' do
|
|
|
|
find('.js-note-text').native.send_keys('Test')
|
2017-06-17 06:08:27 +00:00
|
|
|
find('.js-comment-button').click
|
2017-03-08 16:07:26 +00:00
|
|
|
|
2017-05-17 18:25:13 +00:00
|
|
|
wait_for_requests
|
2017-03-08 16:07:26 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-09-28 14:55:25 +00:00
|
|
|
page.within find_line(position.line_code(project.repository)) do
|
2017-10-02 17:51:16 +00:00
|
|
|
find('.diff-notes-collapse').send_keys(:return)
|
2017-03-08 16:07:26 +00:00
|
|
|
|
2018-11-07 17:20:17 +00:00
|
|
|
expect(page).to have_selector('.js-diff-comment-avatar img', count: 3)
|
2017-03-08 16:07:26 +00:00
|
|
|
expect(find('.diff-comments-more-count')).to have_content '+1'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'multiple comments' do
|
2017-03-31 21:52:38 +00:00
|
|
|
before do
|
2017-04-04 22:27:23 +00:00
|
|
|
create_list(:diff_note_on_merge_request, 3, project: project, noteable: merge_request, in_reply_to: note)
|
2017-07-06 16:20:50 +00:00
|
|
|
visit diffs_project_merge_request_path(project, merge_request, view: view)
|
2017-03-08 16:07:26 +00:00
|
|
|
|
2017-05-17 18:25:13 +00:00
|
|
|
wait_for_requests
|
2017-03-08 16:07:26 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows extra comment count' do
|
2017-09-28 14:55:25 +00:00
|
|
|
page.within find_line(position.line_code(project.repository)) do
|
2017-10-02 17:51:16 +00:00
|
|
|
find('.diff-notes-collapse').send_keys(:return)
|
2017-03-08 16:07:26 +00:00
|
|
|
|
|
|
|
expect(find('.diff-comments-more-count')).to have_content '+1'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2017-09-28 14:55:25 +00:00
|
|
|
|
|
|
|
def find_line(line_code)
|
|
|
|
line = find("[id='#{line_code}']")
|
|
|
|
line = line.find(:xpath, 'preceding-sibling::*[1][self::td]') if line.tag_name == 'td'
|
|
|
|
line
|
|
|
|
end
|
2017-03-08 16:07:26 +00:00
|
|
|
end
|