2019-07-25 05:24:42 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-10-04 22:31:34 +00:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-16 18:09:01 +00:00
|
|
|
RSpec.describe 'User views diffs', :js do
|
2017-10-04 22:31:34 +00:00
|
|
|
let(:merge_request) do
|
|
|
|
create(:merge_request_with_diffs, source_project: project, target_project: project, source_branch: 'merge-test')
|
|
|
|
end
|
2020-08-11 03:11:00 +00:00
|
|
|
|
2017-10-04 22:31:34 +00:00
|
|
|
let(:project) { create(:project, :public, :repository) }
|
2020-02-20 18:08:51 +00:00
|
|
|
let(:view) { 'inline' }
|
2017-10-04 22:31:34 +00:00
|
|
|
|
|
|
|
before do
|
2020-02-20 18:08:51 +00:00
|
|
|
visit(diffs_project_merge_request_path(project, merge_request, view: view))
|
2017-10-04 22:31:34 +00:00
|
|
|
|
|
|
|
wait_for_requests
|
2018-10-03 09:05:43 +00:00
|
|
|
|
|
|
|
find('.js-toggle-tree-list').click
|
2017-10-04 22:31:34 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
shared_examples 'unfold diffs' do
|
2019-08-10 02:36:32 +00:00
|
|
|
it 'unfolds diffs upwards' do
|
2017-10-04 22:31:34 +00:00
|
|
|
first('.js-unfold').click
|
2020-02-20 18:08:51 +00:00
|
|
|
|
2020-12-15 00:10:07 +00:00
|
|
|
page.within('.file-holder[id="2f6fcd96b88b36ce98c38da085c795a27d92a3dd"]') do
|
|
|
|
expect(find('.text-file')).to have_content('fileutils')
|
2021-06-18 18:10:13 +00:00
|
|
|
expect(page).to have_selector('[data-interop-type="new"] [data-linenumber="1"]')
|
2020-02-20 18:08:51 +00:00
|
|
|
end
|
2017-10-04 22:31:34 +00:00
|
|
|
end
|
2019-08-10 02:36:32 +00:00
|
|
|
|
2020-02-20 18:08:51 +00:00
|
|
|
it 'unfolds diffs in the middle' do
|
|
|
|
page.within('.file-holder[id="2f6fcd96b88b36ce98c38da085c795a27d92a3dd"]') do
|
2022-04-20 21:08:12 +00:00
|
|
|
first('.js-unfold-all').click
|
2020-02-20 18:08:51 +00:00
|
|
|
|
2021-06-18 18:10:13 +00:00
|
|
|
expect(page).to have_selector('[data-interop-type="new"] [data-linenumber="24"]', count: 1)
|
|
|
|
expect(page).not_to have_selector('[data-interop-type="new"] [data-linenumber="1"]')
|
2020-02-20 18:08:51 +00:00
|
|
|
end
|
2019-08-10 02:36:32 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'unfolds diffs downwards' do
|
|
|
|
first('.js-unfold-down').click
|
|
|
|
expect(find('.file-holder[id="2f6fcd96b88b36ce98c38da085c795a27d92a3dd"] .text-file')).to have_content('.popen3')
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'unfolds diffs to the end' do
|
|
|
|
page.all('.js-unfold-down').last
|
|
|
|
expect(find('.file-holder[id="6eb14e00385d2fb284765eb1cd8d420d33d63fc9"] .text-file')).to have_content('end')
|
|
|
|
end
|
2017-10-04 22:31:34 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows diffs' do
|
2019-01-24 14:48:03 +00:00
|
|
|
find('.js-show-diff-settings').click
|
|
|
|
|
2017-10-04 22:31:34 +00:00
|
|
|
expect(page).to have_css('.tab-content #diffs.active')
|
|
|
|
expect(page).to have_css('#parallel-diff-btn', count: 1)
|
|
|
|
expect(page).to have_css('#inline-diff-btn', count: 1)
|
|
|
|
end
|
|
|
|
|
2018-05-29 14:49:28 +00:00
|
|
|
it 'hides loading spinner after load' do
|
|
|
|
expect(page).not_to have_selector('.mr-loading-status .loading', visible: true)
|
|
|
|
end
|
|
|
|
|
2021-07-27 00:08:48 +00:00
|
|
|
it 'expands all diffs', quarantine: 'https://gitlab.com/gitlab-org/gitlab/-/issues/333628' do
|
2020-11-07 00:08:58 +00:00
|
|
|
first('.diff-toggle-caret').click
|
2019-03-11 13:09:36 +00:00
|
|
|
|
|
|
|
expect(page).to have_button('Expand all')
|
|
|
|
|
|
|
|
click_button 'Expand all'
|
2021-06-04 03:10:08 +00:00
|
|
|
wait_for_requests
|
2019-03-11 13:09:36 +00:00
|
|
|
|
|
|
|
expect(page).not_to have_button('Expand all')
|
|
|
|
end
|
|
|
|
|
2017-10-04 22:31:34 +00:00
|
|
|
context 'when in the inline view' do
|
|
|
|
include_examples 'unfold diffs'
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when in the side-by-side view' do
|
2020-02-20 18:08:51 +00:00
|
|
|
let(:view) { 'parallel' }
|
2017-10-04 22:31:34 +00:00
|
|
|
|
|
|
|
it 'shows diffs in parallel' do
|
|
|
|
expect(page).to have_css('.parallel')
|
|
|
|
end
|
|
|
|
|
2018-06-21 12:22:40 +00:00
|
|
|
it 'toggles container class' do
|
|
|
|
expect(page).not_to have_css('.content-wrapper > .container-fluid.container-limited')
|
|
|
|
|
|
|
|
click_link 'Commits'
|
|
|
|
|
|
|
|
expect(page).to have_css('.content-wrapper > .container-fluid.container-limited')
|
|
|
|
end
|
|
|
|
|
2017-10-04 22:31:34 +00:00
|
|
|
include_examples 'unfold diffs'
|
|
|
|
end
|
|
|
|
end
|