Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AAE-4661] Fix search results are still displayed when search term ge… #6707

Merged
merged 2 commits into from
Feb 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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'] } });
Expand Down Expand Up @@ -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');

Expand Down Expand Up @@ -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' } });
Expand Down Expand Up @@ -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');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down