Skip to content

Commit

Permalink
[ACA-4099] Fix search query in content node selector (#6299)
Browse files Browse the repository at this point in the history
  • Loading branch information
arditdomi committed Nov 4, 2020
1 parent 3f12138 commit 7bb3c30
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ describe('ContentNodeSelectorPanelComponent', () => {
sitesService = TestBed.inject(SitesService);
contentNodeSelectorPanelService = TestBed.inject(ContentNodeSelectorPanelService);
searchQueryBuilderService = component.queryBuilderService;
component.queryBuilderService.resetToDefaults();

spyOn(nodeService, 'getNode').and.returnValue(of({ id: 'fake-node', path: { elements: [{ nodeType: 'st:site', name: 'fake-site'}] } }));
searchSpy = spyOn(searchQueryBuilderService, 'execute');
Expand Down Expand Up @@ -400,12 +401,12 @@ describe('ContentNodeSelectorPanelComponent', () => {
fixture.detectChanges();

expect(updateSpy).toHaveBeenCalled();
expect(searchQueryBuilderService.userQuery).toEqual('(search-term)');
expect(searchQueryBuilderService.userQuery).toEqual('(search-term*)');
expect(component.searchTerm).toEqual('search-term');
}));

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();

fixture.detectChanges();
Expand Down Expand Up @@ -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', () => {
component.queryBuilderService.userQuery = 'search-term';
component.queryBuilderService.userQuery = 'search-term*';
component.currentFolderId = 'my-root-id';
component.restrictRootToCurrentFolderId = true;
component.siteChanged(<SiteEntry> { entry: { guid: 'my-site-id' } });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,9 +273,9 @@ export class ContentNodeSelectorPanelComponent implements OnInit, OnDestroy {
debounceTime(this.debounceSearch),
takeUntil(this.onDestroy$)
)
.subscribe(searchValue => {
.subscribe((searchValue: string) => {
this.searchTerm = searchValue;
this.queryBuilderService.userQuery = searchValue;
this.queryBuilderService.userQuery = searchValue.length > 0 ? `${searchValue}*` : searchValue ;
this.queryBuilderService.update();
});

Expand Down
2 changes: 1 addition & 1 deletion lib/content-services/src/lib/mock/search-query.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { QueryBody } from '@alfresco/js-api';

export const mockQueryBody: QueryBody = <QueryBody> {
query: {
query: '(search-term)',
query: '(search-term*)',
language: 'afts'
},
include: ['path', 'allowableOperations'],
Expand Down

0 comments on commit 7bb3c30

Please sign in to comment.