Commit bc8fbd0c authored by Miguel Rincon's avatar Miguel Rincon

Merge branch '320959-sort-full-codequality-report' into 'master'

Sort issues in full codequality report by severity

See merge request gitlab-org/gitlab!56892
parents 8b4e49c8 28221c76
export const VIEW_EVENT_FEATURE_FLAG = 'usageDataITestingFullCodeQualityReportTotal'; export const VIEW_EVENT_FEATURE_FLAG = 'usageDataITestingFullCodeQualityReportTotal';
export const VIEW_EVENT_NAME = 'i_testing_full_code_quality_report_total'; export const VIEW_EVENT_NAME = 'i_testing_full_code_quality_report_total';
export const SEVERITY_SORT_ORDER = {
unknown: 0,
blocker: 1,
critical: 2,
major: 3,
minor: 4,
info: 5,
};
import { SEVERITY_SORT_ORDER } from './constants';
import * as types from './mutation_types'; import * as types from './mutation_types';
export default { export default {
...@@ -14,7 +15,11 @@ export default { ...@@ -14,7 +15,11 @@ export default {
[types.RECEIVE_REPORT_SUCCESS](state, allCodequalityIssues) { [types.RECEIVE_REPORT_SUCCESS](state, allCodequalityIssues) {
Object.assign(state, { Object.assign(state, {
isLoadingCodequality: false, isLoadingCodequality: false,
allCodequalityIssues: Object.freeze(allCodequalityIssues), allCodequalityIssues: Object.freeze(
allCodequalityIssues.sort(
(a, b) => SEVERITY_SORT_ORDER[a.severity] - SEVERITY_SORT_ORDER[b.severity],
),
),
pageInfo: Object.assign(state.pageInfo, { pageInfo: Object.assign(state.pageInfo, {
total: allCodequalityIssues.length, total: allCodequalityIssues.length,
}), }),
......
---
title: Sort issues in full codequality report by severity
merge_request: 56892
author:
type: changed
...@@ -35,6 +35,24 @@ describe('Codequality report mutations', () => { ...@@ -35,6 +35,24 @@ describe('Codequality report mutations', () => {
expect(state.allCodequalityIssues).toBe(parsedIssues); expect(state.allCodequalityIssues).toBe(parsedIssues);
expect(state.pageInfo.total).toBe(parsedIssues.length); expect(state.pageInfo.total).toBe(parsedIssues.length);
}); });
it('should sort issues by severity', () => {
mutations[types.RECEIVE_REPORT_SUCCESS](state, [
{ severity: 'critical' },
{ severity: 'blocker' },
{ severity: 'info' },
{ severity: 'minor' },
{ severity: 'unknown' },
{ severity: 'major' },
]);
expect(state.allCodequalityIssues[0].severity).toBe('unknown');
expect(state.allCodequalityIssues[1].severity).toBe('blocker');
expect(state.allCodequalityIssues[2].severity).toBe('critical');
expect(state.allCodequalityIssues[3].severity).toBe('major');
expect(state.allCodequalityIssues[4].severity).toBe('minor');
expect(state.allCodequalityIssues[5].severity).toBe('info');
});
}); });
describe('receive report error', () => { describe('receive report error', () => {
......
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