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 not showing results when filtering by content model pr… #6723

Merged
merged 1 commit into from
Feb 23, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,8 @@ describe('ContentNodeSelectorPanelComponent', () => {
});

it('should not show the breadcrumb if search was performed as last action', async () => {
component.searchTerm = 'mock-search-term';
searchQueryBuilderService.userQuery = 'mock-search-term';
searchQueryBuilderService.update();
triggerSearchResults(fakeResultSetPaging);

fixture.detectChanges();
Expand All @@ -264,7 +265,8 @@ describe('ContentNodeSelectorPanelComponent', () => {
});

it('should show the breadcrumb for the selected node when search results are displayed', async () => {
component.searchTerm = 'mock-search-term';
searchQueryBuilderService.userQuery = 'mock-search-term';
searchQueryBuilderService.update();
triggerSearchResults(fakeResultSetPaging);

const chosenNode = new Node({ path: { elements: ['one'] } });
Expand Down Expand Up @@ -644,7 +646,8 @@ describe('ContentNodeSelectorPanelComponent', () => {
}));

it('should emit showingSearch event with true while searching', async () => {
component.searchTerm = 'mock-search-term';
searchQueryBuilderService.userQuery = 'mock-search-term';
searchQueryBuilderService.update();
spyOn(customResourcesService, 'hasCorrespondingNodeIds').and.returnValue(true);
const showingSearchSpy = spyOn(component.showingSearch, 'emit');

Expand Down Expand Up @@ -688,7 +691,8 @@ describe('ContentNodeSelectorPanelComponent', () => {
});

it('should emit showingResults event with false if search api fails', async () => {
component.searchTerm = 'mock-search-term';
searchQueryBuilderService.userQuery = 'mock-search-term';
searchQueryBuilderService.update();
getCorrespondingNodeIdsSpy.and.throwError('Failed');
const showingSearchSpy = spyOn(component.showingSearch, 'emit');
component.queryBuilderService.execute({ query: { query: 'search' } });
Expand Down Expand Up @@ -852,18 +856,21 @@ describe('ContentNodeSelectorPanelComponent', () => {
fixture.detectChanges();
const documentList = fixture.debugElement.query(By.css('[data-automation-id="content-node-selector-document-list"]'));
expect(documentList).not.toBeNull('Document list should be shown');
expect(component.hasValidQuery).toEqual(true);
expect(documentList.componentInstance.currentFolderId).toBeNull();
done();
}, 300);
});

it('should not show the result list when results are returned but there is no search term typed', (done) => {
component.searchTerm = '';
searchQueryBuilderService.userQuery = '';
searchQueryBuilderService.update();

setTimeout(() => {
triggerSearchResults(fakeResultSetPaging);
fixture.detectChanges();

expect(component.hasValidQuery).toEqual(false);
expect(component.showingSearchResults).toEqual(false);
done();
}, 300);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ export class ContentNodeSelectorPanelComponent implements OnInit, OnDestroy {
folderIdToShow: string | null = null;
breadcrumbFolderTitle: string | null = null;
startSiteGuid: string | null = null;
hasValidQuery: boolean = false;

@ViewChild(InfinitePaginationComponent, { static: true })
infinitePaginationComponent: InfinitePaginationComponent;
Expand Down Expand Up @@ -293,18 +294,20 @@ export class ContentNodeSelectorPanelComponent implements OnInit, OnDestroy {
.pipe(takeUntil(this.onDestroy$))
.subscribe((queryBody: QueryBody) => {
if (queryBody) {
this.hasValidQuery = true;
this.prepareDialogForNewSearch(queryBody);
this.queryBuilderService.execute(queryBody);
} else {
this.hasValidQuery = false;
this.resetFolderToShow();
this.clearSearch();
}
});

this.queryBuilderService.executed
.pipe(takeUntil(this.onDestroy$))
.subscribe( (results: NodePaging) => {
if (this.searchTerm) {
.subscribe((results: NodePaging) => {
if (this.hasValidQuery) {
this.showSearchResults(results);
}
});
Expand Down