mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-31 17:38:48 +00:00
[AAE-4661] Fix not showing results when filtering by content model properties (#6723)
This commit is contained in:
@@ -243,7 +243,8 @@ 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';
|
searchQueryBuilderService.userQuery = 'mock-search-term';
|
||||||
|
searchQueryBuilderService.update();
|
||||||
triggerSearchResults(fakeResultSetPaging);
|
triggerSearchResults(fakeResultSetPaging);
|
||||||
|
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
@@ -264,7 +265,8 @@ 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';
|
searchQueryBuilderService.userQuery = 'mock-search-term';
|
||||||
|
searchQueryBuilderService.update();
|
||||||
triggerSearchResults(fakeResultSetPaging);
|
triggerSearchResults(fakeResultSetPaging);
|
||||||
|
|
||||||
const chosenNode = new Node({ path: { elements: ['one'] } });
|
const chosenNode = new Node({ path: { elements: ['one'] } });
|
||||||
@@ -644,7 +646,8 @@ 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';
|
searchQueryBuilderService.userQuery = 'mock-search-term';
|
||||||
|
searchQueryBuilderService.update();
|
||||||
spyOn(customResourcesService, 'hasCorrespondingNodeIds').and.returnValue(true);
|
spyOn(customResourcesService, 'hasCorrespondingNodeIds').and.returnValue(true);
|
||||||
const showingSearchSpy = spyOn(component.showingSearch, 'emit');
|
const showingSearchSpy = spyOn(component.showingSearch, 'emit');
|
||||||
|
|
||||||
@@ -688,7 +691,8 @@ 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';
|
searchQueryBuilderService.userQuery = 'mock-search-term';
|
||||||
|
searchQueryBuilderService.update();
|
||||||
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' } });
|
||||||
@@ -852,18 +856,21 @@ describe('ContentNodeSelectorPanelComponent', () => {
|
|||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
const documentList = fixture.debugElement.query(By.css('[data-automation-id="content-node-selector-document-list"]'));
|
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(documentList).not.toBeNull('Document list should be shown');
|
||||||
|
expect(component.hasValidQuery).toEqual(true);
|
||||||
expect(documentList.componentInstance.currentFolderId).toBeNull();
|
expect(documentList.componentInstance.currentFolderId).toBeNull();
|
||||||
done();
|
done();
|
||||||
}, 300);
|
}, 300);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not show the result list when results are returned but there is no search term typed', (done) => {
|
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(() => {
|
setTimeout(() => {
|
||||||
triggerSearchResults(fakeResultSetPaging);
|
triggerSearchResults(fakeResultSetPaging);
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
|
|
||||||
|
expect(component.hasValidQuery).toEqual(false);
|
||||||
expect(component.showingSearchResults).toEqual(false);
|
expect(component.showingSearchResults).toEqual(false);
|
||||||
done();
|
done();
|
||||||
}, 300);
|
}, 300);
|
||||||
|
@@ -242,6 +242,7 @@ export class ContentNodeSelectorPanelComponent implements OnInit, OnDestroy {
|
|||||||
folderIdToShow: string | null = null;
|
folderIdToShow: string | null = null;
|
||||||
breadcrumbFolderTitle: string | null = null;
|
breadcrumbFolderTitle: string | null = null;
|
||||||
startSiteGuid: string | null = null;
|
startSiteGuid: string | null = null;
|
||||||
|
hasValidQuery: boolean = false;
|
||||||
|
|
||||||
@ViewChild(InfinitePaginationComponent, { static: true })
|
@ViewChild(InfinitePaginationComponent, { static: true })
|
||||||
infinitePaginationComponent: InfinitePaginationComponent;
|
infinitePaginationComponent: InfinitePaginationComponent;
|
||||||
@@ -293,9 +294,11 @@ export class ContentNodeSelectorPanelComponent implements OnInit, OnDestroy {
|
|||||||
.pipe(takeUntil(this.onDestroy$))
|
.pipe(takeUntil(this.onDestroy$))
|
||||||
.subscribe((queryBody: QueryBody) => {
|
.subscribe((queryBody: QueryBody) => {
|
||||||
if (queryBody) {
|
if (queryBody) {
|
||||||
|
this.hasValidQuery = true;
|
||||||
this.prepareDialogForNewSearch(queryBody);
|
this.prepareDialogForNewSearch(queryBody);
|
||||||
this.queryBuilderService.execute(queryBody);
|
this.queryBuilderService.execute(queryBody);
|
||||||
} else {
|
} else {
|
||||||
|
this.hasValidQuery = false;
|
||||||
this.resetFolderToShow();
|
this.resetFolderToShow();
|
||||||
this.clearSearch();
|
this.clearSearch();
|
||||||
}
|
}
|
||||||
@@ -304,7 +307,7 @@ 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) {
|
if (this.hasValidQuery) {
|
||||||
this.showSearchResults(results);
|
this.showSearchResults(results);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user