2019-07-25 01:24:42 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-04-06 12:36:38 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-16 14:09:01 -04:00
|
|
|
RSpec.describe 'File blob', :js do
|
2017-11-05 22:25:44 -05:00
|
|
|
include MobileHelpers
|
|
|
|
|
2017-07-24 18:51:14 -04:00
|
|
|
let(:project) { create(:project, :public, :repository) }
|
2017-04-13 12:50:40 -04:00
|
|
|
|
2021-12-06 22:12:22 -05:00
|
|
|
def visit_blob(path, anchor: nil, ref: 'master', **additional_args)
|
|
|
|
visit project_blob_path(project, File.join(ref, path), anchor: anchor, **additional_args)
|
2017-05-08 19:50:23 -04:00
|
|
|
|
2017-05-17 14:25:13 -04:00
|
|
|
wait_for_requests
|
2017-04-13 12:50:40 -04:00
|
|
|
end
|
|
|
|
|
2021-07-26 02:10:00 -04:00
|
|
|
def create_file(file_name, content)
|
|
|
|
project.add_maintainer(project.creator)
|
|
|
|
|
|
|
|
Files::CreateService.new(
|
|
|
|
project,
|
|
|
|
project.creator,
|
|
|
|
start_branch: 'master',
|
|
|
|
branch_name: 'master',
|
|
|
|
commit_message: "Add #{file_name}",
|
|
|
|
file_path: file_name,
|
|
|
|
file_content: <<-SPEC.strip_heredoc
|
|
|
|
#{content}
|
|
|
|
SPEC
|
|
|
|
).execute
|
|
|
|
end
|
|
|
|
|
2022-02-01 07:17:55 -05:00
|
|
|
context 'with refactor_blob_viewer feature flag enabled' do
|
|
|
|
context 'Ruby file' do
|
2017-04-25 16:22:56 -04:00
|
|
|
before do
|
2022-02-01 07:17:55 -05:00
|
|
|
visit_blob('files/ruby/popen.rb')
|
2018-05-22 06:30:48 -04:00
|
|
|
|
|
|
|
wait_for_requests
|
2017-04-25 16:22:56 -04:00
|
|
|
end
|
|
|
|
|
2022-02-01 07:17:55 -05:00
|
|
|
it 'displays the blob' do
|
2017-04-25 16:22:56 -04:00
|
|
|
aggregate_failures do
|
2022-02-01 07:17:55 -05:00
|
|
|
# shows highlighted Ruby code
|
|
|
|
expect(page).to have_css(".js-syntax-highlight")
|
|
|
|
expect(page).to have_content("require 'fileutils'")
|
2017-04-25 16:22:56 -04:00
|
|
|
|
2022-02-01 07:17:55 -05:00
|
|
|
# does not show a viewer switcher
|
|
|
|
expect(page).not_to have_selector('.js-blob-viewer-switcher')
|
2017-04-25 16:22:56 -04:00
|
|
|
|
2022-02-01 07:17:55 -05:00
|
|
|
# shows an enabled copy button
|
|
|
|
expect(page).to have_selector('.js-copy-blob-source-btn:not(.disabled)')
|
2017-04-13 13:11:52 -04:00
|
|
|
|
|
|
|
# shows a raw button
|
|
|
|
expect(page).to have_link('Open raw')
|
2017-04-25 16:22:56 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2022-02-01 07:17:55 -05:00
|
|
|
it 'displays file actions on all screen sizes' do
|
|
|
|
file_actions_selector = '.file-actions'
|
|
|
|
|
|
|
|
resize_screen_sm
|
|
|
|
expect(page).to have_selector(file_actions_selector, visible: true)
|
|
|
|
|
|
|
|
resize_screen_xs
|
|
|
|
expect(page).to have_selector(file_actions_selector, visible: true)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'Markdown file' do
|
|
|
|
context 'visiting directly' do
|
2017-04-25 16:22:56 -04:00
|
|
|
before do
|
2022-02-01 07:17:55 -05:00
|
|
|
visit_blob('files/markdown/ruby-style-guide.md')
|
2017-04-25 16:22:56 -04:00
|
|
|
|
2017-05-17 14:25:13 -04:00
|
|
|
wait_for_requests
|
2017-04-25 16:22:56 -04:00
|
|
|
end
|
2017-04-13 12:50:40 -04:00
|
|
|
|
2022-02-01 07:17:55 -05:00
|
|
|
it 'displays the blob using the rich viewer' do
|
2017-04-25 16:22:56 -04:00
|
|
|
aggregate_failures do
|
2022-02-01 07:17:55 -05:00
|
|
|
# hides the simple viewer
|
|
|
|
expect(page).not_to have_selector('.blob-viewer[data-type="simple"]')
|
|
|
|
expect(page).to have_selector('.blob-viewer[data-type="rich"]')
|
2017-04-13 12:50:40 -04:00
|
|
|
|
2022-02-01 07:17:55 -05:00
|
|
|
# shows rendered Markdown
|
|
|
|
expect(page).to have_link("PEP-8")
|
2017-04-25 16:22:56 -04:00
|
|
|
|
2022-02-01 07:17:55 -05:00
|
|
|
# shows a viewer switcher
|
|
|
|
expect(page).to have_selector('.js-blob-viewer-switcher')
|
|
|
|
|
|
|
|
# shows a disabled copy button
|
|
|
|
expect(page).to have_selector('.js-copy-blob-source-btn.disabled')
|
|
|
|
|
|
|
|
# shows a raw button
|
|
|
|
expect(page).to have_link('Open raw')
|
2017-04-25 16:22:56 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2022-02-01 07:17:55 -05:00
|
|
|
context 'switching to the simple viewer' do
|
2017-04-25 16:22:56 -04:00
|
|
|
before do
|
2022-02-01 07:17:55 -05:00
|
|
|
find('.js-blob-viewer-switch-btn[data-viewer=simple]').click
|
2017-04-25 16:22:56 -04:00
|
|
|
|
2017-05-17 14:25:13 -04:00
|
|
|
wait_for_requests
|
2017-04-25 16:22:56 -04:00
|
|
|
end
|
|
|
|
|
2022-02-01 07:17:55 -05:00
|
|
|
it 'displays the blob using the simple viewer' do
|
2017-04-25 16:22:56 -04:00
|
|
|
aggregate_failures do
|
2022-02-01 07:17:55 -05:00
|
|
|
# hides the rich viewer
|
|
|
|
expect(page).to have_selector('.blob-viewer[data-type="simple"]')
|
|
|
|
expect(page).not_to have_selector('.blob-viewer[data-type="rich"]')
|
|
|
|
|
|
|
|
# shows highlighted Markdown code
|
|
|
|
expect(page).to have_css(".js-syntax-highlight")
|
|
|
|
expect(page).to have_content("[PEP-8](http://www.python.org/dev/peps/pep-0008/)")
|
2017-04-25 16:22:56 -04:00
|
|
|
|
|
|
|
# shows an enabled copy button
|
|
|
|
expect(page).to have_selector('.js-copy-blob-source-btn:not(.disabled)')
|
|
|
|
end
|
|
|
|
end
|
2021-04-26 05:09:53 -04:00
|
|
|
|
2022-02-01 07:17:55 -05:00
|
|
|
context 'switching to the rich viewer again' do
|
|
|
|
before do
|
|
|
|
find('.js-blob-viewer-switch-btn[data-viewer=rich]').click
|
2021-04-26 05:09:53 -04:00
|
|
|
|
2022-02-01 07:17:55 -05:00
|
|
|
wait_for_requests
|
|
|
|
end
|
2021-04-26 05:09:53 -04:00
|
|
|
|
2022-02-01 07:17:55 -05:00
|
|
|
it 'displays the blob using the rich viewer' do
|
|
|
|
aggregate_failures do
|
|
|
|
# hides the simple viewer
|
|
|
|
expect(page).not_to have_selector('.blob-viewer[data-type="simple"]')
|
|
|
|
expect(page).to have_selector('.blob-viewer[data-type="rich"]')
|
2021-04-26 05:09:53 -04:00
|
|
|
|
2022-02-01 07:17:55 -05:00
|
|
|
# shows a disabled copy button
|
|
|
|
expect(page).to have_selector('.js-copy-blob-source-btn.disabled')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2021-04-26 05:09:53 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2022-02-01 07:17:55 -05:00
|
|
|
context 'when ref switch' do
|
|
|
|
def switch_ref_to(ref_name)
|
|
|
|
first('.qa-branches-select').click # rubocop:disable QA/SelectorUsage
|
2021-04-26 05:09:53 -04:00
|
|
|
|
2022-02-01 07:17:55 -05:00
|
|
|
page.within '.project-refs-form' do
|
|
|
|
click_link ref_name
|
|
|
|
wait_for_requests
|
|
|
|
end
|
2021-04-26 05:09:53 -04:00
|
|
|
end
|
|
|
|
|
2022-02-01 07:17:55 -05:00
|
|
|
it 'displays no highlighted number of different ref' do
|
|
|
|
Files::UpdateService.new(
|
|
|
|
project,
|
|
|
|
project.first_owner,
|
|
|
|
commit_message: 'Update',
|
|
|
|
start_branch: 'feature',
|
|
|
|
branch_name: 'feature',
|
|
|
|
file_path: 'files/js/application.js',
|
|
|
|
file_content: 'new content'
|
|
|
|
).execute
|
2021-04-26 05:09:53 -04:00
|
|
|
|
2022-02-01 07:17:55 -05:00
|
|
|
project.commit('feature').diffs.diff_files.first
|
2021-04-26 05:09:53 -04:00
|
|
|
|
2022-02-01 07:17:55 -05:00
|
|
|
visit_blob('files/js/application.js', anchor: 'L3')
|
|
|
|
switch_ref_to('feature')
|
2021-04-26 05:09:53 -04:00
|
|
|
|
2022-02-01 07:17:55 -05:00
|
|
|
page.within '.blob-content' do
|
|
|
|
expect(page).not_to have_css('.hll')
|
|
|
|
end
|
2021-04-26 05:09:53 -04:00
|
|
|
end
|
2021-04-27 23:09:58 -04:00
|
|
|
|
2022-02-01 07:17:55 -05:00
|
|
|
context 'successfully change ref of similar name' do
|
|
|
|
before do
|
|
|
|
project.repository.create_branch('dev')
|
|
|
|
project.repository.create_branch('development')
|
|
|
|
end
|
2021-04-27 23:09:58 -04:00
|
|
|
|
2022-02-01 07:17:55 -05:00
|
|
|
it 'switch ref from longer to shorter ref name' do
|
|
|
|
visit_blob('files/js/application.js', ref: 'development')
|
|
|
|
switch_ref_to('dev')
|
2021-04-27 23:09:58 -04:00
|
|
|
|
2022-02-01 07:17:55 -05:00
|
|
|
aggregate_failures do
|
|
|
|
expect(page.find('.file-title-name').text).to eq('application.js')
|
|
|
|
expect(page).not_to have_css('flash-container')
|
|
|
|
end
|
2021-06-03 20:10:03 -04:00
|
|
|
end
|
2021-04-27 23:09:58 -04:00
|
|
|
|
2022-02-01 07:17:55 -05:00
|
|
|
it 'switch ref from shorter to longer ref name' do
|
|
|
|
visit_blob('files/js/application.js', ref: 'dev')
|
|
|
|
switch_ref_to('development')
|
2021-04-27 23:09:58 -04:00
|
|
|
|
2022-02-01 07:17:55 -05:00
|
|
|
aggregate_failures do
|
|
|
|
expect(page.find('.file-title-name').text).to eq('application.js')
|
|
|
|
expect(page).not_to have_css('flash-container')
|
|
|
|
end
|
2021-06-03 20:10:03 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2022-02-01 07:17:55 -05:00
|
|
|
it 'successfully changes ref when the ref name matches the project name' do
|
|
|
|
project.repository.create_branch(project.name)
|
2021-06-03 20:10:03 -04:00
|
|
|
|
2022-02-01 07:17:55 -05:00
|
|
|
visit_blob('files/js/application.js', ref: project.name)
|
|
|
|
switch_ref_to('master')
|
2021-06-03 20:10:03 -04:00
|
|
|
|
2022-02-01 07:17:55 -05:00
|
|
|
aggregate_failures do
|
|
|
|
expect(page.find('.file-title-name').text).to eq('application.js')
|
|
|
|
expect(page).not_to have_css('flash-container')
|
|
|
|
end
|
2021-04-27 23:09:58 -04:00
|
|
|
end
|
|
|
|
end
|
2021-04-26 05:09:53 -04:00
|
|
|
end
|
|
|
|
|
2022-02-01 07:17:55 -05:00
|
|
|
context 'Markdown rendering' do
|
2017-04-25 16:22:56 -04:00
|
|
|
before do
|
2022-02-01 07:17:55 -05:00
|
|
|
project.add_maintainer(project.creator)
|
2017-04-25 16:22:56 -04:00
|
|
|
|
2022-02-01 07:17:55 -05:00
|
|
|
Files::CreateService.new(
|
|
|
|
project,
|
|
|
|
project.creator,
|
|
|
|
start_branch: 'master',
|
|
|
|
branch_name: 'master',
|
|
|
|
commit_message: "Add RedCarpet and CommonMark Markdown ",
|
|
|
|
file_path: 'files/commonmark/file.md',
|
|
|
|
file_content: "1. one\n - sublist\n"
|
|
|
|
).execute
|
|
|
|
end
|
2017-04-25 16:22:56 -04:00
|
|
|
|
2022-02-01 07:17:55 -05:00
|
|
|
context 'when rendering default markdown' do
|
|
|
|
before do
|
|
|
|
visit_blob('files/commonmark/file.md')
|
2017-04-25 16:22:56 -04:00
|
|
|
|
2022-02-01 07:17:55 -05:00
|
|
|
wait_for_requests
|
|
|
|
end
|
2017-04-13 12:50:40 -04:00
|
|
|
|
2022-02-01 07:17:55 -05:00
|
|
|
it 'renders using CommonMark' do
|
|
|
|
aggregate_failures do
|
|
|
|
expect(page).to have_content("sublist")
|
|
|
|
expect(page).not_to have_xpath("//ol//li//ul")
|
|
|
|
end
|
2017-04-25 16:22:56 -04:00
|
|
|
end
|
|
|
|
end
|
2017-04-13 12:50:40 -04:00
|
|
|
end
|
2018-09-02 11:24:27 -04:00
|
|
|
|
2022-02-01 07:17:55 -05:00
|
|
|
context 'Markdown file (stored in LFS)' do
|
2018-09-02 11:24:27 -04:00
|
|
|
before do
|
2022-02-01 07:17:55 -05:00
|
|
|
project.add_maintainer(project.creator)
|
2018-09-02 11:24:27 -04:00
|
|
|
|
2022-02-01 07:17:55 -05:00
|
|
|
Files::CreateService.new(
|
|
|
|
project,
|
|
|
|
project.creator,
|
|
|
|
start_branch: 'master',
|
|
|
|
branch_name: 'master',
|
|
|
|
commit_message: "Add Markdown in LFS",
|
|
|
|
file_path: 'files/lfs/file.md',
|
|
|
|
file_content: project.repository.blob_at('master', 'files/lfs/lfs_object.iso').data
|
|
|
|
).execute
|
2018-09-02 11:24:27 -04:00
|
|
|
end
|
2017-04-25 16:22:56 -04:00
|
|
|
|
2022-02-01 07:17:55 -05:00
|
|
|
context 'when LFS is enabled on the project' do
|
|
|
|
before do
|
|
|
|
allow(Gitlab.config.lfs).to receive(:enabled).and_return(true)
|
|
|
|
project.update_attribute(:lfs_enabled, true)
|
2017-04-25 16:22:56 -04:00
|
|
|
|
2022-02-01 07:17:55 -05:00
|
|
|
visit_blob('files/lfs/file.md')
|
2018-05-22 06:30:48 -04:00
|
|
|
|
2022-02-01 07:17:55 -05:00
|
|
|
wait_for_requests
|
|
|
|
end
|
2017-04-25 16:22:56 -04:00
|
|
|
|
2022-02-01 07:17:55 -05:00
|
|
|
it 'displays an error' do
|
|
|
|
aggregate_failures do
|
|
|
|
# hides the simple viewer
|
|
|
|
expect(page).not_to have_selector('.blob-viewer[data-type="simple"]')
|
|
|
|
expect(page).not_to have_selector('.blob-viewer[data-type="rich"]')
|
2017-04-25 16:22:56 -04:00
|
|
|
|
2022-02-01 07:17:55 -05:00
|
|
|
# shows an error message
|
|
|
|
expect(page).to have_content('This content could not be displayed because it is stored in LFS. You can download it instead.')
|
2017-04-25 16:22:56 -04:00
|
|
|
|
2022-02-01 07:17:55 -05:00
|
|
|
# does not show a viewer switcher
|
|
|
|
expect(page).not_to have_selector('.js-blob-viewer-switcher')
|
2017-04-25 16:22:56 -04:00
|
|
|
|
2022-02-01 07:17:55 -05:00
|
|
|
# does not show a copy button
|
|
|
|
expect(page).not_to have_selector('.js-copy-blob-source-btn')
|
2017-04-13 13:11:52 -04:00
|
|
|
|
2022-02-01 07:17:55 -05:00
|
|
|
# shows a download button
|
|
|
|
expect(page).to have_link('Download')
|
|
|
|
end
|
2017-04-25 16:22:56 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2022-02-01 07:17:55 -05:00
|
|
|
context 'when LFS is disabled on the project' do
|
2017-04-25 16:22:56 -04:00
|
|
|
before do
|
2022-02-01 07:17:55 -05:00
|
|
|
visit_blob('files/lfs/file.md')
|
2017-04-25 16:22:56 -04:00
|
|
|
|
2017-05-17 14:25:13 -04:00
|
|
|
wait_for_requests
|
2017-04-25 16:22:56 -04:00
|
|
|
end
|
|
|
|
|
2022-02-01 07:17:55 -05:00
|
|
|
it 'displays the blob' do
|
2017-04-25 16:22:56 -04:00
|
|
|
aggregate_failures do
|
2022-02-01 07:17:55 -05:00
|
|
|
# shows text
|
|
|
|
expect(page).to have_content('size 1575078')
|
2017-04-25 16:22:56 -04:00
|
|
|
|
2022-02-01 07:17:55 -05:00
|
|
|
# does not show a viewer switcher
|
|
|
|
expect(page).not_to have_selector('.js-blob-viewer-switcher')
|
2017-04-25 16:22:56 -04:00
|
|
|
|
2022-02-01 07:17:55 -05:00
|
|
|
# shows an enabled copy button
|
|
|
|
expect(page).to have_selector('.js-copy-blob-source-btn:not(.disabled)')
|
|
|
|
|
|
|
|
# shows a raw button
|
|
|
|
expect(page).to have_link('Open raw')
|
2017-04-25 16:22:56 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2022-02-01 07:17:55 -05:00
|
|
|
context 'PDF file' do
|
2017-04-25 16:22:56 -04:00
|
|
|
before do
|
2022-02-01 07:17:55 -05:00
|
|
|
project.add_maintainer(project.creator)
|
|
|
|
|
|
|
|
Files::CreateService.new(
|
|
|
|
project,
|
|
|
|
project.creator,
|
|
|
|
start_branch: 'master',
|
|
|
|
branch_name: 'master',
|
|
|
|
commit_message: "Add PDF",
|
|
|
|
file_path: 'files/test.pdf',
|
|
|
|
file_content: project.repository.blob_at('add-pdf-file', 'files/pdf/test.pdf').data
|
|
|
|
).execute
|
|
|
|
|
|
|
|
visit_blob('files/test.pdf')
|
2018-05-22 06:30:48 -04:00
|
|
|
|
|
|
|
wait_for_requests
|
2017-04-25 16:22:56 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'displays the blob' do
|
|
|
|
aggregate_failures do
|
2022-02-01 07:17:55 -05:00
|
|
|
# shows rendered PDF
|
|
|
|
expect(page).to have_selector('.js-pdf-viewer')
|
2017-04-25 16:22:56 -04:00
|
|
|
|
|
|
|
# does not show a viewer switcher
|
|
|
|
expect(page).not_to have_selector('.js-blob-viewer-switcher')
|
|
|
|
|
2022-02-01 07:17:55 -05:00
|
|
|
# does not show a copy button
|
|
|
|
expect(page).not_to have_selector('.js-copy-blob-source-btn')
|
2017-04-13 13:11:52 -04:00
|
|
|
|
2022-02-01 07:17:55 -05:00
|
|
|
# shows a download button
|
|
|
|
expect(page).to have_link('Download')
|
2017-04-25 16:22:56 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2022-02-01 07:17:55 -05:00
|
|
|
context 'Jupiter Notebook file' do
|
|
|
|
before do
|
|
|
|
project.add_maintainer(project.creator)
|
|
|
|
|
|
|
|
Files::CreateService.new(
|
|
|
|
project,
|
|
|
|
project.creator,
|
|
|
|
start_branch: 'master',
|
|
|
|
branch_name: 'master',
|
|
|
|
commit_message: "Add Jupiter Notebook",
|
|
|
|
file_path: 'files/basic.ipynb',
|
|
|
|
file_content: project.repository.blob_at('add-ipython-files', 'files/ipython/basic.ipynb').data
|
|
|
|
).execute
|
2017-04-25 16:22:56 -04:00
|
|
|
|
2022-02-01 07:17:55 -05:00
|
|
|
visit_blob('files/basic.ipynb')
|
2017-04-25 16:22:56 -04:00
|
|
|
|
2022-02-01 07:17:55 -05:00
|
|
|
wait_for_requests
|
|
|
|
end
|
2018-05-22 06:30:48 -04:00
|
|
|
|
2022-02-01 07:17:55 -05:00
|
|
|
it 'displays the blob' do
|
|
|
|
aggregate_failures do
|
|
|
|
# shows rendered notebook
|
|
|
|
expect(page).to have_selector('.js-notebook-viewer-mounted')
|
|
|
|
|
|
|
|
# does show a viewer switcher
|
|
|
|
expect(page).to have_selector('.js-blob-viewer-switcher')
|
2017-04-25 16:22:56 -04:00
|
|
|
|
2022-02-01 07:17:55 -05:00
|
|
|
# show a disabled copy button
|
|
|
|
expect(page).to have_selector('.js-copy-blob-source-btn.disabled')
|
2017-04-25 16:22:56 -04:00
|
|
|
|
2022-02-01 07:17:55 -05:00
|
|
|
# shows a raw button
|
|
|
|
expect(page).to have_link('Open raw')
|
2017-04-25 16:22:56 -04:00
|
|
|
|
2022-02-01 07:17:55 -05:00
|
|
|
# shows a download button
|
|
|
|
expect(page).to have_link('Download')
|
2017-04-13 13:11:52 -04:00
|
|
|
|
2022-02-01 07:17:55 -05:00
|
|
|
# shows the rendered notebook
|
|
|
|
expect(page).to have_content('test')
|
|
|
|
end
|
2017-04-25 16:22:56 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2022-02-01 07:17:55 -05:00
|
|
|
context 'ISO file (stored in LFS)' do
|
|
|
|
context 'when LFS is enabled on the project' do
|
|
|
|
before do
|
|
|
|
allow(Gitlab.config.lfs).to receive(:enabled).and_return(true)
|
|
|
|
project.update_attribute(:lfs_enabled, true)
|
2020-03-13 20:09:30 -04:00
|
|
|
|
2022-02-01 07:17:55 -05:00
|
|
|
visit_blob('files/lfs/lfs_object.iso')
|
2020-03-13 20:09:30 -04:00
|
|
|
|
2022-02-01 07:17:55 -05:00
|
|
|
wait_for_requests
|
|
|
|
end
|
2020-03-13 20:09:30 -04:00
|
|
|
|
2022-02-01 07:17:55 -05:00
|
|
|
it 'displays the blob' do
|
|
|
|
aggregate_failures do
|
|
|
|
# shows a download link
|
|
|
|
expect(page).to have_link('Download (1.50 MiB)')
|
|
|
|
|
|
|
|
# does not show a viewer switcher
|
|
|
|
expect(page).not_to have_selector('.js-blob-viewer-switcher')
|
|
|
|
|
|
|
|
# does not show a copy button
|
|
|
|
expect(page).not_to have_selector('.js-copy-blob-source-btn')
|
|
|
|
|
|
|
|
# shows a download button
|
|
|
|
expect(page).to have_link('Download')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2020-03-13 20:09:30 -04:00
|
|
|
|
2022-02-01 07:17:55 -05:00
|
|
|
context 'when LFS is disabled on the project' do
|
|
|
|
before do
|
|
|
|
visit_blob('files/lfs/lfs_object.iso')
|
2020-03-13 20:09:30 -04:00
|
|
|
|
2022-02-01 07:17:55 -05:00
|
|
|
wait_for_requests
|
|
|
|
end
|
2020-03-13 20:09:30 -04:00
|
|
|
|
2022-02-01 07:17:55 -05:00
|
|
|
it 'displays the blob' do
|
|
|
|
aggregate_failures do
|
|
|
|
# shows text
|
|
|
|
expect(page).to have_content('size 1575078')
|
2020-03-13 20:09:30 -04:00
|
|
|
|
2022-02-01 07:17:55 -05:00
|
|
|
# does not show a viewer switcher
|
|
|
|
expect(page).not_to have_selector('.js-blob-viewer-switcher')
|
2020-03-13 20:09:30 -04:00
|
|
|
|
2022-02-01 07:17:55 -05:00
|
|
|
# shows an enabled copy button
|
|
|
|
expect(page).to have_selector('.js-copy-blob-source-btn:not(.disabled)')
|
2020-03-13 20:09:30 -04:00
|
|
|
|
2022-02-01 07:17:55 -05:00
|
|
|
# shows a raw button
|
|
|
|
expect(page).to have_link('Open raw')
|
|
|
|
end
|
|
|
|
end
|
2020-03-13 20:09:30 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2022-02-01 07:17:55 -05:00
|
|
|
context 'ZIP file' do
|
2017-04-25 16:22:56 -04:00
|
|
|
before do
|
2022-02-01 07:17:55 -05:00
|
|
|
visit_blob('Gemfile.zip')
|
2018-05-22 06:30:48 -04:00
|
|
|
|
|
|
|
wait_for_requests
|
2017-04-25 16:22:56 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'displays the blob' do
|
|
|
|
aggregate_failures do
|
|
|
|
# shows a download link
|
2022-02-01 07:17:55 -05:00
|
|
|
expect(page).to have_link('Download (2.11 KiB)')
|
2017-04-25 16:22:56 -04:00
|
|
|
|
|
|
|
# does not show a viewer switcher
|
|
|
|
expect(page).not_to have_selector('.js-blob-viewer-switcher')
|
|
|
|
|
|
|
|
# does not show a copy button
|
|
|
|
expect(page).not_to have_selector('.js-copy-blob-source-btn')
|
2017-04-13 13:11:52 -04:00
|
|
|
|
|
|
|
# shows a download button
|
|
|
|
expect(page).to have_link('Download')
|
2017-04-25 16:22:56 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2022-02-01 07:17:55 -05:00
|
|
|
context 'empty file' do
|
2017-04-25 16:22:56 -04:00
|
|
|
before do
|
2022-02-01 07:17:55 -05:00
|
|
|
project.add_maintainer(project.creator)
|
|
|
|
|
|
|
|
Files::CreateService.new(
|
|
|
|
project,
|
|
|
|
project.creator,
|
|
|
|
start_branch: 'master',
|
|
|
|
branch_name: 'master',
|
|
|
|
commit_message: "Add empty file",
|
|
|
|
file_path: 'files/empty.md',
|
|
|
|
file_content: ''
|
|
|
|
).execute
|
|
|
|
|
|
|
|
visit_blob('files/empty.md')
|
2018-05-22 06:30:48 -04:00
|
|
|
|
|
|
|
wait_for_requests
|
2017-04-25 16:22:56 -04:00
|
|
|
end
|
|
|
|
|
2022-02-01 07:17:55 -05:00
|
|
|
it 'displays an error' do
|
2017-04-25 16:22:56 -04:00
|
|
|
aggregate_failures do
|
2022-02-01 07:17:55 -05:00
|
|
|
# shows an error message
|
|
|
|
expect(page).to have_content('Empty file')
|
2017-04-25 16:22:56 -04:00
|
|
|
|
|
|
|
# does not show a viewer switcher
|
|
|
|
expect(page).not_to have_selector('.js-blob-viewer-switcher')
|
|
|
|
|
2022-02-01 07:17:55 -05:00
|
|
|
# does not show a copy button
|
|
|
|
expect(page).not_to have_selector('.js-copy-blob-source-btn')
|
2017-04-13 13:11:52 -04:00
|
|
|
|
2022-02-01 07:17:55 -05:00
|
|
|
# does not show a download or raw button
|
|
|
|
expect(page).not_to have_link('Download')
|
|
|
|
expect(page).not_to have_link('Open raw')
|
2017-04-25 16:22:56 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2022-02-01 07:17:55 -05:00
|
|
|
context 'files with auxiliary viewers' do
|
|
|
|
describe '.gitlab-ci.yml' do
|
|
|
|
before do
|
|
|
|
project.add_maintainer(project.creator)
|
2017-04-13 13:11:52 -04:00
|
|
|
|
2022-02-01 07:17:55 -05:00
|
|
|
Files::CreateService.new(
|
|
|
|
project,
|
|
|
|
project.creator,
|
|
|
|
start_branch: 'master',
|
|
|
|
branch_name: 'master',
|
|
|
|
commit_message: "Add .gitlab-ci.yml",
|
|
|
|
file_path: '.gitlab-ci.yml',
|
|
|
|
file_content: File.read(Rails.root.join('spec/support/gitlab_stubs/gitlab_ci.yml'))
|
|
|
|
).execute
|
2017-05-02 18:45:50 -04:00
|
|
|
|
2022-02-01 07:17:55 -05:00
|
|
|
visit_blob('.gitlab-ci.yml')
|
|
|
|
end
|
2017-05-02 18:45:50 -04:00
|
|
|
|
2022-02-01 07:17:55 -05:00
|
|
|
it 'displays an auxiliary viewer' do
|
|
|
|
aggregate_failures do
|
|
|
|
# shows that configuration is valid
|
|
|
|
expect(page).to have_content('This GitLab CI configuration is valid.')
|
2017-05-02 18:45:50 -04:00
|
|
|
|
2022-02-01 07:17:55 -05:00
|
|
|
# shows a learn more link
|
|
|
|
expect(page).to have_link('Learn more')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2018-05-22 06:30:48 -04:00
|
|
|
|
2022-02-01 07:17:55 -05:00
|
|
|
describe '.gitlab/route-map.yml' do
|
|
|
|
before do
|
|
|
|
project.add_maintainer(project.creator)
|
2017-05-02 18:45:50 -04:00
|
|
|
|
2022-02-01 07:17:55 -05:00
|
|
|
Files::CreateService.new(
|
|
|
|
project,
|
|
|
|
project.creator,
|
|
|
|
start_branch: 'master',
|
|
|
|
branch_name: 'master',
|
|
|
|
commit_message: "Add .gitlab/route-map.yml",
|
|
|
|
file_path: '.gitlab/route-map.yml',
|
|
|
|
file_content: <<-MAP.strip_heredoc
|
|
|
|
# Team data
|
|
|
|
- source: 'data/team.yml'
|
|
|
|
public: 'team/'
|
|
|
|
MAP
|
|
|
|
).execute
|
2017-05-02 18:45:50 -04:00
|
|
|
|
2022-02-01 07:17:55 -05:00
|
|
|
visit_blob('.gitlab/route-map.yml')
|
|
|
|
end
|
2017-05-02 18:45:50 -04:00
|
|
|
|
2022-02-01 07:17:55 -05:00
|
|
|
it 'displays an auxiliary viewer' do
|
|
|
|
aggregate_failures do
|
|
|
|
# shows that map is valid
|
|
|
|
expect(page).to have_content('This Route Map is valid.')
|
2017-05-02 18:45:50 -04:00
|
|
|
|
2022-02-01 07:17:55 -05:00
|
|
|
# shows a learn more link
|
|
|
|
expect(page).to have_link('Learn more')
|
|
|
|
end
|
|
|
|
end
|
2017-05-02 18:45:50 -04:00
|
|
|
end
|
2017-05-08 19:50:23 -04:00
|
|
|
|
2022-02-01 07:17:55 -05:00
|
|
|
describe '.gitlab/dashboards/custom-dashboard.yml' do
|
|
|
|
before do
|
|
|
|
project.add_maintainer(project.creator)
|
|
|
|
|
|
|
|
Files::CreateService.new(
|
|
|
|
project,
|
|
|
|
project.creator,
|
|
|
|
start_branch: 'master',
|
|
|
|
branch_name: 'master',
|
|
|
|
commit_message: "Add .gitlab/dashboards/custom-dashboard.yml",
|
|
|
|
file_path: '.gitlab/dashboards/custom-dashboard.yml',
|
|
|
|
file_content: file_content
|
|
|
|
).execute
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'with metrics_dashboard_exhaustive_validations feature flag off' do
|
|
|
|
before do
|
|
|
|
stub_feature_flags(metrics_dashboard_exhaustive_validations: false)
|
|
|
|
visit_blob('.gitlab/dashboards/custom-dashboard.yml')
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'valid dashboard file' do
|
|
|
|
let(:file_content) { File.read(Rails.root.join('config/prometheus/common_metrics.yml')) }
|
|
|
|
|
|
|
|
it 'displays an auxiliary viewer' do
|
|
|
|
aggregate_failures do
|
|
|
|
# shows that dashboard yaml is valid
|
|
|
|
expect(page).to have_content('Metrics Dashboard YAML definition is valid.')
|
|
|
|
|
|
|
|
# shows a learn more link
|
|
|
|
expect(page).to have_link('Learn more')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'invalid dashboard file' do
|
|
|
|
let(:file_content) { "dashboard: 'invalid'" }
|
|
|
|
|
|
|
|
it 'displays an auxiliary viewer' do
|
|
|
|
aggregate_failures do
|
|
|
|
# shows that dashboard yaml is invalid
|
|
|
|
expect(page).to have_content('Metrics Dashboard YAML definition is invalid:')
|
|
|
|
expect(page).to have_content("panel_groups: should be an array of panel_groups objects")
|
|
|
|
|
|
|
|
# shows a learn more link
|
|
|
|
expect(page).to have_link('Learn more')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'with metrics_dashboard_exhaustive_validations feature flag on' do
|
|
|
|
before do
|
|
|
|
stub_feature_flags(metrics_dashboard_exhaustive_validations: true)
|
|
|
|
visit_blob('.gitlab/dashboards/custom-dashboard.yml')
|
|
|
|
end
|
2017-06-07 17:07:57 -04:00
|
|
|
|
2022-02-01 07:17:55 -05:00
|
|
|
context 'valid dashboard file' do
|
|
|
|
let(:file_content) { File.read(Rails.root.join('config/prometheus/common_metrics.yml')) }
|
2017-06-07 17:07:57 -04:00
|
|
|
|
2022-02-01 07:17:55 -05:00
|
|
|
it 'displays an auxiliary viewer' do
|
|
|
|
aggregate_failures do
|
|
|
|
# shows that dashboard yaml is valid
|
|
|
|
expect(page).to have_content('Metrics Dashboard YAML definition is valid.')
|
2017-06-07 17:07:57 -04:00
|
|
|
|
2022-02-01 07:17:55 -05:00
|
|
|
# shows a learn more link
|
|
|
|
expect(page).to have_link('Learn more')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2017-06-07 17:07:57 -04:00
|
|
|
|
2022-02-01 07:17:55 -05:00
|
|
|
context 'invalid dashboard file' do
|
|
|
|
let(:file_content) { "dashboard: 'invalid'" }
|
|
|
|
|
|
|
|
it 'displays an auxiliary viewer' do
|
|
|
|
aggregate_failures do
|
|
|
|
# shows that dashboard yaml is invalid
|
|
|
|
expect(page).to have_content('Metrics Dashboard YAML definition is invalid:')
|
|
|
|
expect(page).to have_content("root is missing required keys: panel_groups")
|
2017-06-07 17:07:57 -04:00
|
|
|
|
2022-02-01 07:17:55 -05:00
|
|
|
# shows a learn more link
|
|
|
|
expect(page).to have_link('Learn more')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2017-06-07 17:07:57 -04:00
|
|
|
end
|
|
|
|
|
2022-02-01 07:17:55 -05:00
|
|
|
context 'LICENSE' do
|
|
|
|
before do
|
|
|
|
visit_blob('LICENSE')
|
|
|
|
end
|
2017-05-08 19:50:23 -04:00
|
|
|
|
2022-02-01 07:17:55 -05:00
|
|
|
it 'displays an auxiliary viewer' do
|
|
|
|
aggregate_failures do
|
|
|
|
# shows license
|
|
|
|
expect(page).to have_content('This project is licensed under the MIT License.')
|
2017-05-08 19:50:23 -04:00
|
|
|
|
2022-02-01 07:17:55 -05:00
|
|
|
# shows a learn more link
|
|
|
|
expect(page).to have_link('Learn more', href: 'http://choosealicense.com/licenses/mit/')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context '*.gemspec' do
|
|
|
|
before do
|
|
|
|
project.add_maintainer(project.creator)
|
2017-05-08 19:50:23 -04:00
|
|
|
|
2022-02-01 07:17:55 -05:00
|
|
|
Files::CreateService.new(
|
|
|
|
project,
|
|
|
|
project.creator,
|
|
|
|
start_branch: 'master',
|
|
|
|
branch_name: 'master',
|
|
|
|
commit_message: "Add activerecord.gemspec",
|
|
|
|
file_path: 'activerecord.gemspec',
|
|
|
|
file_content: <<-SPEC.strip_heredoc
|
|
|
|
Gem::Specification.new do |s|
|
|
|
|
s.platform = Gem::Platform::RUBY
|
|
|
|
s.name = "activerecord"
|
|
|
|
end
|
|
|
|
SPEC
|
|
|
|
).execute
|
|
|
|
|
|
|
|
visit_blob('activerecord.gemspec')
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'displays an auxiliary viewer' do
|
|
|
|
aggregate_failures do
|
|
|
|
# shows names of dependency manager and package
|
|
|
|
expect(page).to have_content('This project manages its dependencies using RubyGems.')
|
|
|
|
|
|
|
|
# shows a learn more link
|
|
|
|
expect(page).to have_link('Learn more', href: 'https://rubygems.org/')
|
|
|
|
end
|
|
|
|
end
|
2021-07-23 02:08:47 -04:00
|
|
|
end
|
2017-05-08 19:50:23 -04:00
|
|
|
|
2022-02-01 07:17:55 -05:00
|
|
|
context 'CONTRIBUTING.md' do
|
|
|
|
before do
|
|
|
|
file_name = 'CONTRIBUTING.md'
|
2017-05-08 19:50:23 -04:00
|
|
|
|
2022-02-01 07:17:55 -05:00
|
|
|
create_file(file_name, '## Contribution guidelines')
|
|
|
|
visit_blob(file_name)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'displays an auxiliary viewer' do
|
|
|
|
aggregate_failures do
|
|
|
|
expect(page).to have_content("After you've reviewed these contribution guidelines, you'll be all set to contribute to this project.")
|
|
|
|
end
|
2021-07-23 02:08:47 -04:00
|
|
|
end
|
|
|
|
end
|
2017-05-08 19:50:23 -04:00
|
|
|
|
2022-02-01 07:17:55 -05:00
|
|
|
context 'CHANGELOG.md' do
|
|
|
|
before do
|
|
|
|
file_name = 'CHANGELOG.md'
|
2021-07-23 02:08:47 -04:00
|
|
|
|
2022-02-01 07:17:55 -05:00
|
|
|
create_file(file_name, '## Changelog for v1.0.0')
|
|
|
|
visit_blob(file_name)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'displays an auxiliary viewer' do
|
|
|
|
aggregate_failures do
|
|
|
|
expect(page).to have_content("To find the state of this project's repository at the time of any of these versions, check out the tags.")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'Cargo.toml' do
|
|
|
|
before do
|
|
|
|
file_name = 'Cargo.toml'
|
|
|
|
|
|
|
|
create_file(file_name, '
|
|
|
|
[package]
|
|
|
|
name = "hello_world" # the name of the package
|
|
|
|
version = "0.1.0" # the current version, obeying semver
|
|
|
|
authors = ["Alice <a@example.com>", "Bob <b@example.com>"]
|
|
|
|
')
|
|
|
|
visit_blob(file_name)
|
|
|
|
end
|
2017-05-08 19:50:23 -04:00
|
|
|
|
2022-02-01 07:17:55 -05:00
|
|
|
it 'displays an auxiliary viewer' do
|
|
|
|
aggregate_failures do
|
|
|
|
expect(page).to have_content("This project manages its dependencies using Cargo.")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'Cartfile' do
|
|
|
|
before do
|
|
|
|
file_name = 'Cartfile'
|
|
|
|
|
|
|
|
create_file(file_name, '
|
|
|
|
gitlab "Alamofire/Alamofire" == 4.9.0
|
|
|
|
gitlab "Alamofire/AlamofireImage" ~> 3.4
|
|
|
|
')
|
|
|
|
visit_blob(file_name)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'displays an auxiliary viewer' do
|
|
|
|
aggregate_failures do
|
|
|
|
expect(page).to have_content("This project manages its dependencies using Carthage.")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'composer.json' do
|
|
|
|
before do
|
|
|
|
file_name = 'composer.json'
|
|
|
|
|
|
|
|
create_file(file_name, '
|
|
|
|
{
|
|
|
|
"license": "MIT"
|
|
|
|
}
|
|
|
|
')
|
|
|
|
visit_blob(file_name)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'displays an auxiliary viewer' do
|
|
|
|
aggregate_failures do
|
|
|
|
expect(page).to have_content("This project manages its dependencies using Composer.")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'Gemfile' do
|
|
|
|
before do
|
|
|
|
file_name = 'Gemfile'
|
|
|
|
|
|
|
|
create_file(file_name, '
|
|
|
|
source "https://rubygems.org"
|
|
|
|
|
|
|
|
# Gems here
|
|
|
|
')
|
|
|
|
visit_blob(file_name)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'displays an auxiliary viewer' do
|
|
|
|
aggregate_failures do
|
|
|
|
expect(page).to have_content("This project manages its dependencies using Bundler.")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'Godeps.json' do
|
|
|
|
before do
|
|
|
|
file_name = 'Godeps.json'
|
|
|
|
|
|
|
|
create_file(file_name, '
|
|
|
|
{
|
|
|
|
"GoVersion": "go1.6"
|
|
|
|
}
|
|
|
|
')
|
|
|
|
visit_blob(file_name)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'displays an auxiliary viewer' do
|
|
|
|
aggregate_failures do
|
|
|
|
expect(page).to have_content("This project manages its dependencies using godep.")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'go.mod' do
|
|
|
|
before do
|
|
|
|
file_name = 'go.mod'
|
|
|
|
|
|
|
|
create_file(file_name, '
|
|
|
|
module example.com/mymodule
|
|
|
|
|
|
|
|
go 1.14
|
|
|
|
')
|
|
|
|
visit_blob(file_name)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'displays an auxiliary viewer' do
|
|
|
|
aggregate_failures do
|
|
|
|
expect(page).to have_content("This project manages its dependencies using Go Modules.")
|
|
|
|
end
|
|
|
|
end
|
2017-05-08 19:50:23 -04:00
|
|
|
end
|
|
|
|
|
2022-02-01 07:17:55 -05:00
|
|
|
context 'package.json' do
|
|
|
|
before do
|
|
|
|
file_name = 'package.json'
|
2020-06-03 05:08:47 -04:00
|
|
|
|
2022-02-01 07:17:55 -05:00
|
|
|
create_file(file_name, '
|
|
|
|
{
|
|
|
|
"name": "my-awesome-package",
|
|
|
|
"version": "1.0.0"
|
|
|
|
}
|
|
|
|
')
|
|
|
|
visit_blob(file_name)
|
2021-07-23 02:08:47 -04:00
|
|
|
end
|
|
|
|
|
2022-02-01 07:17:55 -05:00
|
|
|
it 'displays an auxiliary viewer' do
|
|
|
|
aggregate_failures do
|
|
|
|
expect(page).to have_content("This project manages its dependencies using npm.")
|
|
|
|
end
|
|
|
|
end
|
2020-08-27 11:10:21 -04:00
|
|
|
end
|
2020-06-03 05:08:47 -04:00
|
|
|
|
2022-02-01 07:17:55 -05:00
|
|
|
context 'podfile' do
|
2021-07-23 02:08:47 -04:00
|
|
|
before do
|
2022-02-01 07:17:55 -05:00
|
|
|
file_name = 'podfile'
|
2020-08-27 11:10:21 -04:00
|
|
|
|
2022-02-01 07:17:55 -05:00
|
|
|
create_file(file_name, 'platform :ios, "8.0"')
|
|
|
|
visit_blob(file_name)
|
|
|
|
end
|
2021-07-23 02:08:47 -04:00
|
|
|
|
2022-02-01 07:17:55 -05:00
|
|
|
it 'displays an auxiliary viewer' do
|
|
|
|
aggregate_failures do
|
|
|
|
expect(page).to have_content("This project manages its dependencies using CocoaPods.")
|
2020-08-27 11:10:21 -04:00
|
|
|
end
|
|
|
|
end
|
2022-02-01 07:17:55 -05:00
|
|
|
end
|
2020-08-27 11:10:21 -04:00
|
|
|
|
2022-02-01 07:17:55 -05:00
|
|
|
context 'test.podspec' do
|
|
|
|
before do
|
|
|
|
file_name = 'test.podspec'
|
2020-06-03 05:08:47 -04:00
|
|
|
|
2022-02-01 07:17:55 -05:00
|
|
|
create_file(file_name, '
|
|
|
|
Pod::Spec.new do |s|
|
|
|
|
s.name = "TensorFlowLiteC"
|
|
|
|
')
|
|
|
|
visit_blob(file_name)
|
|
|
|
end
|
2020-08-27 11:10:21 -04:00
|
|
|
|
2022-02-01 07:17:55 -05:00
|
|
|
it 'displays an auxiliary viewer' do
|
|
|
|
aggregate_failures do
|
|
|
|
expect(page).to have_content("This project manages its dependencies using CocoaPods.")
|
2020-08-27 11:10:21 -04:00
|
|
|
end
|
2020-06-03 05:08:47 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2022-02-01 07:17:55 -05:00
|
|
|
context 'JSON.podspec.json' do
|
2021-07-23 02:08:47 -04:00
|
|
|
before do
|
2022-02-01 07:17:55 -05:00
|
|
|
file_name = 'JSON.podspec.json'
|
2020-06-03 05:08:47 -04:00
|
|
|
|
2022-02-01 07:17:55 -05:00
|
|
|
create_file(file_name, '
|
|
|
|
{
|
|
|
|
"name": "JSON"
|
|
|
|
}
|
|
|
|
')
|
|
|
|
visit_blob(file_name)
|
|
|
|
end
|
2020-08-27 11:10:21 -04:00
|
|
|
|
2022-02-01 07:17:55 -05:00
|
|
|
it 'displays an auxiliary viewer' do
|
|
|
|
aggregate_failures do
|
|
|
|
expect(page).to have_content("This project manages its dependencies using CocoaPods.")
|
2020-08-27 11:10:21 -04:00
|
|
|
end
|
|
|
|
end
|
2022-02-01 07:17:55 -05:00
|
|
|
end
|
2020-08-27 11:10:21 -04:00
|
|
|
|
2022-02-01 07:17:55 -05:00
|
|
|
context 'requirements.txt' do
|
|
|
|
before do
|
|
|
|
file_name = 'requirements.txt'
|
2020-08-27 11:10:21 -04:00
|
|
|
|
2022-02-01 07:17:55 -05:00
|
|
|
create_file(file_name, 'Project requirements')
|
|
|
|
visit_blob(file_name)
|
|
|
|
end
|
2020-08-27 11:10:21 -04:00
|
|
|
|
2022-02-01 07:17:55 -05:00
|
|
|
it 'displays an auxiliary viewer' do
|
|
|
|
aggregate_failures do
|
|
|
|
expect(page).to have_content("This project manages its dependencies using pip.")
|
2020-08-27 11:10:21 -04:00
|
|
|
end
|
2020-06-03 05:08:47 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2022-02-01 07:17:55 -05:00
|
|
|
context 'yarn.lock' do
|
|
|
|
before do
|
|
|
|
file_name = 'yarn.lock'
|
2017-05-08 19:50:23 -04:00
|
|
|
|
2022-02-01 07:17:55 -05:00
|
|
|
create_file(file_name, '
|
|
|
|
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
|
|
|
|
# yarn lockfile v1
|
|
|
|
')
|
|
|
|
visit_blob(file_name)
|
|
|
|
end
|
2017-05-08 19:50:23 -04:00
|
|
|
|
2022-02-01 07:17:55 -05:00
|
|
|
it 'displays an auxiliary viewer' do
|
|
|
|
aggregate_failures do
|
|
|
|
expect(page).to have_content("This project manages its dependencies using Yarn.")
|
|
|
|
end
|
2021-07-23 02:08:47 -04:00
|
|
|
end
|
2017-05-17 12:27:30 -04:00
|
|
|
end
|
2022-03-31 17:08:16 -04:00
|
|
|
|
|
|
|
context 'openapi.yml' do
|
|
|
|
before do
|
|
|
|
file_name = 'openapi.yml'
|
|
|
|
|
|
|
|
create_file(file_name, '
|
|
|
|
swagger: \'2.0\'
|
|
|
|
info:
|
|
|
|
title: Classic API Resource Documentation
|
|
|
|
description: |
|
|
|
|
<div class="foo-bar" style="background-color: red;" data-foo-bar="baz">
|
|
|
|
<h1>Swagger API documentation</h1>
|
|
|
|
</div>
|
|
|
|
version: production
|
|
|
|
basePath: /JSSResource/
|
|
|
|
produces:
|
|
|
|
- application/xml
|
|
|
|
- application/json
|
|
|
|
consumes:
|
|
|
|
- application/xml
|
|
|
|
- application/json
|
|
|
|
security:
|
|
|
|
- basicAuth: []
|
|
|
|
paths:
|
|
|
|
/accounts:
|
|
|
|
get:
|
|
|
|
responses:
|
|
|
|
\'200\':
|
|
|
|
description: No response was specified
|
|
|
|
tags:
|
|
|
|
- accounts
|
|
|
|
operationId: findAccounts
|
|
|
|
summary: Finds all accounts
|
|
|
|
')
|
|
|
|
visit_blob(file_name, useUnsafeMarkdown: '1')
|
|
|
|
click_button('Display rendered file')
|
|
|
|
|
|
|
|
wait_for_requests
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'removes `style`, `class`, and `data-*`` attributes from HTML' do
|
|
|
|
expect(page).to have_css('h1', text: 'Swagger API documentation')
|
|
|
|
expect(page).not_to have_css('.foo-bar')
|
|
|
|
expect(page).not_to have_css('[style="background-color: red;"]')
|
|
|
|
expect(page).not_to have_css('[data-foo-bar="baz"]')
|
|
|
|
end
|
|
|
|
end
|
2017-05-17 12:27:30 -04:00
|
|
|
end
|
|
|
|
|
2022-02-01 07:17:55 -05:00
|
|
|
context 'realtime pipelines' do
|
2021-07-23 02:08:47 -04:00
|
|
|
before do
|
|
|
|
Files::CreateService.new(
|
|
|
|
project,
|
|
|
|
project.creator,
|
2022-02-01 07:17:55 -05:00
|
|
|
start_branch: 'feature',
|
|
|
|
branch_name: 'feature',
|
|
|
|
commit_message: "Add ruby file",
|
|
|
|
file_path: 'files/ruby/test.rb',
|
|
|
|
file_content: "# Awesome content"
|
2021-07-23 02:08:47 -04:00
|
|
|
).execute
|
2017-05-17 12:27:30 -04:00
|
|
|
|
2022-02-01 07:17:55 -05:00
|
|
|
create(:ci_pipeline, status: 'running', project: project, ref: 'feature', sha: project.commit('feature').sha)
|
|
|
|
visit_blob('files/ruby/test.rb', ref: 'feature')
|
2021-07-23 02:08:47 -04:00
|
|
|
end
|
2017-05-17 12:27:30 -04:00
|
|
|
|
2022-02-01 07:17:55 -05:00
|
|
|
it 'shows the realtime pipeline status' do
|
|
|
|
page.within('.commit-actions') do
|
|
|
|
expect(page).to have_css('.ci-status-icon')
|
|
|
|
expect(page).to have_css('.ci-status-icon-running')
|
|
|
|
expect(page).to have_css('.js-ci-status-icon-running')
|
2021-07-23 02:08:47 -04:00
|
|
|
end
|
2017-05-08 19:50:23 -04:00
|
|
|
end
|
|
|
|
end
|
2021-07-26 02:10:00 -04:00
|
|
|
|
2022-02-01 07:17:55 -05:00
|
|
|
context 'for subgroups' do
|
|
|
|
let(:group) { create(:group) }
|
|
|
|
let(:subgroup) { create(:group, parent: group) }
|
|
|
|
let(:project) { create(:project, :public, :repository, group: subgroup) }
|
2021-07-26 02:10:00 -04:00
|
|
|
|
2022-02-01 07:17:55 -05:00
|
|
|
it 'renders tree table without errors' do
|
|
|
|
visit_blob('README.md')
|
2021-07-26 02:10:00 -04:00
|
|
|
|
2022-02-01 07:17:55 -05:00
|
|
|
expect(page).to have_selector('.file-content')
|
2022-02-10 07:18:48 -05:00
|
|
|
expect(page).not_to have_selector('[data-testid="alert-danger"]')
|
2021-07-26 02:10:00 -04:00
|
|
|
end
|
|
|
|
|
2022-02-01 07:17:55 -05:00
|
|
|
it 'displays a GPG badge' do
|
|
|
|
visit_blob('CONTRIBUTING.md', ref: '33f3729a45c02fc67d00adb1b8bca394b0e761d9')
|
2021-07-26 02:10:00 -04:00
|
|
|
|
2022-02-01 07:17:55 -05:00
|
|
|
expect(page).not_to have_selector '.gpg-status-box.js-loading-gpg-badge'
|
|
|
|
expect(page).to have_selector '.gpg-status-box.invalid'
|
2021-07-26 02:10:00 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2022-02-01 07:17:55 -05:00
|
|
|
context 'on signed merge commit' do
|
|
|
|
it 'displays a GPG badge' do
|
|
|
|
visit_blob('conflicting-file.md', ref: '6101e87e575de14b38b4e1ce180519a813671e10')
|
2021-07-26 02:10:00 -04:00
|
|
|
|
2022-02-01 07:17:55 -05:00
|
|
|
expect(page).not_to have_selector '.gpg-status-box.js-loading-gpg-badge'
|
|
|
|
expect(page).to have_selector '.gpg-status-box.invalid'
|
2021-07-26 02:10:00 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2022-02-01 07:17:55 -05:00
|
|
|
context 'when static objects external storage is enabled' do
|
2021-07-26 02:10:00 -04:00
|
|
|
before do
|
2022-02-01 07:17:55 -05:00
|
|
|
stub_application_setting(static_objects_external_storage_url: 'https://cdn.gitlab.com')
|
2021-07-26 02:10:00 -04:00
|
|
|
end
|
|
|
|
|
2022-03-07 13:19:30 -05:00
|
|
|
context 'private project' do
|
|
|
|
let_it_be(:project) { create(:project, :repository, :private) }
|
|
|
|
let_it_be(:user) { create(:user, static_object_token: 'ABCD1234') }
|
|
|
|
|
|
|
|
before do
|
|
|
|
project.add_developer(user)
|
|
|
|
|
|
|
|
sign_in(user)
|
|
|
|
visit_blob('README.md')
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows open raw and download buttons with external storage URL prepended and user token appended to their href' do
|
|
|
|
path = project_raw_path(project, 'master/README.md')
|
|
|
|
raw_uri = "https://cdn.gitlab.com#{path}?token=#{user.static_object_token}"
|
|
|
|
download_uri = "https://cdn.gitlab.com#{path}?token=#{user.static_object_token}&inline=false"
|
|
|
|
|
|
|
|
aggregate_failures do
|
|
|
|
expect(page).to have_link 'Open raw', href: raw_uri
|
|
|
|
expect(page).to have_link 'Download', href: download_uri
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2022-02-01 07:17:55 -05:00
|
|
|
context 'public project' do
|
|
|
|
before do
|
|
|
|
visit_blob('README.md')
|
2021-07-26 02:10:00 -04:00
|
|
|
end
|
|
|
|
|
2022-02-01 07:17:55 -05:00
|
|
|
it 'shows open raw and download buttons with external storage URL prepended to their href' do
|
|
|
|
path = project_raw_path(project, 'master/README.md')
|
|
|
|
raw_uri = "https://cdn.gitlab.com#{path}"
|
|
|
|
download_uri = "https://cdn.gitlab.com#{path}?inline=false"
|
2021-07-26 02:10:00 -04:00
|
|
|
|
2022-02-01 07:17:55 -05:00
|
|
|
aggregate_failures do
|
|
|
|
expect(page).to have_link 'Open raw', href: raw_uri
|
|
|
|
expect(page).to have_link 'Download', href: download_uri
|
|
|
|
end
|
2021-07-26 02:10:00 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2022-02-01 07:17:55 -05:00
|
|
|
end
|
2021-07-26 02:10:00 -04:00
|
|
|
|
2022-02-01 07:17:55 -05:00
|
|
|
context 'with refactor_blob_viewer feature flag disabled' do
|
|
|
|
before do
|
|
|
|
stub_feature_flags(refactor_blob_viewer: false)
|
|
|
|
end
|
2021-07-26 02:10:00 -04:00
|
|
|
|
2022-02-01 07:17:55 -05:00
|
|
|
context 'binary file that appears to be text in the first 1024 bytes' do
|
|
|
|
# We need to unsre that this test runs with the refactor_blob_viewer feature flag enabled
|
|
|
|
# This will be addressed in https://gitlab.com/gitlab-org/gitlab/-/issues/351559
|
2021-07-26 02:10:00 -04:00
|
|
|
|
2022-02-01 07:17:55 -05:00
|
|
|
before do
|
|
|
|
visit_blob('encoding/binary-1.bin', ref: 'binary-encoding')
|
2021-07-26 02:10:00 -04:00
|
|
|
end
|
2022-02-01 07:17:55 -05:00
|
|
|
it 'displays the blob' do
|
2021-07-26 02:10:00 -04:00
|
|
|
aggregate_failures do
|
2022-02-01 07:17:55 -05:00
|
|
|
# shows a download link
|
|
|
|
expect(page).to have_link('Download (23.8 KB)')
|
|
|
|
# does not show a viewer switcher
|
|
|
|
expect(page).not_to have_selector('.js-blob-viewer-switcher')
|
|
|
|
# The specs below verify an arguably incorrect result, but since we only
|
|
|
|
# learn that the file is not actually text once the text viewer content
|
|
|
|
# is loaded asynchronously, there is no straightforward way to get these
|
|
|
|
# synchronously loaded elements to display correctly.
|
|
|
|
#
|
|
|
|
# Clicking the copy button will result in nothing being copied.
|
|
|
|
# Clicking the raw button will result in the binary file being downloaded,
|
|
|
|
# as expected.
|
|
|
|
# shows an enabled copy button, incorrectly
|
|
|
|
expect(page).to have_selector('.js-copy-blob-source-btn:not(.disabled)')
|
|
|
|
# shows a raw button, incorrectly
|
|
|
|
expect(page).to have_link('Open raw')
|
2021-07-26 02:10:00 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2017-05-08 19:50:23 -04:00
|
|
|
end
|
2017-04-06 12:36:38 -04:00
|
|
|
end
|