diff --git a/lib/content-services/src/lib/content-node-selector/content-node-selector-panel.component.spec.ts b/lib/content-services/src/lib/content-node-selector/content-node-selector-panel.component.spec.ts index 79b0c3fbf7..48fc2de566 100644 --- a/lib/content-services/src/lib/content-node-selector/content-node-selector-panel.component.spec.ts +++ b/lib/content-services/src/lib/content-node-selector/content-node-selector-panel.component.spec.ts @@ -243,6 +243,7 @@ describe('ContentNodeSelectorPanelComponent', () => { }); it('should not show the breadcrumb if search was performed as last action', async () => { + component.searchTerm = 'mock-search-term'; triggerSearchResults(fakeResultSetPaging); fixture.detectChanges(); @@ -263,6 +264,7 @@ describe('ContentNodeSelectorPanelComponent', () => { }); it('should show the breadcrumb for the selected node when search results are displayed', async () => { + component.searchTerm = 'mock-search-term'; triggerSearchResults(fakeResultSetPaging); const chosenNode = new Node({ path: { elements: ['one'] } }); @@ -642,6 +644,7 @@ describe('ContentNodeSelectorPanelComponent', () => { })); it('should emit showingSearch event with true while searching', async () => { + component.searchTerm = 'mock-search-term'; spyOn(customResourcesService, 'hasCorrespondingNodeIds').and.returnValue(true); const showingSearchSpy = spyOn(component.showingSearch, 'emit'); @@ -685,6 +688,7 @@ describe('ContentNodeSelectorPanelComponent', () => { }); it('should emit showingResults event with false if search api fails', async () => { + component.searchTerm = 'mock-search-term'; getCorrespondingNodeIdsSpy.and.throwError('Failed'); const showingSearchSpy = spyOn(component.showingSearch, 'emit'); component.queryBuilderService.execute({ query: { query: 'search' } }); @@ -845,6 +849,18 @@ describe('ContentNodeSelectorPanelComponent', () => { }, 300); }); + it('should not show the result list when results are returned but there is no search term typed', (done) => { + component.searchTerm = ''; + + setTimeout(() => { + triggerSearchResults(fakeResultSetPaging); + fixture.detectChanges(); + + expect(component.showingSearchResults).toEqual(false); + done(); + }, 300); + }); + it('should highlight the results when search was performed in the next timeframe', (done) => { typeToSearchBox('My'); diff --git a/lib/content-services/src/lib/content-node-selector/content-node-selector-panel.component.ts b/lib/content-services/src/lib/content-node-selector/content-node-selector-panel.component.ts index 66edbed806..2f7426ce9a 100644 --- a/lib/content-services/src/lib/content-node-selector/content-node-selector-panel.component.ts +++ b/lib/content-services/src/lib/content-node-selector/content-node-selector-panel.component.ts @@ -304,7 +304,9 @@ export class ContentNodeSelectorPanelComponent implements OnInit, OnDestroy { this.queryBuilderService.executed .pipe(takeUntil(this.onDestroy$)) .subscribe( (results: NodePaging) => { - this.showSearchResults(results); + if (this.searchTerm) { + this.showSearchResults(results); + } }); this.userPreferencesService