[ACA-4099] Fix search query in content node selector (#6299)

This commit is contained in:
arditdomi
2020-11-04 10:08:23 +00:00
committed by GitHub
parent 3f121384c9
commit 7bb3c30154
3 changed files with 7 additions and 6 deletions

View File

@@ -96,6 +96,7 @@ describe('ContentNodeSelectorPanelComponent', () => {
sitesService = TestBed.inject(SitesService); sitesService = TestBed.inject(SitesService);
contentNodeSelectorPanelService = TestBed.inject(ContentNodeSelectorPanelService); contentNodeSelectorPanelService = TestBed.inject(ContentNodeSelectorPanelService);
searchQueryBuilderService = component.queryBuilderService; searchQueryBuilderService = component.queryBuilderService;
component.queryBuilderService.resetToDefaults();
spyOn(nodeService, 'getNode').and.returnValue(of({ id: 'fake-node', path: { elements: [{ nodeType: 'st:site', name: 'fake-site'}] } })); spyOn(nodeService, 'getNode').and.returnValue(of({ id: 'fake-node', path: { elements: [{ nodeType: 'st:site', name: 'fake-site'}] } }));
searchSpy = spyOn(searchQueryBuilderService, 'execute'); searchSpy = spyOn(searchQueryBuilderService, 'execute');
@@ -400,12 +401,12 @@ describe('ContentNodeSelectorPanelComponent', () => {
fixture.detectChanges(); fixture.detectChanges();
expect(updateSpy).toHaveBeenCalled(); expect(updateSpy).toHaveBeenCalled();
expect(searchQueryBuilderService.userQuery).toEqual('(search-term)'); expect(searchQueryBuilderService.userQuery).toEqual('(search-term*)');
expect(component.searchTerm).toEqual('search-term'); expect(component.searchTerm).toEqual('search-term');
})); }));
it('should perform a search when the queryBody gets updated and it is defined', async () => { it('should perform a search when the queryBody gets updated and it is defined', async () => {
searchQueryBuilderService.userQuery = 'search-term'; searchQueryBuilderService.userQuery = 'search-term*';
searchQueryBuilderService.update(); searchQueryBuilderService.update();
fixture.detectChanges(); fixture.detectChanges();
@@ -695,7 +696,7 @@ describe('ContentNodeSelectorPanelComponent', () => {
}); });
it('should the query restrict the search to the site and not to the currentFolderId in case is changed', () => { it('should the query restrict the search to the site and not to the currentFolderId in case is changed', () => {
component.queryBuilderService.userQuery = 'search-term'; component.queryBuilderService.userQuery = 'search-term*';
component.currentFolderId = 'my-root-id'; component.currentFolderId = 'my-root-id';
component.restrictRootToCurrentFolderId = true; component.restrictRootToCurrentFolderId = true;
component.siteChanged(<SiteEntry> { entry: { guid: 'my-site-id' } }); component.siteChanged(<SiteEntry> { entry: { guid: 'my-site-id' } });

View File

@@ -273,9 +273,9 @@ export class ContentNodeSelectorPanelComponent implements OnInit, OnDestroy {
debounceTime(this.debounceSearch), debounceTime(this.debounceSearch),
takeUntil(this.onDestroy$) takeUntil(this.onDestroy$)
) )
.subscribe(searchValue => { .subscribe((searchValue: string) => {
this.searchTerm = searchValue; this.searchTerm = searchValue;
this.queryBuilderService.userQuery = searchValue; this.queryBuilderService.userQuery = searchValue.length > 0 ? `${searchValue}*` : searchValue ;
this.queryBuilderService.update(); this.queryBuilderService.update();
}); });

View File

@@ -19,7 +19,7 @@ import { QueryBody } from '@alfresco/js-api';
export const mockQueryBody: QueryBody = <QueryBody> { export const mockQueryBody: QueryBody = <QueryBody> {
query: { query: {
query: '(search-term)', query: '(search-term*)',
language: 'afts' language: 'afts'
}, },
include: ['path', 'allowableOperations'], include: ['path', 'allowableOperations'],