Commit da662ce0 authored by Ezekiel Kigbo's avatar Ezekiel Kigbo

Merge branch '334789-fix-aux-viewers' into 'master'

Blob refactor: Fix the Auxiliary viewers

See merge request gitlab-org/gitlab!66529
parents 64a920f2 b3d15ebd
...@@ -2,7 +2,7 @@ import Vue from 'vue'; ...@@ -2,7 +2,7 @@ import Vue from 'vue';
import VueApollo from 'vue-apollo'; import VueApollo from 'vue-apollo';
import TableOfContents from '~/blob/components/table_contents.vue'; import TableOfContents from '~/blob/components/table_contents.vue';
import PipelineTourSuccessModal from '~/blob/pipeline_tour_success_modal.vue'; import PipelineTourSuccessModal from '~/blob/pipeline_tour_success_modal.vue';
import { BlobViewer } from '~/blob/viewer/index'; import { BlobViewer, initAuxiliaryViewer } from '~/blob/viewer/index';
import GpgBadges from '~/gpg_badges'; import GpgBadges from '~/gpg_badges';
import createDefaultClient from '~/lib/graphql'; import createDefaultClient from '~/lib/graphql';
import initBlob from '~/pages/projects/init_blob'; import initBlob from '~/pages/projects/init_blob';
...@@ -39,6 +39,8 @@ if (viewBlobEl) { ...@@ -39,6 +39,8 @@ if (viewBlobEl) {
}); });
}, },
}); });
initAuxiliaryViewer();
} else { } else {
new BlobViewer(); // eslint-disable-line no-new new BlobViewer(); // eslint-disable-line no-new
initBlob(); initBlob();
......
...@@ -584,199 +584,205 @@ RSpec.describe 'File blob', :js do ...@@ -584,199 +584,205 @@ RSpec.describe 'File blob', :js do
end end
end end
describe '.gitlab-ci.yml' do context 'files with auxiliary viewers' do
before do before do
project.add_maintainer(project.creator) stub_feature_flags(refactor_blob_viewer: true)
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
visit_blob('.gitlab-ci.yml')
end end
it 'displays an auxiliary viewer' do describe '.gitlab-ci.yml' do
aggregate_failures do before do
# shows that configuration is valid project.add_maintainer(project.creator)
expect(page).to have_content('This GitLab CI configuration is valid.')
# shows a learn more link Files::CreateService.new(
expect(page).to have_link('Learn more') project,
end project.creator,
end start_branch: 'master',
end 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
describe '.gitlab/route-map.yml' do visit_blob('.gitlab-ci.yml')
before do end
project.add_maintainer(project.creator)
Files::CreateService.new( it 'displays an auxiliary viewer' do
project, aggregate_failures do
project.creator, # shows that configuration is valid
start_branch: 'master', expect(page).to have_content('This GitLab CI configuration is valid.')
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
visit_blob('.gitlab/route-map.yml') # shows a learn more link
expect(page).to have_link('Learn more')
end
end
end end
it 'displays an auxiliary viewer' do describe '.gitlab/route-map.yml' do
aggregate_failures do before do
# shows that map is valid project.add_maintainer(project.creator)
expect(page).to have_content('This Route Map is valid.')
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
# shows a learn more link visit_blob('.gitlab/route-map.yml')
expect(page).to have_link('Learn more')
end end
end
end
describe '.gitlab/dashboards/custom-dashboard.yml' do it 'displays an auxiliary viewer' do
before do aggregate_failures do
project.add_maintainer(project.creator) # shows that map is valid
expect(page).to have_content('This Route Map is valid.')
Files::CreateService.new( # shows a learn more link
project, expect(page).to have_link('Learn more')
project.creator, end
start_branch: 'master', end
branch_name: 'master',
commit_message: "Add .gitlab/dashboards/custom-dashboard.yml",
file_path: '.gitlab/dashboards/custom-dashboard.yml',
file_content: file_content
).execute
end end
context 'with metrics_dashboard_exhaustive_validations feature flag off' do describe '.gitlab/dashboards/custom-dashboard.yml' do
before do before do
stub_feature_flags(metrics_dashboard_exhaustive_validations: false) project.add_maintainer(project.creator)
visit_blob('.gitlab/dashboards/custom-dashboard.yml')
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 end
context 'valid dashboard file' do context 'with metrics_dashboard_exhaustive_validations feature flag off' do
let(:file_content) { File.read(Rails.root.join('config/prometheus/common_metrics.yml')) } before do
stub_feature_flags(metrics_dashboard_exhaustive_validations: false)
visit_blob('.gitlab/dashboards/custom-dashboard.yml')
end
it 'displays an auxiliary viewer' do context 'valid dashboard file' do
aggregate_failures do let(:file_content) { File.read(Rails.root.join('config/prometheus/common_metrics.yml')) }
# shows that dashboard yaml is valid
expect(page).to have_content('Metrics Dashboard YAML definition is valid.')
# shows a learn more link it 'displays an auxiliary viewer' do
expect(page).to have_link('Learn more') 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
end end
end
context 'invalid dashboard file' do context 'invalid dashboard file' do
let(:file_content) { "dashboard: 'invalid'" } let(:file_content) { "dashboard: 'invalid'" }
it 'displays an auxiliary viewer' do it 'displays an auxiliary viewer' do
aggregate_failures do aggregate_failures do
# shows that dashboard yaml is invalid # shows that dashboard yaml is invalid
expect(page).to have_content('Metrics Dashboard YAML definition 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") expect(page).to have_content("panel_groups: should be an array of panel_groups objects")
# shows a learn more link # shows a learn more link
expect(page).to have_link('Learn more') expect(page).to have_link('Learn more')
end
end end
end end
end end
end
context 'with metrics_dashboard_exhaustive_validations feature flag on' do context 'with metrics_dashboard_exhaustive_validations feature flag on' do
before do before do
stub_feature_flags(metrics_dashboard_exhaustive_validations: true) stub_feature_flags(metrics_dashboard_exhaustive_validations: true)
visit_blob('.gitlab/dashboards/custom-dashboard.yml') visit_blob('.gitlab/dashboards/custom-dashboard.yml')
end end
context 'valid dashboard file' do context 'valid dashboard file' do
let(:file_content) { File.read(Rails.root.join('config/prometheus/common_metrics.yml')) } let(:file_content) { File.read(Rails.root.join('config/prometheus/common_metrics.yml')) }
it 'displays an auxiliary viewer' do it 'displays an auxiliary viewer' do
aggregate_failures do aggregate_failures do
# shows that dashboard yaml is valid # shows that dashboard yaml is valid
expect(page).to have_content('Metrics Dashboard YAML definition is valid.') expect(page).to have_content('Metrics Dashboard YAML definition is valid.')
# shows a learn more link # shows a learn more link
expect(page).to have_link('Learn more') expect(page).to have_link('Learn more')
end
end end
end end
end
context 'invalid dashboard file' do context 'invalid dashboard file' do
let(:file_content) { "dashboard: 'invalid'" } let(:file_content) { "dashboard: 'invalid'" }
it 'displays an auxiliary viewer' do it 'displays an auxiliary viewer' do
aggregate_failures do aggregate_failures do
# shows that dashboard yaml is invalid # shows that dashboard yaml is invalid
expect(page).to have_content('Metrics Dashboard YAML definition 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") expect(page).to have_content("root is missing required keys: panel_groups")
# shows a learn more link # shows a learn more link
expect(page).to have_link('Learn more') expect(page).to have_link('Learn more')
end
end end
end end
end end
end end
end
context 'LICENSE' do context 'LICENSE' do
before do before do
visit_blob('LICENSE') visit_blob('LICENSE')
end end
it 'displays an auxiliary viewer' do it 'displays an auxiliary viewer' do
aggregate_failures do aggregate_failures do
# shows license # shows license
expect(page).to have_content('This project is licensed under the MIT License.') expect(page).to have_content('This project is licensed under the MIT License.')
# shows a learn more link # shows a learn more link
expect(page).to have_link('Learn more', href: 'http://choosealicense.com/licenses/mit/') expect(page).to have_link('Learn more', href: 'http://choosealicense.com/licenses/mit/')
end
end end
end end
end
context '*.gemspec' do context '*.gemspec' do
before do before do
project.add_maintainer(project.creator) project.add_maintainer(project.creator)
Files::CreateService.new( Files::CreateService.new(
project, project,
project.creator, project.creator,
start_branch: 'master', start_branch: 'master',
branch_name: 'master', branch_name: 'master',
commit_message: "Add activerecord.gemspec", commit_message: "Add activerecord.gemspec",
file_path: 'activerecord.gemspec', file_path: 'activerecord.gemspec',
file_content: <<-SPEC.strip_heredoc file_content: <<-SPEC.strip_heredoc
Gem::Specification.new do |s| Gem::Specification.new do |s|
s.platform = Gem::Platform::RUBY s.platform = Gem::Platform::RUBY
s.name = "activerecord" s.name = "activerecord"
end end
SPEC SPEC
).execute ).execute
visit_blob('activerecord.gemspec') visit_blob('activerecord.gemspec')
end end
it 'displays an auxiliary viewer' do it 'displays an auxiliary viewer' do
aggregate_failures do aggregate_failures do
# shows names of dependency manager and package # shows names of dependency manager and package
expect(page).to have_content('This project manages its dependencies using RubyGems.') expect(page).to have_content('This project manages its dependencies using RubyGems.')
# shows a learn more link # shows a learn more link
expect(page).to have_link('Learn more', href: 'https://rubygems.org/') expect(page).to have_link('Learn more', href: 'https://rubygems.org/')
end
end end
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment