[ADF-3854] destination picker - exclude site content after rowFilter reset (#4158)

* [ADF-3854] exclude set site content after rowFilter reset

* [ADF-3854] fix duplicated call

* [ADF-3854] add test

* fix unrelated failing test

* improve type definition
add set get filtering node selector

* remove comma

* [ADF-3854] demo-shell - case when rowFilter is not set for adf-content-node-selector-panel
This commit is contained in:
Suzana Dirla
2019-02-04 14:10:52 +02:00
committed by Eugenio Romano
parent cf922dd46e
commit 08cdb2f7c3
5 changed files with 120 additions and 18 deletions

View File

@@ -29,6 +29,7 @@ import { ContentTestingModule } from '../testing/content.testing.module';
import { DocumentListService } from '../document-list/services/document-list.service';
import { DocumentListComponent } from '../document-list/components/document-list.component';
import { CustomResourcesService } from '../document-list/services/custom-resources.service';
import { ShareDataRow } from '../document-list';
const ONE_FOLDER_RESULT = {
list: {
@@ -97,6 +98,24 @@ describe('ContentNodeSelectorComponent', () => {
describe('Parameters', () => {
let documentListService,
sitesService;
beforeEach(() => {
documentListService = TestBed.get(DocumentListService);
sitesService = TestBed.get(SitesService);
spyOn(documentListService, 'getFolderNode').and.returnValue(of(<NodeEntry> { entry: { path: { elements: [] } } }));
spyOn(documentListService, 'getFolder').and.returnValue(throwError('No results for test'));
spyOn(sitesService, 'getSites').and.returnValue(of({
list: {
entries: [<SiteEntry> { entry: { guid: 'namek', id: 'namek' } },
<SiteEntry> { entry: { guid: 'blog', id: 'blog' } }]
}
}));
component.currentFolderId = 'cat-girl-nuku-nuku';
fixture.detectChanges();
});
it('should trigger the select event when selection has been made', (done) => {
const expectedNode = <Node> {};
component.select.subscribe((nodes) => {
@@ -113,7 +132,35 @@ describe('ContentNodeSelectorComponent', () => {
fixture.detectChanges();
const testSiteContent = new Node({ id: 'blog-id', properties: { 'st:componentId': 'blog' } });
expect(component.rowFilter(<any> { node: { entry: testSiteContent } }, null, null)).toBe(false);
expect(component.rowFilter(<any> { node: { entry: testSiteContent } }, null, null))
.toBe(false, 'did not filter out blog');
});
it('should still be able to filter out the exclude site content after rowFilter changes', () => {
const filterFunction1 = () => {
return true;
};
const filterFunction2 = (row: ShareDataRow) => {
const node: Node = row.node.entry;
return node.isFile;
};
component.excludeSiteContent = ['blog'];
component.rowFilter = filterFunction1;
fixture.detectChanges();
const testSiteContent = new Node({
id: 'blog-id',
properties: { 'st:componentId': 'blog' },
isFile: true
});
expect(component.rowFilter(<any> { node: { entry: testSiteContent } }, null, null))
.toBe(false, 'did not filter out blog with filterFunction1');
component.rowFilter = filterFunction2;
fixture.detectChanges();
expect(component.rowFilter(<any> { node: { entry: testSiteContent } }, null, null))
.toBe(false, 'did not filter out blog with filterFunction2');
});
it('should NOT filter out any site content by default', () => {
@@ -548,15 +595,48 @@ describe('ContentNodeSelectorComponent', () => {
});
it('should pass through the rowFilter to the documentList', () => {
const filter = () => {
let filter = (shareDataRow: ShareDataRow) => {
if (shareDataRow.node.entry.name === 'impossible-name') {
return true;
}
};
component.rowFilter = filter;
fixture.detectChanges();
let documentList = fixture.debugElement.query(By.directive(DocumentListComponent));
expect(documentList).not.toBeNull('Document list should be shown');
expect(documentList.componentInstance.rowFilter).toBe(filter);
expect(documentList.componentInstance.rowFilter({
node: {
entry: new Node({
name: 'impossible-name',
id: 'name'
})
}
}))
.toBe(filter(<ShareDataRow> {
node: {
entry: new Node({
name: 'impossible-name',
id: 'name'
})
}
}));
});
it('should pass through the excludeSiteContent to the rowFilter of the documentList', () => {
component.excludeSiteContent = ['blog'];
fixture.detectChanges();
let documentList = fixture.debugElement.query(By.directive(DocumentListComponent));
expect(documentList).not.toBeNull('Document list should be shown');
expect(documentList.componentInstance.rowFilter).toBeTruthy('Document list should have had a rowFilter');
const testSiteContent = new Node({ id: 'blog-id', properties: { 'st:componentId': 'blog' } });
expect(documentList.componentInstance.rowFilter(<any> { node: { entry: testSiteContent } }, null, null))
.toBe(false);
});
it('should pass through the imageResolver to the documentList', () => {