Commit 4d7fbe95 authored by mfluharty's avatar mfluharty

Add specs to check codequality report links

parent b2213d1a
......@@ -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_namespace_project_pipeline_path(project.namespace, 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