Commit e4d0c250 authored by Phil Hughes's avatar Phil Hughes

Merge branch 'mw-cr-not-label-fix' into 'master'

Set selectedLabels to empty array

See merge request gitlab-org/gitlab!32406
parents 2a2e39e9 23a368a9
...@@ -17,7 +17,7 @@ const transformFilters = filters => { ...@@ -17,7 +17,7 @@ const transformFilters = filters => {
'not[milestone_title]': notMilestoneTitle, 'not[milestone_title]': notMilestoneTitle,
} = filters; } = filters;
let selectedLabels = labelNames?.map(label => ({ value: label, operator: '=' })); let selectedLabels = labelNames?.map(label => ({ value: label, operator: '=' })) || [];
let selectedMilestone = null; let selectedMilestone = null;
if (notLabelNames) { if (notLabelNames) {
......
...@@ -19,18 +19,32 @@ describe('CodeReviewAnalytics utils', () => { ...@@ -19,18 +19,32 @@ describe('CodeReviewAnalytics utils', () => {
}); });
describe('when "not[label_name]" filter is present', () => { describe('when "not[label_name]" filter is present', () => {
it('applies the "!=" operator to the selectedLabels array', () => { describe('and "label_name" filter is present', () => {
const filters = { it('applies the "!=" operator to the selectedLabels array', () => {
milestone_title: 'my-milestone', const filters = {
label_name: ['my-label'], milestone_title: 'my-milestone',
'not[label_name]': ['another label'], label_name: ['my-label'],
}; 'not[label_name]': ['another label'],
expect(transformFilters(filters)).toEqual({ };
selectedMilestone: { value: 'my-milestone', operator: '=' }, expect(transformFilters(filters)).toEqual({
selectedLabels: [ selectedMilestone: { value: 'my-milestone', operator: '=' },
{ value: 'my-label', operator: '=' }, selectedLabels: [
{ value: 'another label', operator: '!=' }, { value: 'my-label', operator: '=' },
], { value: 'another label', operator: '!=' },
],
});
});
});
describe('and "label_name" filter is missing', () => {
it('applies the "!=" operator to the selectedLabels array', () => {
const filters = {
'not[label_name]': ['another label'],
};
expect(transformFilters(filters)).toEqual({
selectedLabels: [{ value: 'another label', operator: '!=' }],
selectedMilestone: null,
});
}); });
}); });
}); });
......
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