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

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

Merged
merged 1 commit into from
Nov 4, 2020
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 @@ -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 @@ -269,9 +269,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