Commit 3b3af0d8 authored by Kushal Pandya's avatar Kushal Pandya

Merge branch '210351-full-code-quality-report-file-links-404' into 'master'

Fix 404s when clicking links in full code quality report

Closes #210351

See merge request gitlab-org/gitlab!27138
parents 0d1bae05 00b45ab1
......@@ -30,4 +30,4 @@
- if codequality_report_download_path
#js-tab-codequality.tab-pane
#js-pipeline-codequality-report{ data: { codequality_report_download_path: codequality_report_download_path,
blob_path: project_blob_path(project, pipeline.ref) } }
blob_path: project_blob_path(project, pipeline.commit) } }
......@@ -14,5 +14,5 @@
- if pipeline.downloadable_path_for_report_type(:codequality)
%li.js-codequality-tab-link
= link_to codequality_report_namespace_project_pipeline_path(project.namespace, project, pipeline), data: { target: '#js-tab-codequality', action: 'codequality_report', toggle: 'tab'}, class: 'codequality-tab' do
= link_to codequality_report_project_pipeline_path(project, pipeline), data: { target: '#js-tab-codequality', action: 'codequality_report', toggle: 'tab'}, class: 'codequality-tab' do
= _('Code Quality')
---
title: Fix 404s when clicking links in full code quality report
merge_request: 27138
author:
type: fixed
......@@ -165,6 +165,67 @@ describe 'Pipeline', :js do
end
end
describe 'GET /:project/pipelines/:id/codequality_report' do
shared_examples_for 'full codequality report' do
context 'with no code quality artifact' do
before do
create(:ee_ci_build, pipeline: pipeline)
visit project_pipeline_path(project, pipeline)
end
it 'does not show code quality tab' do
expect(page).not_to have_content('Code Quality')
expect(page).not_to have_css('#js-tab-codequality')
end
end
context 'with code quality artifact' do
before do
create(:ee_ci_build, :codequality, pipeline: pipeline)
visit codequality_report_project_pipeline_path(project, pipeline)
end
it 'shows code quality tab pane as active' do
expect(page).to have_content('Code Quality')
expect(page).to have_css('#js-tab-codequality')
end
it 'shows code quality report section' do
expect(page).to have_content('Loading codeclimate report')
end
it 'shows code quality issue with link to file' do
wait_for_requests
expect(page).to have_content('Function `simulateEvent` has 28 lines of code (exceeds 25 allowed). Consider refactoring.')
expect(find_link('app/assets/javascripts/test_utils/simulate_drag.js:1')[:href]).to end_with(project_blob_path(project, File.join(pipeline.commit.id, 'app/assets/javascripts/test_utils/simulate_drag.js')) + '#L1')
end
end
end
context 'for a branch pipeline' do
let(:pipeline) { create(:ci_pipeline, project: project, ref: 'master', sha: project.commit.id) }
it_behaves_like 'full codequality report'
end
context 'for a merge request pipeline' do
let(:merge_request) do
create(:merge_request,
:with_merge_request_pipeline,
source_project: project,
target_project: project,
merge_sha: project.commit.id)
end
let(:pipeline) do
merge_request.all_pipelines.last
end
it_behaves_like 'full codequality report'
end
end
private
def create_link(source_pipeline, pipeline)
......
......@@ -71,6 +71,15 @@ describe('Codequality report app', () => {
expect(findStatus().text()).toBe(`Found ${expectedIssueTotal} code quality issues`);
expect(wrapper.findAll('.report-block-list-issue').length).toBe(expectedIssueTotal);
});
it('renders a link to the line where the issue was found', () => {
const issueLink = wrapper.find('.report-block-list-issue a');
expect(issueLink.text()).toBe('ee/spec/features/admin/geo/admin_geo_projects_spec.rb:152');
expect(issueLink.attributes('href')).toBe(
'/root/test-codequality/blob/feature-branch/ee/spec/features/admin/geo/admin_geo_projects_spec.rb#L152',
);
});
});
describe('when there are no codequality issues', () => {
......
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