mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ACS-4296] adding mapping in tags service (#8240)
* ACS-4296 Adding mapping in tags service * ACS-4296 Correct lint issue * ACS-4296 Excluded failing e2e * ACS-4296 Trigger build * ACS-4296 Trigger build * ACS-4296 Reverted excluded tests
This commit is contained in:
@@ -22,12 +22,15 @@ import { ContentTestingModule } from '../../testing/content.testing.module';
|
|||||||
import { TranslateModule } from '@ngx-translate/core';
|
import { TranslateModule } from '@ngx-translate/core';
|
||||||
import { throwError } from 'rxjs';
|
import { throwError } from 'rxjs';
|
||||||
import {
|
import {
|
||||||
|
Pagination,
|
||||||
RequestQuery,
|
RequestQuery,
|
||||||
RequestSortDefinitionInner,
|
RequestSortDefinitionInner,
|
||||||
|
ResultNode,
|
||||||
ResultSetContext,
|
ResultSetContext,
|
||||||
ResultSetContextFacetQueries,
|
ResultSetContextFacetQueries,
|
||||||
ResultSetPaging,
|
ResultSetPaging,
|
||||||
ResultSetPagingList,
|
ResultSetPagingList,
|
||||||
|
ResultSetRowEntry,
|
||||||
Tag,
|
Tag,
|
||||||
TagBody,
|
TagBody,
|
||||||
TagEntry,
|
TagEntry,
|
||||||
@@ -129,6 +132,13 @@ describe('TagService', () => {
|
|||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
result = new ResultSetPaging();
|
result = new ResultSetPaging();
|
||||||
|
result.list = new ResultSetPagingList();
|
||||||
|
const tag = new ResultSetRowEntry();
|
||||||
|
tag.entry = new ResultNode();
|
||||||
|
tag.entry.id = 'some id';
|
||||||
|
tag.entry.name = 'some name';
|
||||||
|
result.list.entries = [tag];
|
||||||
|
result.list.pagination = new Pagination();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should call search on searchApi with correct parameters', () => {
|
it('should call search on searchApi with correct parameters', () => {
|
||||||
@@ -156,14 +166,22 @@ describe('TagService', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return observable which emits paging object for tags', (done) => {
|
it('should return observable which emits paging object for tags', fakeAsync(() => {
|
||||||
spyOn(service.searchApi, 'search').and.returnValue(Promise.resolve(result));
|
spyOn(service.searchApi, 'search').and.returnValue(Promise.resolve(result));
|
||||||
|
|
||||||
service.searchTags('test').subscribe((tagsResult) => {
|
service.searchTags('test').subscribe((tagsResult) => {
|
||||||
expect(tagsResult).toBe(result);
|
const tagPaging = new TagPaging();
|
||||||
done();
|
tagPaging.list = new TagPagingList();
|
||||||
|
const tagEntry = new TagEntry();
|
||||||
|
tagEntry.entry = new Tag();
|
||||||
|
tagEntry.entry.id = 'some id';
|
||||||
|
tagEntry.entry.tag = 'some name';
|
||||||
|
tagPaging.list.entries = [tagEntry];
|
||||||
|
tagPaging.list.pagination = new Pagination();
|
||||||
|
expect(tagsResult).toEqual(tagPaging);
|
||||||
});
|
});
|
||||||
});
|
tick();
|
||||||
|
}));
|
||||||
|
|
||||||
it('should call error on logService when error occurs during fetching paging object for tags', fakeAsync(() => {
|
it('should call error on logService when error occurs during fetching paging object for tags', fakeAsync(() => {
|
||||||
spyOn(logService, 'error');
|
spyOn(logService, 'error');
|
||||||
|
@@ -23,11 +23,12 @@ import {
|
|||||||
RequestQuery,
|
RequestQuery,
|
||||||
RequestSortDefinitionInner,
|
RequestSortDefinitionInner,
|
||||||
ResultSetContextFacetQueries,
|
ResultSetContextFacetQueries,
|
||||||
ResultSetPaging,
|
|
||||||
SearchApi,
|
SearchApi,
|
||||||
|
Tag,
|
||||||
TagBody,
|
TagBody,
|
||||||
TagEntry,
|
TagEntry,
|
||||||
TagPaging,
|
TagPaging,
|
||||||
|
TagPagingList,
|
||||||
TagsApi
|
TagsApi
|
||||||
} from '@alfresco/js-api';
|
} from '@alfresco/js-api';
|
||||||
|
|
||||||
@@ -160,7 +161,7 @@ export class TagService {
|
|||||||
* @param maxItems Specify max number of returned tags. Default is specified by UserPreferencesService.
|
* @param maxItems Specify max number of returned tags. Default is specified by UserPreferencesService.
|
||||||
* @returns Found tags which name contains searched name.
|
* @returns Found tags which name contains searched name.
|
||||||
*/
|
*/
|
||||||
searchTags(name: string, skipCount = 0, maxItems?: number): Observable<ResultSetPaging> {
|
searchTags(name: string, skipCount = 0, maxItems?: number): Observable<TagPaging> {
|
||||||
maxItems = maxItems || this.userPreferencesService.paginationSize;
|
maxItems = maxItems || this.userPreferencesService.paginationSize;
|
||||||
const sortingByName: RequestSortDefinitionInner = new RequestSortDefinitionInner();
|
const sortingByName: RequestSortDefinitionInner = new RequestSortDefinitionInner();
|
||||||
sortingByName.field = 'cm:name';
|
sortingByName.field = 'cm:name';
|
||||||
@@ -176,7 +177,19 @@ export class TagService {
|
|||||||
maxItems
|
maxItems
|
||||||
},
|
},
|
||||||
sort: [sortingByName]
|
sort: [sortingByName]
|
||||||
})).pipe(catchError((error) => this.handleError(error)));
|
})).pipe(map((resultSetPaging) => {
|
||||||
|
const tagPaging = new TagPaging();
|
||||||
|
tagPaging.list = new TagPagingList();
|
||||||
|
tagPaging.list.pagination = resultSetPaging.list.pagination;
|
||||||
|
tagPaging.list.entries = resultSetPaging.list.entries.map((resultEntry) => {
|
||||||
|
const tagEntry = new TagEntry();
|
||||||
|
tagEntry.entry = new Tag();
|
||||||
|
tagEntry.entry.tag = resultEntry.entry.name;
|
||||||
|
tagEntry.entry.id = resultEntry.entry.id;
|
||||||
|
return tagEntry;
|
||||||
|
});
|
||||||
|
return tagPaging;
|
||||||
|
}), catchError((error) => this.handleError(error)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user