From 697b0c634d4d44bd0b8e6eb1379f3da404fb46f8 Mon Sep 17 00:00:00 2001 From: John Mitchell Date: Wed, 29 Apr 2020 16:30:29 -0400 Subject: [PATCH] add additional merge params test, remove unnecessary span container from search chips --- awx/ui_next/src/components/Search/Search.jsx | 4 ++-- awx/ui_next/src/util/qs.test.js | 22 ++++++++++++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/awx/ui_next/src/components/Search/Search.jsx b/awx/ui_next/src/components/Search/Search.jsx index 25b450053c..d24bd1273c 100644 --- a/awx/ui_next/src/components/Search/Search.jsx +++ b/awx/ui_next/src/components/Search/Search.jsx @@ -187,13 +187,13 @@ class Search extends React.Component { queryParams[key].forEach(val => queryParamsByKey[columnKey].chips.push({ key: `${key}:${val}`, - node: {getLabelFromValue(val, columnKey)}, + node: getLabelFromValue(val, columnKey), }) ); } else { queryParamsByKey[columnKey].chips.push({ key: `${key}:${queryParams[key]}`, - node: {getLabelFromValue(queryParams[key], columnKey)}, + node: getLabelFromValue(queryParams[key], columnKey), }); } }); diff --git a/awx/ui_next/src/util/qs.test.js b/awx/ui_next/src/util/qs.test.js index 1f711e30f6..763b07434c 100644 --- a/awx/ui_next/src/util/qs.test.js +++ b/awx/ui_next/src/util/qs.test.js @@ -652,6 +652,28 @@ describe('qs (qs.js)', () => { }); }); + it('should not remove empty string values', () => { + const oldParams = { + foo: '', + }; + const newParams = { + foo: 'two', + }; + expect(mergeParams(oldParams, newParams)).toEqual({ + foo: ['', 'two'], + }); + + const oldParams2 = { + foo: 'one', + }; + const newParams2 = { + foo: '', + }; + expect(mergeParams(oldParams2, newParams2)).toEqual({ + foo: ['one', ''], + }); + }); + it('should retain unaltered params', () => { const oldParams = { foo: 'one',