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