2017-08-01 14:03:07 -04:00
|
|
|
require 'rails_helper'
|
2016-08-05 07:15:06 -04:00
|
|
|
|
2017-08-01 14:03:07 -04:00
|
|
|
describe 'Merge request > User resolves conflicts', :js do
|
2017-07-26 17:52:10 -04:00
|
|
|
let(:project) { create(:project, :repository) }
|
2017-08-01 14:03:07 -04:00
|
|
|
let(:user) { project.creator }
|
2016-08-05 07:15:06 -04:00
|
|
|
|
2017-07-13 03:58:05 -04:00
|
|
|
before do
|
|
|
|
# In order to have the diffs collapsed, we need to disable the increase feature
|
|
|
|
stub_feature_flags(gitlab_git_diff_size_limit_increase: false)
|
|
|
|
end
|
2016-08-05 07:15:06 -04:00
|
|
|
|
|
|
|
def create_merge_request(source_branch)
|
2018-03-27 23:20:12 -04:00
|
|
|
create(:merge_request, source_branch: source_branch, target_branch: 'conflict-start', source_project: project, merge_status: :unchecked) do |mr|
|
2016-08-05 07:15:06 -04:00
|
|
|
mr.mark_as_unmergeable
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-10-05 08:57:57 -04:00
|
|
|
shared_examples "conflicts are resolved in Interactive mode" do
|
|
|
|
it 'conflicts are resolved in Interactive mode' do
|
|
|
|
within find('.files-wrapper .diff-file', text: 'files/ruby/popen.rb') do
|
|
|
|
click_button 'Use ours'
|
|
|
|
end
|
2016-08-05 07:15:06 -04:00
|
|
|
|
2016-10-05 08:57:57 -04:00
|
|
|
within find('.files-wrapper .diff-file', text: 'files/ruby/regex.rb') do
|
|
|
|
all('button', text: 'Use ours').each do |button|
|
2017-10-02 13:51:16 -04:00
|
|
|
button.send_keys(:return)
|
2016-10-05 08:57:57 -04:00
|
|
|
end
|
|
|
|
end
|
2016-08-05 07:15:06 -04:00
|
|
|
|
2018-05-11 15:41:46 -04:00
|
|
|
find_button('Commit to source branch').send_keys(:return)
|
2016-08-05 07:15:06 -04:00
|
|
|
|
2016-10-05 08:57:57 -04:00
|
|
|
expect(page).to have_content('All merge conflicts were resolved')
|
|
|
|
merge_request.reload_diff
|
2016-08-05 07:15:06 -04:00
|
|
|
|
2017-08-08 09:25:00 -04:00
|
|
|
wait_for_requests
|
|
|
|
|
2016-10-05 08:57:57 -04:00
|
|
|
click_on 'Changes'
|
2017-05-17 14:25:13 -04:00
|
|
|
wait_for_requests
|
2016-08-05 07:15:06 -04:00
|
|
|
|
2016-10-05 08:57:57 -04:00
|
|
|
within find('.diff-file', text: 'files/ruby/popen.rb') do
|
|
|
|
expect(page).to have_selector('.line_content.new', text: "vars = { 'PWD' => path }")
|
|
|
|
expect(page).to have_selector('.line_content.new', text: "options = { chdir: path }")
|
2016-08-05 07:15:06 -04:00
|
|
|
end
|
2016-09-25 16:45:58 -04:00
|
|
|
|
2016-10-05 08:57:57 -04:00
|
|
|
within find('.diff-file', text: 'files/ruby/regex.rb') do
|
|
|
|
expect(page).to have_selector('.line_content.new', text: "def username_regexp")
|
|
|
|
expect(page).to have_selector('.line_content.new', text: "def project_name_regexp")
|
|
|
|
expect(page).to have_selector('.line_content.new', text: "def path_regexp")
|
|
|
|
expect(page).to have_selector('.line_content.new', text: "def archive_formats_regexp")
|
|
|
|
expect(page).to have_selector('.line_content.new', text: "def git_reference_regexp")
|
|
|
|
expect(page).to have_selector('.line_content.new', text: "def default_regexp")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2016-09-25 16:45:58 -04:00
|
|
|
|
2016-10-05 08:57:57 -04:00
|
|
|
shared_examples "conflicts are resolved in Edit inline mode" do
|
|
|
|
it 'conflicts are resolved in Edit inline mode' do
|
|
|
|
expect(find('#conflicts')).to have_content('popen.rb')
|
2016-09-25 16:45:58 -04:00
|
|
|
|
2016-10-05 08:57:57 -04:00
|
|
|
within find('.files-wrapper .diff-file', text: 'files/ruby/popen.rb') do
|
|
|
|
click_button 'Edit inline'
|
2017-05-17 14:25:13 -04:00
|
|
|
wait_for_requests
|
2017-10-16 13:37:52 -04:00
|
|
|
find('.files-wrapper .diff-file pre')
|
2016-10-05 08:57:57 -04:00
|
|
|
execute_script('ace.edit($(".files-wrapper .diff-file pre")[0]).setValue("One morning");')
|
2016-09-25 16:45:58 -04:00
|
|
|
end
|
2016-10-05 08:57:57 -04:00
|
|
|
|
|
|
|
within find('.files-wrapper .diff-file', text: 'files/ruby/regex.rb') do
|
|
|
|
click_button 'Edit inline'
|
2017-05-17 14:25:13 -04:00
|
|
|
wait_for_requests
|
2017-10-16 13:37:52 -04:00
|
|
|
find('.files-wrapper .diff-file pre')
|
2016-10-05 08:57:57 -04:00
|
|
|
execute_script('ace.edit($(".files-wrapper .diff-file pre")[1]).setValue("Gregor Samsa woke from troubled dreams");')
|
|
|
|
end
|
|
|
|
|
2018-05-11 15:41:46 -04:00
|
|
|
find_button('Commit to source branch').send_keys(:return)
|
2017-08-08 09:25:00 -04:00
|
|
|
|
2016-10-05 08:57:57 -04:00
|
|
|
expect(page).to have_content('All merge conflicts were resolved')
|
|
|
|
merge_request.reload_diff
|
|
|
|
|
2017-08-08 09:25:00 -04:00
|
|
|
wait_for_requests
|
|
|
|
|
2016-10-05 08:57:57 -04:00
|
|
|
click_on 'Changes'
|
2017-05-17 14:25:13 -04:00
|
|
|
wait_for_requests
|
2016-10-05 08:57:57 -04:00
|
|
|
|
|
|
|
expect(page).to have_content('One morning')
|
|
|
|
expect(page).to have_content('Gregor Samsa woke from troubled dreams')
|
2016-08-05 07:15:06 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-10-05 08:57:57 -04:00
|
|
|
context 'can be resolved in the UI' do
|
2016-09-29 21:26:01 -04:00
|
|
|
before do
|
2017-12-22 03:18:28 -05:00
|
|
|
project.add_developer(user)
|
2017-06-21 19:44:10 -04:00
|
|
|
sign_in(user)
|
2016-10-05 08:57:57 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'the conflicts are resolvable' do
|
|
|
|
let(:merge_request) { create_merge_request('conflict-resolvable') }
|
|
|
|
|
2017-06-14 14:18:56 -04:00
|
|
|
before do
|
2017-07-06 12:20:50 -04:00
|
|
|
visit project_merge_request_path(project, merge_request)
|
2017-06-14 14:18:56 -04:00
|
|
|
end
|
2016-10-05 08:57:57 -04:00
|
|
|
|
|
|
|
it 'shows a link to the conflict resolution page' do
|
2018-01-27 00:35:53 -05:00
|
|
|
expect(page).to have_link('conflicts', href: %r{/conflicts\Z})
|
2016-10-05 08:57:57 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'in Inline view mode' do
|
2017-06-14 14:18:56 -04:00
|
|
|
before do
|
2018-01-27 00:35:53 -05:00
|
|
|
click_link('conflicts', href: %r{/conflicts\Z})
|
2017-06-14 14:18:56 -04:00
|
|
|
end
|
2016-10-05 08:57:57 -04:00
|
|
|
|
2018-09-10 15:40:38 -04:00
|
|
|
include_examples "conflicts are resolved in Interactive mode"
|
|
|
|
include_examples "conflicts are resolved in Edit inline mode"
|
2016-10-05 08:57:57 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'in Parallel view mode' do
|
|
|
|
before do
|
2018-01-27 00:35:53 -05:00
|
|
|
click_link('conflicts', href: %r{/conflicts\Z})
|
2016-10-05 08:57:57 -04:00
|
|
|
click_button 'Side-by-side'
|
|
|
|
end
|
2016-09-29 21:26:01 -04:00
|
|
|
|
2018-09-10 15:40:38 -04:00
|
|
|
include_examples "conflicts are resolved in Interactive mode"
|
|
|
|
include_examples "conflicts are resolved in Edit inline mode"
|
2016-10-05 08:57:57 -04:00
|
|
|
end
|
2016-09-29 21:26:01 -04:00
|
|
|
end
|
|
|
|
|
2016-10-05 08:57:57 -04:00
|
|
|
context 'the conflict contain markers' do
|
|
|
|
let(:merge_request) { create_merge_request('conflict-contains-conflict-markers') }
|
|
|
|
|
|
|
|
before do
|
2017-07-06 12:20:50 -04:00
|
|
|
visit project_merge_request_path(project, merge_request)
|
2018-01-27 00:35:53 -05:00
|
|
|
click_link('conflicts', href: %r{/conflicts\Z})
|
2016-10-05 08:57:57 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'conflicts can not be resolved in Interactive mode' do
|
|
|
|
within find('.files-wrapper .diff-file', text: 'files/markdown/ruby-style-guide.md') do
|
|
|
|
expect(page).not_to have_content 'Interactive mode'
|
|
|
|
expect(page).not_to have_content 'Edit inline'
|
|
|
|
end
|
|
|
|
end
|
2016-09-29 21:26:01 -04:00
|
|
|
|
2018-06-21 08:22:40 -04:00
|
|
|
# TODO: https://gitlab.com/gitlab-org/gitlab-ce/issues/48034
|
|
|
|
xit 'conflicts are resolved in Edit inline mode' do
|
2016-09-30 18:42:36 -04:00
|
|
|
within find('.files-wrapper .diff-file', text: 'files/markdown/ruby-style-guide.md') do
|
2017-05-17 14:25:13 -04:00
|
|
|
wait_for_requests
|
2017-10-16 13:37:52 -04:00
|
|
|
find('.files-wrapper .diff-file pre')
|
2016-09-30 18:42:36 -04:00
|
|
|
execute_script('ace.edit($(".files-wrapper .diff-file pre")[0]).setValue("Gregor Samsa woke from troubled dreams");')
|
2016-09-29 21:26:01 -04:00
|
|
|
end
|
|
|
|
|
2018-05-11 15:41:46 -04:00
|
|
|
click_button 'Commit to source branch'
|
2016-09-29 21:26:01 -04:00
|
|
|
|
|
|
|
expect(page).to have_content('All merge conflicts were resolved')
|
|
|
|
|
|
|
|
merge_request.reload_diff
|
|
|
|
|
2017-08-08 09:25:00 -04:00
|
|
|
wait_for_requests
|
|
|
|
|
2016-09-29 21:26:01 -04:00
|
|
|
click_on 'Changes'
|
2017-05-17 14:25:13 -04:00
|
|
|
wait_for_requests
|
2017-01-24 13:50:22 -05:00
|
|
|
click_link 'Expand all'
|
2017-05-17 14:25:13 -04:00
|
|
|
wait_for_requests
|
2016-09-29 21:26:01 -04:00
|
|
|
|
|
|
|
expect(page).to have_content('Gregor Samsa woke from troubled dreams')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-08-05 07:15:06 -04:00
|
|
|
UNRESOLVABLE_CONFLICTS = {
|
|
|
|
'conflict-too-large' => 'when the conflicts contain a large file',
|
|
|
|
'conflict-binary-file' => 'when the conflicts contain a binary file',
|
2016-08-23 11:37:14 -04:00
|
|
|
'conflict-missing-side' => 'when the conflicts contain a file edited in one branch and deleted in another',
|
2017-05-03 07:22:03 -04:00
|
|
|
'conflict-non-utf8' => 'when the conflicts contain a non-UTF-8 file'
|
2017-02-21 18:32:18 -05:00
|
|
|
}.freeze
|
2016-08-05 07:15:06 -04:00
|
|
|
|
|
|
|
UNRESOLVABLE_CONFLICTS.each do |source_branch, description|
|
|
|
|
context description do
|
|
|
|
let(:merge_request) { create_merge_request(source_branch) }
|
|
|
|
|
|
|
|
before do
|
2017-12-22 03:18:28 -05:00
|
|
|
project.add_developer(user)
|
2017-06-21 19:44:10 -04:00
|
|
|
sign_in(user)
|
2017-07-06 12:20:50 -04:00
|
|
|
visit project_merge_request_path(project, merge_request)
|
2016-08-05 07:15:06 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not show a link to the conflict resolution page' do
|
2018-01-27 00:35:53 -05:00
|
|
|
expect(page).not_to have_link('conflicts', href: %r{/conflicts\Z})
|
2016-08-05 07:15:06 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows an error if the conflicts page is visited directly' do
|
|
|
|
visit current_url + '/conflicts'
|
2017-05-17 14:25:13 -04:00
|
|
|
wait_for_requests
|
2016-08-05 07:15:06 -04:00
|
|
|
|
2016-08-11 13:54:55 -04:00
|
|
|
expect(find('#conflicts')).to have_content('Please try to resolve them locally.')
|
2016-08-05 07:15:06 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|