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,6 +19,7 @@ describe('CodeReviewAnalytics utils', () => { ...@@ -19,6 +19,7 @@ describe('CodeReviewAnalytics utils', () => {
}); });
describe('when "not[label_name]" filter is present', () => { describe('when "not[label_name]" filter is present', () => {
describe('and "label_name" filter is present', () => {
it('applies the "!=" operator to the selectedLabels array', () => { it('applies the "!=" operator to the selectedLabels array', () => {
const filters = { const filters = {
milestone_title: 'my-milestone', milestone_title: 'my-milestone',
...@@ -35,6 +36,19 @@ describe('CodeReviewAnalytics utils', () => { ...@@ -35,6 +36,19 @@ describe('CodeReviewAnalytics utils', () => {
}); });
}); });
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,
});
});
});
});
describe('when "not[milestone_title]" filter is present', () => { describe('when "not[milestone_title]" filter is present', () => {
it('applies the "!=" operator to the selectedMilestone object', () => { it('applies the "!=" operator to the selectedMilestone object', () => {
const filters = { const filters = {
......
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