debian-mirror-gitlab/spec/features/merge_request/user_sees_discussions_spec.rb

105 lines
3.6 KiB
Ruby
Raw Normal View History

2019-10-12 21:52:04 +05:30
# frozen_string_literal: true
2019-12-04 20:38:33 +05:30
require 'spec_helper'
2018-03-17 18:26:18 +05:30
2019-09-30 21:07:59 +05:30
describe 'Merge request > User sees threads', :js do
2018-03-17 18:26:18 +05:30
let(:project) { create(:project, :public, :repository) }
let(:user) { project.creator }
let(:merge_request) { create(:merge_request, source_project: project) }
2017-08-17 22:00:37 +05:30
before do
2018-11-18 11:00:15 +05:30
project.add_maintainer(user)
2018-03-17 18:26:18 +05:30
sign_in(user)
2017-08-17 22:00:37 +05:30
end
2017-09-10 17:25:29 +05:30
describe "Diff discussions" do
2017-08-17 22:00:37 +05:30
let!(:old_merge_request_diff) { merge_request.merge_request_diffs.create(diff_refs: outdated_diff_refs) }
let!(:new_merge_request_diff) { merge_request.merge_request_diffs.create }
let!(:outdated_discussion) { create(:diff_note_on_merge_request, project: project, noteable: merge_request, position: outdated_position).to_discussion }
let!(:active_discussion) { create(:diff_note_on_merge_request, noteable: merge_request, project: project).to_discussion }
let(:outdated_position) do
2020-03-09 13:42:32 +05:30
build(:text_diff_position, :added,
file: "files/ruby/popen.rb",
2017-08-17 22:00:37 +05:30
new_line: 9,
diff_refs: outdated_diff_refs
)
end
let(:outdated_diff_refs) { project.commit("874797c3a73b60d2187ed6e2fcabd289ff75171e").diff_refs }
2018-03-17 18:26:18 +05:30
before do
2017-09-10 17:25:29 +05:30
visit project_merge_request_path(project, merge_request)
2017-08-17 22:00:37 +05:30
end
2019-09-30 21:07:59 +05:30
context 'active threads' do
2017-08-17 22:00:37 +05:30
it 'shows a link to the diff' do
within(".discussion[data-discussion-id='#{active_discussion.id}']") do
2017-09-10 17:25:29 +05:30
path = diffs_project_merge_request_path(project, merge_request, anchor: active_discussion.line_code)
2017-08-17 22:00:37 +05:30
expect(page).to have_link('the diff', href: path)
end
end
end
2019-09-30 21:07:59 +05:30
context 'outdated threads' do
2017-08-17 22:00:37 +05:30
it 'shows a link to the outdated diff' do
within(".discussion[data-discussion-id='#{outdated_discussion.id}']") do
2017-09-10 17:25:29 +05:30
path = diffs_project_merge_request_path(project, merge_request, diff_id: old_merge_request_diff.id, anchor: outdated_discussion.line_code)
expect(page).to have_link('an old version of the diff', href: path)
2017-08-17 22:00:37 +05:30
end
end
end
end
2017-09-10 17:25:29 +05:30
describe 'Commit comments displayed in MR context', :js do
shared_examples 'a functional discussion' do
let(:discussion_id) { note.discussion_id(merge_request) }
2019-02-15 15:39:39 +05:30
it 'is displayed' do
2017-09-10 17:25:29 +05:30
expect(page).to have_css(".discussion[data-discussion-id='#{discussion_id}']")
end
2019-02-15 15:39:39 +05:30
it 'can be replied to' do
2017-09-10 17:25:29 +05:30
within(".discussion[data-discussion-id='#{discussion_id}']") do
click_button 'Reply...'
fill_in 'note[note]', with: 'Test!'
click_button 'Comment'
expect(page).to have_css('.note', count: 2)
end
end
end
2018-03-17 18:26:18 +05:30
before do
2017-09-10 17:25:29 +05:30
visit project_merge_request_path(project, merge_request)
end
2019-12-04 20:38:33 +05:30
# TODO: https://gitlab.com/gitlab-org/gitlab-foss/issues/48034
2019-02-15 15:39:39 +05:30
# context 'a regular commit comment' do
# let(:note) { create(:note_on_commit, project: project) }
#
# it_behaves_like 'a functional discussion'
# end
2017-09-10 17:25:29 +05:30
context 'a commit diff comment' do
let(:note) { create(:diff_note_on_commit, project: project) }
it_behaves_like 'a functional discussion'
2019-02-15 15:39:39 +05:30
it 'displays correct header' do
2019-09-30 21:07:59 +05:30
expect(page).to have_content "started a thread on commit #{note.commit_id[0...7]}"
2019-02-15 15:39:39 +05:30
end
2017-09-10 17:25:29 +05:30
end
2019-03-02 22:35:43 +05:30
context 'a commit non-diff discussion' do
let(:note) { create(:discussion_note_on_commit, project: project) }
it 'displays correct header' do
page.within(find("#note_#{note.id}", match: :first)) do
refresh # Trigger a refresh of notes.
wait_for_requests
expect(page).to have_content "commented on commit #{note.commit_id[0...7]}"
end
end
end
2017-09-10 17:25:29 +05:30
end
2017-08-17 22:00:37 +05:30
end