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

96 lines
2.8 KiB
Ruby
Raw Normal View History

2019-10-12 21:52:04 +05:30
# frozen_string_literal: true
2018-03-17 18:26:18 +05:30
require 'spec_helper'
2020-06-23 00:09:42 +05:30
RSpec.describe 'User views diffs', :js do
2018-03-17 18:26:18 +05:30
let(:merge_request) do
create(:merge_request_with_diffs, source_project: project, target_project: project, source_branch: 'merge-test')
end
2020-10-24 23:57:45 +05:30
2018-03-17 18:26:18 +05:30
let(:project) { create(:project, :public, :repository) }
2020-04-08 14:13:33 +05:30
let(:view) { 'inline' }
2018-03-17 18:26:18 +05:30
before do
2020-04-08 14:13:33 +05:30
visit(diffs_project_merge_request_path(project, merge_request, view: view))
2018-03-17 18:26:18 +05:30
wait_for_requests
2018-12-05 23:21:45 +05:30
find('.js-toggle-tree-list').click
2018-03-17 18:26:18 +05:30
end
shared_examples 'unfold diffs' do
2019-10-12 21:52:04 +05:30
it 'unfolds diffs upwards' do
2018-03-17 18:26:18 +05:30
first('.js-unfold').click
2020-04-08 14:13:33 +05:30
2021-02-22 17:27:13 +05:30
page.within('.file-holder[id="2f6fcd96b88b36ce98c38da085c795a27d92a3dd"]') do
expect(find('.text-file')).to have_content('fileutils')
2021-09-30 23:02:18 +05:30
expect(page).to have_selector('[data-interop-type="new"] [data-linenumber="1"]')
2020-04-08 14:13:33 +05:30
end
2018-03-17 18:26:18 +05:30
end
2019-10-12 21:52:04 +05:30
2020-04-08 14:13:33 +05:30
it 'unfolds diffs in the middle' do
page.within('.file-holder[id="2f6fcd96b88b36ce98c38da085c795a27d92a3dd"]') do
all('.js-unfold-all')[1].click
2021-09-30 23:02:18 +05:30
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-04-08 14:13:33 +05:30
end
2019-10-12 21:52:04 +05:30
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
2018-03-17 18:26:18 +05:30
end
it 'shows diffs' do
2019-03-02 22:35:43 +05:30
find('.js-show-diff-settings').click
2018-03-17 18:26:18 +05:30
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-11-08 19:23:39 +05:30
it 'hides loading spinner after load' do
expect(page).not_to have_selector('.mr-loading-status .loading', visible: true)
end
2021-10-27 15:23:28 +05:30
it 'expands all diffs', quarantine: 'https://gitlab.com/gitlab-org/gitlab/-/issues/333628' do
2021-01-29 00:20:46 +05:30
first('.diff-toggle-caret').click
2019-07-07 11:18:12 +05:30
expect(page).to have_button('Expand all')
click_button 'Expand all'
2021-09-04 01:27:46 +05:30
wait_for_requests
2019-07-07 11:18:12 +05:30
expect(page).not_to have_button('Expand all')
end
2018-03-17 18:26:18 +05:30
context 'when in the inline view' do
include_examples 'unfold diffs'
end
context 'when in the side-by-side view' do
2020-04-08 14:13:33 +05:30
let(:view) { 'parallel' }
2018-03-17 18:26:18 +05:30
it 'shows diffs in parallel' do
expect(page).to have_css('.parallel')
end
2018-11-08 19:23:39 +05:30
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
2018-03-17 18:26:18 +05:30
include_examples 'unfold diffs'
end
end