diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-13 00:08:46 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-13 00:08:46 +0000 |
commit | 47d1f417f03aca055b2ba49c32bb6fb01c459831 (patch) | |
tree | 200f05f28369cbf3a34abcb4a3c388558268b86f /spec/features/merge_request | |
parent | 006e89697dd5165f355afc20fc6bb0cdfa7b381a (diff) | |
download | gitlab-ce-47d1f417f03aca055b2ba49c32bb6fb01c459831.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/features/merge_request')
-rw-r--r-- | spec/features/merge_request/user_interacts_with_batched_mr_diffs_spec.rb | 111 |
1 files changed, 111 insertions, 0 deletions
diff --git a/spec/features/merge_request/user_interacts_with_batched_mr_diffs_spec.rb b/spec/features/merge_request/user_interacts_with_batched_mr_diffs_spec.rb new file mode 100644 index 00000000000..92d90926c0a --- /dev/null +++ b/spec/features/merge_request/user_interacts_with_batched_mr_diffs_spec.rb @@ -0,0 +1,111 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe 'Batch diffs', :js do + include MergeRequestDiffHelpers + include RepoHelpers + + let(:project) { create(:project, :repository) } + let(:merge_request) { create(:merge_request, source_project: project, source_branch: 'master', target_branch: 'empty-branch') } + + before do + stub_feature_flags(single_mr_diff_view: true) + stub_feature_flags(diffs_batch_load: true) + + sign_in(project.owner) + + visit diffs_project_merge_request_path(merge_request.project, merge_request) + wait_for_requests + + # Add discussion to first line of first file + click_diff_line(find('.diff-file.file-holder:first-of-type tr.line_holder.new:first-of-type')) + page.within('.js-discussion-note-form') do + fill_in('note_note', with: 'First Line Comment') + click_button('Comment') + end + + # Add discussion to first line of last file + click_diff_line(find('.diff-file.file-holder:last-of-type tr.line_holder.new:first-of-type')) + page.within('.js-discussion-note-form') do + fill_in('note_note', with: 'Last Line Comment') + click_button('Comment') + end + + wait_for_requests + end + + it 'assigns discussions to diff files across multiple batch pages' do + # Reload so we know the discussions are persisting across batch loads + visit page.current_url + + # Wait for JS to settle + wait_for_requests + + expect(page).to have_selector('.diff-files-holder .file-holder', count: 39) + + # Confirm discussions are applied to appropriate files (should be contained in multiple diff pages) + page.within('.diff-file.file-holder:first-of-type .notes .timeline-entry .note .note-text') do + expect(page).to have_content('First Line Comment') + end + + page.within('.diff-file.file-holder:last-of-type .notes .timeline-entry .note .note-text') do + expect(page).to have_content('Last Line Comment') + end + end + + context 'when user visits a URL with a link directly to to a discussion' do + context 'which is in the first batched page of diffs' do + it 'scrolls to the correct discussion' do + page.within('.diff-file.file-holder:first-of-type') do + click_link('just now') + end + + visit page.current_url + + wait_for_requests + + # Confirm scrolled to correct UI element + expect(page.find('.diff-file.file-holder:first-of-type .discussion-notes .timeline-entry li.note[id]').obscured?).to be_falsey + expect(page.find('.diff-file.file-holder:last-of-type .discussion-notes .timeline-entry li.note[id]').obscured?).to be_truthy + end + end + + context 'which is in at least page 2 of the batched pages of diffs' do + it 'scrolls to the correct discussion' do + page.within('.diff-file.file-holder:last-of-type') do + click_link('just now') + end + + visit page.current_url + + wait_for_requests + + # Confirm scrolled to correct UI element + expect(page.find('.diff-file.file-holder:first-of-type .discussion-notes .timeline-entry li.note[id]').obscured?).to be_truthy + expect(page.find('.diff-file.file-holder:last-of-type .discussion-notes .timeline-entry li.note[id]').obscured?).to be_falsey + end + end + end + + context 'when user switches view styles' do + before do + find('.js-show-diff-settings').click + click_button 'Side-by-side' + + wait_for_requests + end + + it 'has the correct discussions applied to files across batched pages' do + expect(page).to have_selector('.diff-files-holder .file-holder', count: 39) + + page.within('.diff-file.file-holder:first-of-type .notes .timeline-entry .note .note-text') do + expect(page).to have_content('First Line Comment') + end + + page.within('.diff-file.file-holder:last-of-type .notes .timeline-entry .note .note-text') do + expect(page).to have_content('Last Line Comment') + end + end + end +end |