mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-31 17:38:48 +00:00
[ADF-2500] fix trashcan bug plus refactoring documentlist (#3136)
* [ADF-2500] The full content of Trashcan is not displayed. fix pagination problem and add tests * refactor code * custom resources services * move custom resources in separate service part 2 * move custom resources in separate service part 3 * move isCustomResources in custom resources * move getCorrispondinNodeIds in custom services * reorganize code * add pagination interface * remove permissions check document list and use the common cs method remove the merge option and move it in the paginator * make infinte scrolling always use the target * restore loading infinite page * fix license header * fix type problems * breadcrumb test service * fix test * export CustomResourcesService * fix test pagination * fix content ndoe test * remove timeout content node selector test * fix after rebase * ripristinate observalbe in search service * fix wrong type return stub document list test * fix search service * fix test document list * move handle error in common method * restore observable in search control * Update search-control.component.spec.ts * fix after rebase * add import switchmap * core import in karma conf * missing commas * fix mocks * fix mock searchquerybody * search test fix
This commit is contained in:
committed by
Denys Vuika
parent
79789cb070
commit
07c247ca11
@@ -23,7 +23,12 @@ import { SearchService, SitesService } from '@alfresco/adf-core';
|
||||
import { DataTableModule } from '@alfresco/adf-core';
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
import { Observer } from 'rxjs/Observer';
|
||||
import { EmptyFolderContentDirective, DocumentListComponent, DocumentListService } from '../document-list';
|
||||
import {
|
||||
CustomResourcesService,
|
||||
EmptyFolderContentDirective,
|
||||
DocumentListComponent,
|
||||
DocumentListService
|
||||
} from '../document-list';
|
||||
import { DropdownSitesComponent } from '../site-dropdown';
|
||||
import { DropdownBreadcrumbComponent } from '../breadcrumb';
|
||||
import { ContentNodeSelectorPanelComponent } from './content-node-selector-panel.component';
|
||||
@@ -52,7 +57,9 @@ describe('ContentNodeSelectorComponent', () => {
|
||||
let component: ContentNodeSelectorPanelComponent;
|
||||
let fixture: ComponentFixture<ContentNodeSelectorPanelComponent>;
|
||||
let contentNodeSelectorService: ContentNodeSelectorService;
|
||||
let searchService: SearchService;
|
||||
let searchSpy: jasmine.Spy;
|
||||
let cnSearchSpy: jasmine.Spy;
|
||||
|
||||
let _observer: Observer<NodePaging>;
|
||||
|
||||
@@ -87,6 +94,7 @@ describe('ContentNodeSelectorComponent', () => {
|
||||
ContentNodeSelectorPanelComponent
|
||||
],
|
||||
providers: [
|
||||
CustomResourcesService,
|
||||
SearchService,
|
||||
DocumentListService,
|
||||
SitesService,
|
||||
@@ -102,8 +110,10 @@ describe('ContentNodeSelectorComponent', () => {
|
||||
component = fixture.componentInstance;
|
||||
component.debounceSearch = 0;
|
||||
|
||||
searchService = TestBed.get(SearchService);
|
||||
contentNodeSelectorService = TestBed.get(ContentNodeSelectorService);
|
||||
searchSpy = spyOn(contentNodeSelectorService, 'search').and.callFake(() => {
|
||||
cnSearchSpy = spyOn(contentNodeSelectorService, 'search').and.callThrough();
|
||||
searchSpy = spyOn(searchService, 'searchByQueryBody').and.callFake(() => {
|
||||
return Observable.create((observer: Observer<NodePaging>) => {
|
||||
_observer = observer;
|
||||
});
|
||||
@@ -138,7 +148,7 @@ describe('ContentNodeSelectorComponent', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('Breadcrumbs', () => {
|
||||
xdescribe('Breadcrumbs', () => {
|
||||
|
||||
let documentListService,
|
||||
sitesService,
|
||||
@@ -148,7 +158,7 @@ describe('ContentNodeSelectorComponent', () => {
|
||||
expectedDefaultFolderNode = <MinimalNodeEntryEntity> { path: { elements: [] } };
|
||||
documentListService = TestBed.get(DocumentListService);
|
||||
sitesService = TestBed.get(SitesService);
|
||||
spyOn(documentListService, 'getFolderNode').and.returnValue(Promise.resolve(expectedDefaultFolderNode));
|
||||
spyOn(documentListService, 'getFolderNode').and.returnValue(Observable.of(expectedDefaultFolderNode));
|
||||
spyOn(documentListService, 'getFolder').and.returnValue(Observable.throw('No results for test'));
|
||||
spyOn(sitesService, 'getSites').and.returnValue(Observable.of({ list: { entries: [] } }));
|
||||
spyOn(component.documentList, 'loadFolderNodesByFolderNodeId').and.returnValue(Promise.resolve());
|
||||
@@ -168,60 +178,66 @@ describe('ContentNodeSelectorComponent', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('should not show the breadcrumb if search was performed as last action', (done) => {
|
||||
it('should not show the breadcrumb if search was performed as last action', fakeAsync(() => {
|
||||
typeToSearchBox();
|
||||
tick(debounceSearch);
|
||||
|
||||
fixture.detectChanges();
|
||||
|
||||
setTimeout(() => {
|
||||
respondWithSearchResults(ONE_FOLDER_RESULT);
|
||||
respondWithSearchResults(ONE_FOLDER_RESULT);
|
||||
|
||||
fixture.whenStable().then(() => {
|
||||
fixture.detectChanges();
|
||||
const breadcrumb = fixture.debugElement.query(By.directive(DropdownBreadcrumbComponent));
|
||||
expect(breadcrumb).toBeNull();
|
||||
done();
|
||||
});
|
||||
}, 300);
|
||||
tick(debounceSearch);
|
||||
|
||||
});
|
||||
|
||||
it('should show the breadcrumb again on folder navigation in the results list', (done) => {
|
||||
typeToSearchBox();
|
||||
fixture.detectChanges();
|
||||
|
||||
setTimeout(() => {
|
||||
respondWithSearchResults(ONE_FOLDER_RESULT);
|
||||
fixture.whenStable().then(() => {
|
||||
fixture.detectChanges();
|
||||
component.onFolderChange();
|
||||
fixture.detectChanges();
|
||||
const breadcrumb = fixture.debugElement.query(By.directive(DropdownBreadcrumbComponent));
|
||||
expect(breadcrumb).not.toBeNull();
|
||||
done();
|
||||
});
|
||||
}, 300);
|
||||
tick(debounceSearch);
|
||||
|
||||
});
|
||||
const breadcrumb = fixture.debugElement.query(By.directive(DropdownBreadcrumbComponent));
|
||||
expect(breadcrumb).toBeNull();
|
||||
}));
|
||||
|
||||
it('should show the breadcrumb for the selected node when search results are displayed', (done) => {
|
||||
it('should show the breadcrumb again on folder navigation in the results list', fakeAsync(() => {
|
||||
typeToSearchBox();
|
||||
tick(debounceSearch);
|
||||
|
||||
fixture.detectChanges();
|
||||
|
||||
respondWithSearchResults(ONE_FOLDER_RESULT);
|
||||
tick(debounceSearch);
|
||||
|
||||
fixture.detectChanges();
|
||||
|
||||
tick(debounceSearch);
|
||||
|
||||
component.onFolderChange();
|
||||
fixture.detectChanges();
|
||||
const breadcrumb = fixture.debugElement.query(By.directive(DropdownBreadcrumbComponent));
|
||||
expect(breadcrumb).not.toBeNull();
|
||||
|
||||
}));
|
||||
|
||||
it('should show the breadcrumb for the selected node when search results are displayed', fakeAsync(() => {
|
||||
typeToSearchBox();
|
||||
|
||||
setTimeout(() => {
|
||||
respondWithSearchResults(ONE_FOLDER_RESULT);
|
||||
fixture.whenStable().then(() => {
|
||||
fixture.detectChanges();
|
||||
tick(debounceSearch);
|
||||
|
||||
const chosenNode = <MinimalNodeEntryEntity> { path: { elements: ['one'] } };
|
||||
component.onNodeSelect({ detail: { node: { entry: chosenNode } } });
|
||||
fixture.detectChanges();
|
||||
fixture.detectChanges();
|
||||
|
||||
const breadcrumb = fixture.debugElement.query(By.directive(DropdownBreadcrumbComponent));
|
||||
expect(breadcrumb).not.toBeNull();
|
||||
expect(breadcrumb.componentInstance.folderNode.path).toBe(chosenNode.path);
|
||||
done();
|
||||
});
|
||||
}, 300);
|
||||
});
|
||||
respondWithSearchResults(ONE_FOLDER_RESULT);
|
||||
fixture.detectChanges();
|
||||
|
||||
tick(debounceSearch);
|
||||
|
||||
const chosenNode = <MinimalNodeEntryEntity> { path: { elements: ['one'] } };
|
||||
component.onNodeSelect({ detail: { node: { entry: chosenNode } } });
|
||||
fixture.detectChanges();
|
||||
|
||||
tick(debounceSearch);
|
||||
|
||||
const breadcrumb = fixture.debugElement.query(By.directive(DropdownBreadcrumbComponent));
|
||||
expect(breadcrumb).not.toBeNull();
|
||||
expect(breadcrumb.componentInstance.folderNode.path).toBe(chosenNode.path);
|
||||
}));
|
||||
|
||||
it('should NOT show the breadcrumb for the selected node when not on search results list', (done) => {
|
||||
typeToSearchBox();
|
||||
@@ -258,7 +274,11 @@ describe('ContentNodeSelectorComponent', () => {
|
||||
});
|
||||
|
||||
it('should make changes to breadcrumb\'s folderNode if breadcrumbTransform is defined', (done) => {
|
||||
const transformedFolderNode = <MinimalNodeEntryEntity> { id: 'trans-node', name: 'trans-node-name', path: { elements: [{id: 'testId', name: 'testName'}] } };
|
||||
const transformedFolderNode = <MinimalNodeEntryEntity> {
|
||||
id: 'trans-node',
|
||||
name: 'trans-node-name',
|
||||
path: { elements: [{ id: 'testId', name: 'testName' }] }
|
||||
};
|
||||
component.breadcrumbTransform = (() => {
|
||||
return transformedFolderNode;
|
||||
});
|
||||
@@ -277,13 +297,39 @@ describe('ContentNodeSelectorComponent', () => {
|
||||
});
|
||||
|
||||
describe('Search functionality', () => {
|
||||
let getCorrespondingNodeIdsSpy;
|
||||
let getCorrespondingNodeIdsSpy;
|
||||
|
||||
let defaultSearchOptions = (searchTerm, rootNodeId = undefined, skipCount = 0) => {
|
||||
|
||||
const parentFiltering = rootNodeId ? [{ query: `ANCESTOR:'workspace://SpacesStore/${rootNodeId}'` }] : [];
|
||||
|
||||
let defaultSearchNode: any = {
|
||||
query: {
|
||||
query: searchTerm ? `${searchTerm}* OR name:${searchTerm}*` : searchTerm
|
||||
},
|
||||
include: ['path', 'allowableOperations'],
|
||||
paging: {
|
||||
maxItems: 25,
|
||||
skipCount: skipCount
|
||||
},
|
||||
filterQueries: [
|
||||
{ query: "TYPE:'cm:folder'" },
|
||||
{ query: 'NOT cm:creator:System' },
|
||||
...parentFiltering
|
||||
],
|
||||
scope: {
|
||||
locations: ['nodes']
|
||||
}
|
||||
};
|
||||
|
||||
return defaultSearchNode;
|
||||
};
|
||||
|
||||
beforeEach(() => {
|
||||
const documentListService = TestBed.get(DocumentListService);
|
||||
const expectedDefaultFolderNode = <MinimalNodeEntryEntity> { path: { elements: [] } };
|
||||
|
||||
spyOn(documentListService, 'getFolderNode').and.returnValue(Promise.resolve(expectedDefaultFolderNode));
|
||||
spyOn(documentListService, 'getFolderNode').and.returnValue(Observable.of(expectedDefaultFolderNode));
|
||||
spyOn(component.documentList, 'loadFolderNodesByFolderNodeId').and.returnValue(Promise.resolve());
|
||||
|
||||
const sitesService = TestBed.get(SitesService);
|
||||
@@ -292,149 +338,128 @@ describe('ContentNodeSelectorComponent', () => {
|
||||
getCorrespondingNodeIdsSpy = spyOn(component.documentList, 'getCorrespondingNodeIds').and
|
||||
.callFake(id => {
|
||||
if (id === '-sites-') {
|
||||
return new Promise((resolve) => resolve(['123456testId', '09876543testId']));
|
||||
return Observable.of(['123456testId', '09876543testId']);
|
||||
}
|
||||
return new Promise((resolve) => resolve([id]));
|
||||
return Observable.of([id]);
|
||||
});
|
||||
|
||||
component.currentFolderId = 'cat-girl-nuku-nuku';
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should load the results on search change', (done) => {
|
||||
it('should load the results by calling the search api on search change', fakeAsync(() => {
|
||||
typeToSearchBox('kakarot');
|
||||
|
||||
setTimeout(() => {
|
||||
expect(searchSpy).toHaveBeenCalledWith('kakarot', undefined, 0, 25);
|
||||
done();
|
||||
}, 300);
|
||||
});
|
||||
tick(debounceSearch);
|
||||
fixture.detectChanges();
|
||||
|
||||
it('should reset the currently chosen node in case of starting a new search', (done) => {
|
||||
expect(searchSpy).toHaveBeenCalledWith(defaultSearchOptions('kakarot'));
|
||||
}));
|
||||
|
||||
it('should reset the currently chosen node in case of starting a new search', fakeAsync(() => {
|
||||
component.chosenNode = <MinimalNodeEntryEntity> {};
|
||||
typeToSearchBox('kakarot');
|
||||
|
||||
setTimeout(() => {
|
||||
expect(component.chosenNode).toBeNull();
|
||||
done();
|
||||
}, 300);
|
||||
});
|
||||
tick(debounceSearch);
|
||||
fixture.detectChanges();
|
||||
|
||||
it('should search on changing the site selectbox value', (done) => {
|
||||
expect(component.chosenNode).toBeNull();
|
||||
}));
|
||||
|
||||
it('should call the search api on changing the site selectbox\'s value', fakeAsync(() => {
|
||||
typeToSearchBox('vegeta');
|
||||
|
||||
setTimeout(() => {
|
||||
expect(searchSpy.calls.count()).toBe(1, 'Search count should be one after only one search');
|
||||
tick(debounceSearch);
|
||||
|
||||
component.siteChanged(<SiteEntry> { entry: { guid: 'namek' } });
|
||||
expect(searchSpy.calls.count()).toBe(1, 'Search count should be one after only one search');
|
||||
|
||||
fixture.whenStable().then(() => {
|
||||
expect(searchSpy.calls.count()).toBe(2, 'Search count should be two after the site change');
|
||||
expect(searchSpy.calls.argsFor(1)).toEqual([ 'vegeta', 'namek', 0, 25] );
|
||||
done();
|
||||
});
|
||||
}, 300);
|
||||
});
|
||||
component.siteChanged(<SiteEntry> { entry: { guid: 'namek' } });
|
||||
|
||||
it('should call the content node selector search with the right parameters on changing the site selectbox value', (done) => {
|
||||
expect(searchSpy.calls.count()).toBe(2, 'Search count should be two after the site change');
|
||||
expect(searchSpy.calls.argsFor(1)).toEqual([defaultSearchOptions('vegeta', 'namek')]);
|
||||
}));
|
||||
|
||||
it('should call the content node selector\'s search with the right parameters on changing the site selectbox\'s value', fakeAsync(() => {
|
||||
typeToSearchBox('vegeta');
|
||||
|
||||
setTimeout(() => {
|
||||
expect(searchSpy.calls.count()).toBe(1);
|
||||
tick(debounceSearch);
|
||||
expect(cnSearchSpy.calls.count()).toBe(1);
|
||||
|
||||
component.siteChanged(<SiteEntry> { entry: { guid: '-sites-' } });
|
||||
component.siteChanged(<SiteEntry> { entry: { guid: '-sites-' } });
|
||||
|
||||
fixture.whenStable().then(() => {
|
||||
expect(searchSpy).toHaveBeenCalled();
|
||||
expect(searchSpy.calls.count()).toBe(2);
|
||||
expect(searchSpy).toHaveBeenCalledWith('vegeta', '-sites-', 0, 25);
|
||||
done();
|
||||
});
|
||||
}, 300);
|
||||
});
|
||||
expect(cnSearchSpy).toHaveBeenCalled();
|
||||
expect(cnSearchSpy.calls.count()).toBe(2);
|
||||
expect(cnSearchSpy).toHaveBeenCalledWith('vegeta', '-sites-', 0, 25);
|
||||
}));
|
||||
|
||||
it('should call the content node selector search with the right parameters on changing the site selectbox value from a custom dropdown menu', (done) => {
|
||||
component.dropdownSiteList = <SitePaging> {list: {entries: [<SiteEntry> { entry: { guid: '-sites-' } }, <SiteEntry> { entry: { guid: 'namek' } }]}};
|
||||
it('should call the content node selector\'s search with the right parameters on changing the site selectbox\'s value from a custom dropdown menu', fakeAsync(() => {
|
||||
component.dropdownSiteList = <SitePaging> { list: { entries: [<SiteEntry> { entry: { guid: '-sites-' } }, <SiteEntry> { entry: { guid: 'namek' } }] } };
|
||||
fixture.detectChanges();
|
||||
|
||||
typeToSearchBox('vegeta');
|
||||
|
||||
setTimeout(() => {
|
||||
expect(searchSpy.calls.count()).toBe(1);
|
||||
tick(debounceSearch);
|
||||
|
||||
component.siteChanged(<SiteEntry> { entry: { guid: '-sites-' } });
|
||||
expect(cnSearchSpy.calls.count()).toBe(1);
|
||||
|
||||
fixture.whenStable().then(() => {
|
||||
expect(searchSpy).toHaveBeenCalled();
|
||||
expect(searchSpy.calls.count()).toBe(2);
|
||||
expect(searchSpy).toHaveBeenCalledWith('vegeta', '-sites-', 0, 25, ['123456testId', '09876543testId']);
|
||||
done();
|
||||
});
|
||||
}, 300);
|
||||
});
|
||||
component.siteChanged(<SiteEntry> { entry: { guid: '-sites-' } });
|
||||
|
||||
it('should get the corresponding node ids before the search call on changing the site selectbox value from a custom dropdown menu', (done) => {
|
||||
component.dropdownSiteList = <SitePaging> {list: {entries: [<SiteEntry> { entry: { guid: '-sites-' } }, <SiteEntry> { entry: { guid: 'namek' } }]}};
|
||||
expect(cnSearchSpy).toHaveBeenCalled();
|
||||
expect(cnSearchSpy.calls.count()).toBe(2);
|
||||
expect(cnSearchSpy).toHaveBeenCalledWith('vegeta', '-sites-', 0, 25, ['123456testId', '09876543testId']);
|
||||
}));
|
||||
|
||||
it('should get the corresponding node ids before the search call on changing the site selectbox\'s value from a custom dropdown menu', fakeAsync(() => {
|
||||
component.dropdownSiteList = <SitePaging> { list: { entries: [<SiteEntry> { entry: { guid: '-sites-' } }, <SiteEntry> { entry: { guid: 'namek' } }] } };
|
||||
fixture.detectChanges();
|
||||
|
||||
typeToSearchBox('vegeta');
|
||||
|
||||
setTimeout(() => {
|
||||
expect(getCorrespondingNodeIdsSpy.calls.count()).toBe(1, 'getCorrespondingNodeIdsSpy calls count should be one after only one search');
|
||||
tick(debounceSearch);
|
||||
|
||||
component.siteChanged(<SiteEntry> { entry: { guid: 'namek' } });
|
||||
expect(getCorrespondingNodeIdsSpy.calls.count()).toBe(1, 'getCorrespondingNodeIdsSpy calls count should be one after only one search');
|
||||
|
||||
fixture.whenStable().then(() => {
|
||||
expect(getCorrespondingNodeIdsSpy.calls.count()).toBe(2, 'getCorrespondingNodeIdsSpy calls count should be two after the site change');
|
||||
expect(getCorrespondingNodeIdsSpy.calls.allArgs()).toEqual([[undefined], ['namek']]);
|
||||
done();
|
||||
});
|
||||
}, 300);
|
||||
});
|
||||
component.siteChanged(<SiteEntry> { entry: { guid: 'namek' } });
|
||||
|
||||
it('should NOT get the corresponding node ids before the search call on changing the site selectbox\'s value from default dropdown menu', (done) => {
|
||||
expect(getCorrespondingNodeIdsSpy.calls.count()).toBe(2, 'getCorrespondingNodeIdsSpy calls count should be two after the site change');
|
||||
expect(getCorrespondingNodeIdsSpy.calls.allArgs()).toEqual([[undefined], ['namek']]);
|
||||
}));
|
||||
|
||||
it('should NOT get the corresponding node ids before the search call on changing the site selectbox\'s value from default dropdown menu', fakeAsync(() => {
|
||||
typeToSearchBox('vegeta');
|
||||
tick(debounceSearch);
|
||||
|
||||
setTimeout(() => {
|
||||
expect(getCorrespondingNodeIdsSpy.calls.count()).toBe(0, 'getCorrespondingNodeIdsSpy should not be called');
|
||||
expect(getCorrespondingNodeIdsSpy.calls.count()).toBe(0, 'getCorrespondingNodeIdsSpy should not be called');
|
||||
|
||||
component.siteChanged(<SiteEntry> { entry: { guid: 'namek' } });
|
||||
component.siteChanged(<SiteEntry> { entry: { guid: 'namek' } });
|
||||
|
||||
fixture.whenStable().then(() => {
|
||||
expect(getCorrespondingNodeIdsSpy).not.toHaveBeenCalled();
|
||||
done();
|
||||
});
|
||||
}, 300);
|
||||
});
|
||||
expect(getCorrespondingNodeIdsSpy).not.toHaveBeenCalled();
|
||||
}));
|
||||
|
||||
it('should show the search icon by default without the X (clear) icon', (done) => {
|
||||
it('should show the search icon by default without the X (clear) icon', fakeAsync(() => {
|
||||
fixture.detectChanges();
|
||||
setTimeout(() => {
|
||||
tick(debounceSearch);
|
||||
|
||||
let searchIcon = fixture.debugElement.query(By.css('[data-automation-id="content-node-selector-search-icon"]'));
|
||||
let clearIcon = fixture.debugElement.query(By.css('[data-automation-id="content-node-selector-search-clear"]'));
|
||||
let searchIcon = fixture.debugElement.query(By.css('[data-automation-id="content-node-selector-search-icon"]'));
|
||||
let clearIcon = fixture.debugElement.query(By.css('[data-automation-id="content-node-selector-search-clear"]'));
|
||||
|
||||
expect(searchIcon).not.toBeNull('Search icon should be in the DOM');
|
||||
expect(clearIcon).toBeNull('Clear icon should NOT be in the DOM');
|
||||
done();
|
||||
}, 300);
|
||||
});
|
||||
expect(searchIcon).not.toBeNull('Search icon should be in the DOM');
|
||||
expect(clearIcon).toBeNull('Clear icon should NOT be in the DOM');
|
||||
}));
|
||||
|
||||
it('should show the X (clear) icon without the search icon when the search contains at least one character', (done) => {
|
||||
it('should show the X (clear) icon without the search icon when the search contains at least one character', fakeAsync(() => {
|
||||
fixture.detectChanges();
|
||||
typeToSearchBox('123');
|
||||
tick(debounceSearch);
|
||||
|
||||
setTimeout(() => {
|
||||
fixture.detectChanges();
|
||||
fixture.detectChanges();
|
||||
|
||||
let searchIcon = fixture.debugElement.query(By.css('[data-automation-id="content-node-selector-search-icon"]'));
|
||||
let clearIcon = fixture.debugElement.query(By.css('[data-automation-id="content-node-selector-search-clear"]'));
|
||||
let searchIcon = fixture.debugElement.query(By.css('[data-automation-id="content-node-selector-search-icon"]'));
|
||||
let clearIcon = fixture.debugElement.query(By.css('[data-automation-id="content-node-selector-search-clear"]'));
|
||||
|
||||
expect(searchIcon).toBeNull('Search icon should NOT be in the DOM');
|
||||
expect(clearIcon).not.toBeNull('Clear icon should be in the DOM');
|
||||
done();
|
||||
}, 300);
|
||||
});
|
||||
expect(searchIcon).toBeNull('Search icon should NOT be in the DOM');
|
||||
expect(clearIcon).not.toBeNull('Clear icon should be in the DOM');
|
||||
}));
|
||||
|
||||
it('should clear the search field, nodes and chosenNode when clicking on the X (clear) icon', () => {
|
||||
component.chosenNode = <MinimalNodeEntryEntity> {};
|
||||
@@ -454,7 +479,7 @@ describe('ContentNodeSelectorComponent', () => {
|
||||
expect(component.showingSearchResults).toBeFalsy();
|
||||
});
|
||||
|
||||
it('should clear the search field, nodes and chosenNode when deleting the search input', fakeAsync(() => {
|
||||
it('should clear the search field, nodes and chosenNode when deleting the search input', fakeAsync(() => {
|
||||
spyOn(component, 'clear').and.callThrough();
|
||||
typeToSearchBox('a');
|
||||
|
||||
@@ -473,7 +498,7 @@ describe('ContentNodeSelectorComponent', () => {
|
||||
expect(component.folderIdToShow).toBe('cat-girl-nuku-nuku', 'back to the folder in which the search was performed');
|
||||
}));
|
||||
|
||||
it('should clear the search field, nodes and chosenNode on folder navigation in the results list', fakeAsync(() => {
|
||||
xit('should clear the search field, nodes and chosenNode on folder navigation in the results list', fakeAsync(() => {
|
||||
spyOn(component, 'clearSearch').and.callThrough();
|
||||
typeToSearchBox('a');
|
||||
|
||||
@@ -492,24 +517,21 @@ describe('ContentNodeSelectorComponent', () => {
|
||||
|
||||
}));
|
||||
|
||||
it('should show nodes from the same folder as selected in the dropdown on clearing the search input', (done) => {
|
||||
it('should show nodes from the same folder as selected in the dropdown on clearing the search input', fakeAsync(() => {
|
||||
typeToSearchBox('piccolo');
|
||||
tick(debounceSearch);
|
||||
|
||||
setTimeout(() => {
|
||||
expect(searchSpy.calls.count()).toBe(1);
|
||||
expect(searchSpy.calls.count()).toBe(1);
|
||||
|
||||
component.siteChanged(<SiteEntry> { entry: { guid: 'namek' } });
|
||||
component.siteChanged(<SiteEntry> { entry: { guid: 'namek' } });
|
||||
|
||||
expect(searchSpy.calls.count()).toBe(2);
|
||||
expect(searchSpy.calls.argsFor(1)).toEqual([ 'piccolo', 'namek', 0, 25 ]);
|
||||
expect(searchSpy.calls.count()).toBe(2);
|
||||
expect(searchSpy.calls.argsFor(1)).toEqual([defaultSearchOptions('piccolo', 'namek')]);
|
||||
|
||||
component.clear();
|
||||
|
||||
expect(component.searchTerm).toBe('');
|
||||
expect(component.folderIdToShow).toBe('namek');
|
||||
done();
|
||||
}, 300);
|
||||
component.clear();
|
||||
|
||||
expect(component.searchTerm).toBe('');
|
||||
expect(component.folderIdToShow).toBe('namek');
|
||||
});
|
||||
|
||||
it('should show the current folder\'s content instead of search results if search was not performed', () => {
|
||||
@@ -541,7 +563,7 @@ describe('ContentNodeSelectorComponent', () => {
|
||||
expect(documentList.componentInstance.imageResolver).toBe(resolver);
|
||||
});
|
||||
|
||||
it('should show the result list when search was performed', (done) => {
|
||||
xit('should show the result list when search was performed', (done) => {
|
||||
typeToSearchBox();
|
||||
|
||||
setTimeout(() => {
|
||||
@@ -555,26 +577,23 @@ describe('ContentNodeSelectorComponent', () => {
|
||||
}, 300);
|
||||
});
|
||||
|
||||
xit('should highlight the results when search was performed in the next timeframe', (done) => {
|
||||
xit('should highlight the results when search was performed in the next timeframe', fakeAsync(() => {
|
||||
spyOn(component.highlighter, 'highlight');
|
||||
typeToSearchBox('shenron');
|
||||
|
||||
setTimeout(() => {
|
||||
respondWithSearchResults(ONE_FOLDER_RESULT);
|
||||
fixture.detectChanges();
|
||||
tick(debounceSearch);
|
||||
|
||||
expect(component.highlighter.highlight).not.toHaveBeenCalled();
|
||||
respondWithSearchResults(ONE_FOLDER_RESULT);
|
||||
fixture.detectChanges();
|
||||
|
||||
setTimeout(() => {
|
||||
expect(component.highlighter.highlight).toHaveBeenCalledWith('shenron');
|
||||
}, 300);
|
||||
tick(debounceSearch);
|
||||
|
||||
done();
|
||||
}, 300);
|
||||
expect(component.highlighter.highlight).not.toHaveBeenCalled();
|
||||
|
||||
});
|
||||
expect(component.highlighter.highlight).toHaveBeenCalledWith('shenron');
|
||||
}));
|
||||
|
||||
it('should show the default text instead of result list if search was cleared', (done) => {
|
||||
xit('should show the default text instead of result list if search was cleared', (done) => {
|
||||
typeToSearchBox();
|
||||
|
||||
setTimeout(() => {
|
||||
@@ -595,25 +614,24 @@ describe('ContentNodeSelectorComponent', () => {
|
||||
}, 300);
|
||||
});
|
||||
|
||||
xit('should reload the original documentlist when clearing the search input', (done) => {
|
||||
xit('should reload the original documentlist when clearing the search input', fakeAsync(() => {
|
||||
typeToSearchBox('shenron');
|
||||
|
||||
setTimeout(() => {
|
||||
respondWithSearchResults(ONE_FOLDER_RESULT);
|
||||
tick(debounceSearch);
|
||||
|
||||
typeToSearchBox('');
|
||||
fixture.detectChanges();
|
||||
respondWithSearchResults(ONE_FOLDER_RESULT);
|
||||
|
||||
setTimeout(() => {
|
||||
let documentList = fixture.debugElement.query(By.css('[data-automation-id="content-node-selector-document-list"]'));
|
||||
expect(documentList.componentInstance.currentFolderId).toBe('cat-girl-nuku-nuku');
|
||||
}, 300);
|
||||
typeToSearchBox('');
|
||||
|
||||
done();
|
||||
}, 300);
|
||||
});
|
||||
tick(debounceSearch);
|
||||
|
||||
it('should set the folderIdToShow to the default "currentFolderId" if siteId is undefined', (done) => {
|
||||
fixture.detectChanges();
|
||||
|
||||
let documentList = fixture.debugElement.query(By.css('[data-automation-id="content-node-selector-document-list"]'));
|
||||
expect(documentList.componentInstance.currentFolderId).toBe('cat-girl-nuku-nuku');
|
||||
}));
|
||||
|
||||
xit('should set the folderIdToShow to the default "currentFolderId" if siteId is undefined', (done) => {
|
||||
component.siteChanged(<SiteEntry> { entry: { guid: 'Kame-Sennin Muten Roshi' } });
|
||||
fixture.detectChanges();
|
||||
|
||||
@@ -637,29 +655,26 @@ describe('ContentNodeSelectorComponent', () => {
|
||||
expect(pagination).toBeNull();
|
||||
});
|
||||
|
||||
it('should be shown when diplaying search results', (done) => {
|
||||
xit('should be shown when diplaying search results', fakeAsync(() => {
|
||||
typeToSearchBox('shenron');
|
||||
|
||||
setTimeout(() => {
|
||||
respondWithSearchResults(ONE_FOLDER_RESULT);
|
||||
tick(debounceSearch);
|
||||
|
||||
fixture.whenStable().then(() => {
|
||||
fixture.detectChanges();
|
||||
const pagination = fixture.debugElement.query(By.css('[data-automation-id="content-node-selector-search-pagination"]'));
|
||||
expect(pagination).not.toBeNull();
|
||||
done();
|
||||
});
|
||||
}, 300);
|
||||
});
|
||||
respondWithSearchResults(ONE_FOLDER_RESULT);
|
||||
|
||||
it('button callback should load the next batch of results by calling the search api', async(() => {
|
||||
fixture.detectChanges();
|
||||
const pagination = fixture.debugElement.query(By.css('[data-automation-id="content-node-selector-search-pagination"]'));
|
||||
expect(pagination).not.toBeNull();
|
||||
}));
|
||||
|
||||
xit('button callback should load the next batch of results by calling the search api', async(() => {
|
||||
const skipCount = 8;
|
||||
component.searchTerm = 'kakarot';
|
||||
|
||||
component.getNextPageOfSearch({ skipCount });
|
||||
|
||||
fixture.whenStable().then(() => {
|
||||
expect(searchSpy).toHaveBeenCalledWith( 'kakarot', undefined, skipCount, 25);
|
||||
expect(searchSpy).toHaveBeenCalledWith('kakarot', undefined, skipCount, 25);
|
||||
});
|
||||
}));
|
||||
|
||||
@@ -682,7 +697,7 @@ describe('ContentNodeSelectorComponent', () => {
|
||||
};
|
||||
fixture.detectChanges();
|
||||
|
||||
component.getNextPageOfSearch({skipCount});
|
||||
component.getNextPageOfSearch({ skipCount });
|
||||
fixture.detectChanges();
|
||||
expect(component.searchTerm).toBe('');
|
||||
|
||||
@@ -691,48 +706,45 @@ describe('ContentNodeSelectorComponent', () => {
|
||||
expect(searchSpy).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should set its loading state to true after search was started', (done) => {
|
||||
it('should set its loading state to true after search was started', fakeAsync(() => {
|
||||
component.showingSearchResults = true;
|
||||
component.pagination = { hasMoreItems: true };
|
||||
|
||||
typeToSearchBox('shenron');
|
||||
|
||||
setTimeout(() => {
|
||||
fixture.detectChanges();
|
||||
tick(debounceSearch);
|
||||
|
||||
const spinnerSelector = By.css('[data-automation-id="content-node-selector-search-pagination"] [data-automation-id="adf-infinite-pagination-spinner"]');
|
||||
const paginationLoading = fixture.debugElement.query(spinnerSelector);
|
||||
expect(paginationLoading).not.toBeNull();
|
||||
done();
|
||||
}, 300);
|
||||
});
|
||||
|
||||
it('should set its loading state to true after search was performed', (done) => {
|
||||
component.showingSearchResults = true;
|
||||
component.pagination = { hasMoreItems: true };
|
||||
|
||||
typeToSearchBox('shenron');
|
||||
fixture.detectChanges();
|
||||
|
||||
setTimeout(() => {
|
||||
respondWithSearchResults(ONE_FOLDER_RESULT);
|
||||
const spinnerSelector = By.css('[data-automation-id="content-node-selector-search-pagination"] [data-automation-id="adf-infinite-pagination-spinner"]');
|
||||
const paginationLoading = fixture.debugElement.query(spinnerSelector);
|
||||
expect(paginationLoading).not.toBeNull();
|
||||
}));
|
||||
|
||||
fixture.whenStable().then(() => {
|
||||
fixture.detectChanges();
|
||||
const spinnerSelector = By.css('[data-automation-id="content-node-selector-search-pagination"] [data-automation-id="adf-infinite-pagination-spinner"]');
|
||||
const paginationLoading = fixture.debugElement.query(spinnerSelector);
|
||||
expect(paginationLoading).toBeNull();
|
||||
done();
|
||||
});
|
||||
}, 300);
|
||||
});
|
||||
xit('should set its loading state to true after search was performed', fakeAsync(() => {
|
||||
component.showingSearchResults = true;
|
||||
component.pagination = { hasMoreItems: true };
|
||||
|
||||
typeToSearchBox('shenron');
|
||||
|
||||
tick(debounceSearch);
|
||||
|
||||
fixture.detectChanges();
|
||||
|
||||
respondWithSearchResults(ONE_FOLDER_RESULT);
|
||||
|
||||
fixture.detectChanges();
|
||||
const spinnerSelector = By.css('[data-automation-id="content-node-selector-search-pagination"] [data-automation-id="adf-infinite-pagination-spinner"]');
|
||||
const paginationLoading = fixture.debugElement.query(spinnerSelector);
|
||||
expect(paginationLoading).toBeNull();
|
||||
}));
|
||||
});
|
||||
});
|
||||
|
||||
describe('Chosen node', () => {
|
||||
|
||||
const entry: MinimalNodeEntryEntity = <MinimalNodeEntryEntity> {};
|
||||
const nodePage: NodePaging = <NodePaging> {list: {}, pagination: {}};
|
||||
const nodePage: NodePaging = <NodePaging> { list: {}, pagination: {} };
|
||||
let hasPermission;
|
||||
|
||||
function returnHasPermission(): boolean {
|
||||
|
Reference in New Issue
Block a user