Commit 4039b06e authored by Scott Hampton's avatar Scott Hampton Committed by Mayra Cabrera

Expose a11y report path

The frontend needs the API endpoint
to get the report path. This exposes that
endpoint.
parent f55a8be3
......@@ -37,23 +37,12 @@ export const summaryStatus = state => {
export const shouldRenderIssuesList = state =>
Object.values(state.report).some(x => Array.isArray(x) && x.length > 0);
export const unresolvedIssues = state => [
...state.report.existing_errors,
...state.report.existing_warnings,
...state.report.existing_notes,
];
export const resolvedIssues = state => [
...state.report.resolved_errors,
...state.report.resolved_warnings,
...state.report.resolved_notes,
];
export const newIssues = state => [
...state.report.new_errors,
...state.report.new_warnings,
...state.report.new_notes,
];
// We could just map state, but we're going to iterate in the future
// to add notes and warnings to these issue lists, so I'm going to
// keep these as getters
export const unresolvedIssues = state => state.report.existing_errors;
export const resolvedIssues = state => state.report.resolved_errors;
export const newIssues = state => state.report.new_errors;
// prevent babel-plugin-rewire from generating an invalid default during karma tests
export default () => {};
......@@ -40,7 +40,6 @@ import TerraformPlan from './components/mr_widget_terraform_plan.vue';
import GroupedTestReportsApp from '../reports/components/grouped_test_reports_app.vue';
import { setFaviconOverlay } from '../lib/utils/common_utils';
import GroupedAccessibilityReportsApp from '../reports/accessibility_report/grouped_accessibility_reports_app.vue';
import glFeatureFlagsMixin from '~/vue_shared/mixins/gl_feature_flags_mixin';
export default {
el: '#js-vue-mr-widget',
......@@ -80,7 +79,6 @@ export default {
TerraformPlan,
GroupedAccessibilityReportsApp,
},
mixins: [glFeatureFlagsMixin()],
props: {
mrData: {
type: Object,
......@@ -146,7 +144,7 @@ export default {
});
},
shouldShowAccessibilityReport() {
return this.mr.accessibilityReportPath && this.glFeatures.accessibilityMergeRequestWidget;
return this.mr.accessibilityReportPath;
},
},
watch: {
......
......@@ -32,7 +32,6 @@ class Projects::MergeRequestsController < Projects::MergeRequests::ApplicationCo
push_frontend_feature_flag(:code_navigation, @project)
push_frontend_feature_flag(:widget_visibility_polling, @project, default_enabled: true)
push_frontend_feature_flag(:merge_ref_head_comments, @project)
push_frontend_feature_flag(:accessibility_merge_request_widget, @project)
push_frontend_feature_flag(:mr_commit_neighbor_nav, @project, default_enabled: true)
end
......
......@@ -71,6 +71,12 @@ class MergeRequestPollWidgetEntity < Grape::Entity
end
end
expose :accessibility_report_path do |merge_request|
if merge_request.has_accessibility_reports?
accessibility_reports_project_merge_request_path(merge_request.project, merge_request, format: :json)
end
end
expose :terraform_reports_path do |merge_request|
if merge_request.has_terraform_reports?
terraform_reports_project_merge_request_path(merge_request.project, merge_request, format: :json)
......
......@@ -115,39 +115,33 @@ describe('Accessibility reports store getters', () => {
});
describe('unresolvedIssues', () => {
it('returns concatenated array of unresolved errors, warnings, and notes', () => {
it('returns the array unresolved errors', () => {
localState.report = {
existing_errors: [1],
existing_warnings: [2],
existing_notes: [3],
};
const result = [1, 2, 3];
const result = [1];
expect(getters.unresolvedIssues(localState)).toEqual(result);
});
});
describe('resolvedIssues', () => {
it('returns concatenated array of resolved errors, warnings, and notes', () => {
it('returns array of resolved errors', () => {
localState.report = {
resolved_errors: [1],
resolved_warnings: [2],
resolved_notes: [3],
};
const result = [1, 2, 3];
const result = [1];
expect(getters.resolvedIssues(localState)).toEqual(result);
});
});
describe('newIssues', () => {
it('returns concatenated array of new errors, warnings, and notes', () => {
it('returns array of new errors', () => {
localState.report = {
new_errors: [1],
new_warnings: [2],
new_notes: [3],
};
const result = [1, 2, 3];
const result = [1];
expect(getters.newIssues(localState)).toEqual(result);
});
......
......@@ -93,6 +93,28 @@ describe MergeRequestPollWidgetEntity do
end
end
describe 'accessibility_report_path' do
context 'when merge request has accessibility reports' do
before do
allow(resource).to receive(:has_accessibility_reports?).and_return(true)
end
it 'set the path to poll data' do
expect(subject[:accessibility_report_path]).to be_present
end
end
context 'when merge request has no accessibility reports' do
before do
allow(resource).to receive(:has_accessibility_reports?).and_return(false)
end
it 'set the path to poll data' do
expect(subject[:accessibility_report_path]).to be_nil
end
end
end
describe 'exposed_artifacts_path' do
context 'when merge request has exposed artifacts' do
before do
......
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