mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[AAE-4661] Fix search results are still displayed when search term ge… (#6707)
* [AAE-4661] Fix search results are still displayed when search term gets deleted * Fix unit tests
This commit is contained in:
@@ -243,6 +243,7 @@ describe('ContentNodeSelectorPanelComponent', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should not show the breadcrumb if search was performed as last action', async () => {
|
it('should not show the breadcrumb if search was performed as last action', async () => {
|
||||||
|
component.searchTerm = 'mock-search-term';
|
||||||
triggerSearchResults(fakeResultSetPaging);
|
triggerSearchResults(fakeResultSetPaging);
|
||||||
|
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
@@ -263,6 +264,7 @@ describe('ContentNodeSelectorPanelComponent', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should show the breadcrumb for the selected node when search results are displayed', async () => {
|
it('should show the breadcrumb for the selected node when search results are displayed', async () => {
|
||||||
|
component.searchTerm = 'mock-search-term';
|
||||||
triggerSearchResults(fakeResultSetPaging);
|
triggerSearchResults(fakeResultSetPaging);
|
||||||
|
|
||||||
const chosenNode = new Node({ path: { elements: ['one'] } });
|
const chosenNode = new Node({ path: { elements: ['one'] } });
|
||||||
@@ -642,6 +644,7 @@ describe('ContentNodeSelectorPanelComponent', () => {
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
it('should emit showingSearch event with true while searching', async () => {
|
it('should emit showingSearch event with true while searching', async () => {
|
||||||
|
component.searchTerm = 'mock-search-term';
|
||||||
spyOn(customResourcesService, 'hasCorrespondingNodeIds').and.returnValue(true);
|
spyOn(customResourcesService, 'hasCorrespondingNodeIds').and.returnValue(true);
|
||||||
const showingSearchSpy = spyOn(component.showingSearch, 'emit');
|
const showingSearchSpy = spyOn(component.showingSearch, 'emit');
|
||||||
|
|
||||||
@@ -685,6 +688,7 @@ describe('ContentNodeSelectorPanelComponent', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should emit showingResults event with false if search api fails', async () => {
|
it('should emit showingResults event with false if search api fails', async () => {
|
||||||
|
component.searchTerm = 'mock-search-term';
|
||||||
getCorrespondingNodeIdsSpy.and.throwError('Failed');
|
getCorrespondingNodeIdsSpy.and.throwError('Failed');
|
||||||
const showingSearchSpy = spyOn(component.showingSearch, 'emit');
|
const showingSearchSpy = spyOn(component.showingSearch, 'emit');
|
||||||
component.queryBuilderService.execute({ query: { query: 'search' } });
|
component.queryBuilderService.execute({ query: { query: 'search' } });
|
||||||
@@ -845,6 +849,18 @@ describe('ContentNodeSelectorPanelComponent', () => {
|
|||||||
}, 300);
|
}, 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) => {
|
it('should highlight the results when search was performed in the next timeframe', (done) => {
|
||||||
typeToSearchBox('My');
|
typeToSearchBox('My');
|
||||||
|
|
||||||
|
@@ -304,7 +304,9 @@ export class ContentNodeSelectorPanelComponent implements OnInit, OnDestroy {
|
|||||||
this.queryBuilderService.executed
|
this.queryBuilderService.executed
|
||||||
.pipe(takeUntil(this.onDestroy$))
|
.pipe(takeUntil(this.onDestroy$))
|
||||||
.subscribe( (results: NodePaging) => {
|
.subscribe( (results: NodePaging) => {
|
||||||
|
if (this.searchTerm) {
|
||||||
this.showSearchResults(results);
|
this.showSearchResults(results);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
this.userPreferencesService
|
this.userPreferencesService
|
||||||
|
Reference in New Issue
Block a user