From cddca298d57475a6af5fb48be37601a147df0f45 Mon Sep 17 00:00:00 2001 From: Allen Wight Date: Fri, 7 Dec 2018 14:07:53 -0500 Subject: [PATCH] Unshift tag placeholder message onto filtered array, 's nondestructive MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previous implementation replaced first tag option with this 🙀😑 --- client/app/shared/tagging/tagging.component.js | 2 +- .../app/shared/tagging/tagging.component.spec.js | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/client/app/shared/tagging/tagging.component.js b/client/app/shared/tagging/tagging.component.js index abd69179c..3280b8d8b 100644 --- a/client/app/shared/tagging/tagging.component.js +++ b/client/app/shared/tagging/tagging.component.js @@ -99,7 +99,7 @@ function TaggingController ($scope, $filter, $q, $log, CollectionsApi, TaggingSe $scope.$watch('vm.tags.selectedCategory', function () { vm.tags.filtered = $filter('filter')(vm.tags.all, matchCategory) if (vm.tags.filtered) { - vm.tags.filtered[0] = placeholderCategorization + vm.tags.filtered.unshift(placeholderCategorization) vm.tags.selectedTag = vm.tags.filtered[0] vm.showTagDropdowns = !vm.readOnly } diff --git a/client/app/shared/tagging/tagging.component.spec.js b/client/app/shared/tagging/tagging.component.spec.js index da908c486..596cbe796 100644 --- a/client/app/shared/tagging/tagging.component.spec.js +++ b/client/app/shared/tagging/tagging.component.spec.js @@ -76,7 +76,7 @@ describe('Component: taggingWidget', () => { let tagsOfCategorySelect = element.find('.tag-value-select') let tagsOfCategory = angular.element(tagsOfCategorySelect).find('option') - expect(tagsOfCategory.length).to.be.eq(6) // 6 Auto Approve options + expect(tagsOfCategory.length).to.be.eq(7) // 6 Auto Approve options expect(tagsOfCategory[0].selected).to.be.eq(true) done() @@ -88,7 +88,7 @@ describe('Component: taggingWidget', () => { // Select tag category 'Department' and tag 'Accounting' isoScope.vm.tags.selectedCategory = isoScope.vm.tags.categories[8] isoScope.$digest() - isoScope.vm.tags.selectedTag = isoScope.vm.tags.filtered[1] + isoScope.vm.tags.selectedTag = isoScope.vm.tags.filtered[2] isoScope.$digest() expect(isoScope.vm.tags.selectedTag.name).to.be.eq('/managed/department/accounting') @@ -100,8 +100,8 @@ describe('Component: taggingWidget', () => { let tagsOfCategorySelect = element.find('.tag-value-select') let tagsOfCategory = angular.element(tagsOfCategorySelect).find('option') - expect(tagsOfCategory[1].text).to.be.eq('Accounting') - expect(tagsOfCategory[1].selected).to.be.eq(true) + expect(tagsOfCategory[2].text).to.be.eq('Accounting') + expect(tagsOfCategory[2].selected).to.be.eq(true) // should be 2 existing tags let tagsOfItem = element.find('.pficon-close') @@ -130,7 +130,7 @@ describe('Component: taggingWidget', () => { // Select tag category 'Service Level' and tag 'Platinum' isoScope.vm.tags.selectedCategory = isoScope.vm.tags.categories[24] isoScope.$digest() - isoScope.vm.tags.selectedTag = isoScope.vm.tags.filtered[3] + isoScope.vm.tags.selectedTag = isoScope.vm.tags.filtered[4] isoScope.$digest() expect(isoScope.vm.tags.selectedTag.name).to.be.eq('/managed/service_level/platinum') @@ -142,8 +142,8 @@ describe('Component: taggingWidget', () => { let tagsOfCategorySelect = element.find('.tag-value-select') let tagsOfCategory = angular.element(tagsOfCategorySelect).find('option') - expect(tagsOfCategory[3].text).to.be.eq('Platinum') - expect(tagsOfCategory[3].selected).to.be.eq(true) + expect(tagsOfCategory[4].text).to.be.eq('Platinum') + expect(tagsOfCategory[4].selected).to.be.eq(true) // This should replace Service Level Gold with Service Level Platinum let addItem = element.find('.fa-plus')