Merge "Magic Search filter facet removal fix"

This commit is contained in:
Zuul 2021-07-22 07:32:09 +00:00 committed by Gerrit Code Review
commit 9ba9a54d0f
2 changed files with 12 additions and 0 deletions

View File

@ -334,6 +334,10 @@
delete ctrl.textSearch;
} else {
$scope.$emit(magicSearchEvents.SEARCH_UPDATED, query);
if (angular.isDefined(ctrl.textSearch)) {
// emit text search if text facet remains
emitTextSearch(ctrl.textSearch || '');
}
if (ctrl.currentSearch.length > 0) {
// prune facets as needed from menus
var newFacet = ctrl.currentSearch[ctrl.currentSearch.length - 1].name;

View File

@ -509,6 +509,14 @@
expect(scope.strings.prompt).toEqual('');
});
it("emits textSearch if text facet remains", function() {
spyOn(scope, '$emit');
ctrl.currentSearch = [{}];
ctrl.textSearch = 'cat';
ctrl.removeFacet(0);
expect(scope.$emit).toHaveBeenCalledWith(magicSearchEvents.TEXT_SEARCH, 'cat', undefined);
});
it("resets state if facet selected", function() {
ctrl.currentSearch = [{}];
ctrl.facetSelected = {};