diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-05-19 10:33:21 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-05-19 10:33:21 +0300 |
commit | 36a59d088eca61b834191dacea009677a96c052f (patch) | |
tree | e4f33972dab5d8ef79e3944a9f403035fceea43f /spec/features/projects/blobs/blame_spec.rb | |
parent | a1761f15ec2cae7c7f7bbda39a75494add0dfd6f (diff) |
Add latest changes from gitlab-org/gitlab@15-0-stable-eev15.0.0-rc42
Diffstat (limited to 'spec/features/projects/blobs/blame_spec.rb')
-rw-r--r-- | spec/features/projects/blobs/blame_spec.rb | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/spec/features/projects/blobs/blame_spec.rb b/spec/features/projects/blobs/blame_spec.rb new file mode 100644 index 00000000000..bb3b5cd931c --- /dev/null +++ b/spec/features/projects/blobs/blame_spec.rb @@ -0,0 +1,67 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe 'File blame', :js do + include TreeHelper + + let_it_be(:project) { create(:project, :public, :repository) } + + let(:path) { 'CHANGELOG' } + + def visit_blob_blame(path) + visit project_blame_path(project, tree_join('master', path)) + wait_for_all_requests + end + + it 'displays the blame page without pagination' do + visit_blob_blame(path) + + expect(page).to have_css('.blame-commit') + expect(page).not_to have_css('.gl-pagination') + end + + context 'when blob length is over the blame range limit' do + before do + stub_const('Projects::BlameService::PER_PAGE', 2) + end + + it 'displays two first lines of the file with pagination' do + visit_blob_blame(path) + + expect(page).to have_css('.blame-commit') + expect(page).to have_css('.gl-pagination') + + expect(page).to have_css('#L1') + expect(page).not_to have_css('#L3') + expect(find('.page-link.active')).to have_text('1') + end + + context 'when user clicks on the next button' do + before do + visit_blob_blame(path) + + find('.js-next-button').click + end + + it 'displays next two lines of the file with pagination' do + expect(page).not_to have_css('#L1') + expect(page).to have_css('#L3') + expect(find('.page-link.active')).to have_text('2') + end + end + + context 'when feature flag disabled' do + before do + stub_feature_flags(blame_page_pagination: false) + end + + it 'displays the blame page without pagination' do + visit_blob_blame(path) + + expect(page).to have_css('.blame-commit') + expect(page).not_to have_css('.gl-pagination') + end + end + end +end |