mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-31 17:38:48 +00:00
[ACS-5839] migrate to latest JS-API types (#8859)
* [ci:force] migrate Minimal Node to Node * [ci:force] remove js-api wrappers and use real types * [ci:force] remove js-api wrappers and use real types * [ci:force] fix linting errors * [ci:force] fix linting errors * [ci:force] security fixes * [ci:force] sonarcloud bug fixes * [ci:force] dead code elimination, sonar suggested fixes
This commit is contained in:
@@ -18,16 +18,7 @@
|
||||
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
|
||||
import { ComponentFixture, fakeAsync, flush, TestBed, tick } from '@angular/core/testing';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import {
|
||||
MinimalNode,
|
||||
Node,
|
||||
NodeEntry,
|
||||
NodePaging,
|
||||
RequestScope,
|
||||
ResultSetPaging,
|
||||
SiteEntry,
|
||||
SitePaging
|
||||
} from '@alfresco/js-api';
|
||||
import { Node, NodeEntry, NodePaging, RequestScope, ResultSetPaging, SiteEntry, SitePaging } from '@alfresco/js-api';
|
||||
import { of } from 'rxjs';
|
||||
import { ContentNodeSelectorPanelComponent } from './content-node-selector-panel.component';
|
||||
import { ContentTestingModule } from '../testing/content.testing.module';
|
||||
@@ -83,17 +74,13 @@ describe('ContentNodeSelectorPanelComponent', () => {
|
||||
};
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [
|
||||
TranslateModule.forRoot(),
|
||||
ContentTestingModule
|
||||
],
|
||||
schemas: [CUSTOM_ELEMENTS_SCHEMA]
|
||||
});
|
||||
TestBed.configureTestingModule({
|
||||
imports: [TranslateModule.forRoot(), ContentTestingModule],
|
||||
schemas: [CUSTOM_ELEMENTS_SCHEMA]
|
||||
});
|
||||
});
|
||||
|
||||
describe('General component features', () => {
|
||||
|
||||
beforeEach(async () => {
|
||||
fixture = TestBed.createComponent(ContentNodeSelectorPanelComponent);
|
||||
component = fixture.componentInstance;
|
||||
@@ -105,10 +92,14 @@ describe('ContentNodeSelectorPanelComponent', () => {
|
||||
searchQueryBuilderService = component.queryBuilderService;
|
||||
component.queryBuilderService.resetToDefaults();
|
||||
|
||||
spyOn(nodeService, 'getNode').and.returnValue(of(new MinimalNode({
|
||||
id: 'fake-node',
|
||||
path: { elements: [{ nodeType: 'st:site', name: 'fake-site' }] }
|
||||
})));
|
||||
spyOn(nodeService, 'getNode').and.returnValue(
|
||||
of(
|
||||
new Node({
|
||||
id: 'fake-node',
|
||||
path: { elements: [{ nodeType: 'st:site', name: 'fake-site' }] }
|
||||
})
|
||||
)
|
||||
);
|
||||
searchSpy = spyOn(searchQueryBuilderService, 'execute');
|
||||
const fakeSite = new SiteEntry({
|
||||
entry: {
|
||||
@@ -127,7 +118,7 @@ describe('ContentNodeSelectorPanelComponent', () => {
|
||||
});
|
||||
|
||||
describe('Search functionality', () => {
|
||||
let getCorrespondingNodeIdsSpy;
|
||||
let getCorrespondingNodeIdsSpy: jasmine.Spy;
|
||||
let customResourcesService: CustomResourcesService;
|
||||
const entry: Node = { id: 'fakeid' } as Node;
|
||||
|
||||
@@ -137,24 +128,27 @@ describe('ContentNodeSelectorPanelComponent', () => {
|
||||
component.isSelectionValid = (node: Node) => node.isFile;
|
||||
|
||||
spyOn(documentListService, 'getFolderNode').and.returnValue(of(expectedDefaultFolderNode));
|
||||
spyOn(documentListService, 'getFolder').and.returnValue(of(new NodePaging({
|
||||
list: {
|
||||
pagination: {},
|
||||
entries: [],
|
||||
source: {}
|
||||
}
|
||||
})));
|
||||
spyOn(documentListService, 'getFolder').and.returnValue(
|
||||
of(
|
||||
new NodePaging({
|
||||
list: {
|
||||
pagination: {},
|
||||
entries: [],
|
||||
source: {}
|
||||
}
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
spyOn(sitesService, 'getSites').and.returnValue(of(new SitePaging({ list: { entries: [] } })));
|
||||
|
||||
customResourcesService = TestBed.inject(CustomResourcesService);
|
||||
getCorrespondingNodeIdsSpy = spyOn(customResourcesService, 'getCorrespondingNodeIds').and
|
||||
.callFake((id) => {
|
||||
if (id === '-sites-') {
|
||||
return of(['123456testId', '09876543testId']);
|
||||
}
|
||||
return of([id]);
|
||||
});
|
||||
getCorrespondingNodeIdsSpy = spyOn(customResourcesService, 'getCorrespondingNodeIds').and.callFake((id) => {
|
||||
if (id === '-sites-') {
|
||||
return of(['123456testId', '09876543testId']);
|
||||
}
|
||||
return of([id]);
|
||||
});
|
||||
|
||||
component.currentFolderId = 'cat-girl-nuku-nuku';
|
||||
component.documentList.ngOnInit();
|
||||
@@ -259,14 +253,14 @@ describe('ContentNodeSelectorPanelComponent', () => {
|
||||
|
||||
tick(debounceSearch);
|
||||
|
||||
expect(searchSpy.calls.count()).toBe(1, 'Search count should be one after only one search');
|
||||
expect(searchSpy.calls.count()).toBe(1);
|
||||
|
||||
component.siteChanged({ entry: { guid: 'namek' } } as SiteEntry);
|
||||
|
||||
const expectedQueryBody = mockQueryBody;
|
||||
expectedQueryBody.filterQueries = [{ query: `ANCESTOR:'workspace://SpacesStore/namek'` }];
|
||||
|
||||
expect(searchSpy.calls.count()).toBe(2, 'Search count should be two after the site change');
|
||||
expect(searchSpy.calls.count()).toBe(2);
|
||||
expect(searchSpy).toHaveBeenCalledWith(expectedQueryBody);
|
||||
}));
|
||||
|
||||
@@ -285,7 +279,9 @@ describe('ContentNodeSelectorPanelComponent', () => {
|
||||
|
||||
const expectedQueryBodyWithSiteChange = mockQueryBody;
|
||||
expectedQueryBodyWithSiteChange.filterQueries = [
|
||||
{ query: `ANCESTOR:'workspace://SpacesStore/-sites-' OR ANCESTOR:'workspace://SpacesStore/123456testId' OR ANCESTOR:'workspace://SpacesStore/09876543testId'` }
|
||||
{
|
||||
query: `ANCESTOR:'workspace://SpacesStore/-sites-' OR ANCESTOR:'workspace://SpacesStore/123456testId' OR ANCESTOR:'workspace://SpacesStore/09876543testId'`
|
||||
}
|
||||
];
|
||||
|
||||
expect(searchSpy).toHaveBeenCalled();
|
||||
@@ -302,7 +298,7 @@ describe('ContentNodeSelectorPanelComponent', () => {
|
||||
tick(debounceSearch);
|
||||
|
||||
component.siteChanged({ entry: { guid: '-sites-' } } as SiteEntry);
|
||||
expect(getCorrespondingNodeIdsSpy.calls.count()).toBe(1, 'getCorrespondingNodeIdsSpy calls count should be one after the site changes to known alias \'-sites\-');
|
||||
expect(getCorrespondingNodeIdsSpy.calls.count()).toBe(1);
|
||||
expect(getCorrespondingNodeIdsSpy.calls.mostRecent().args[0]).toEqual('-sites-');
|
||||
}));
|
||||
|
||||
@@ -329,7 +325,7 @@ describe('ContentNodeSelectorPanelComponent', () => {
|
||||
|
||||
tick(debounceSearch);
|
||||
|
||||
expect(getCorrespondingNodeIdsSpy.calls.count()).toBe(0, 'getCorrespondingNodeIdsSpy calls count should be 0 when no site is selected');
|
||||
expect(getCorrespondingNodeIdsSpy.calls.count()).toBe(0);
|
||||
}));
|
||||
|
||||
it('should NOT get the corresponding node ids on search when NO known alias is selected from dropdown', fakeAsync(() => {
|
||||
@@ -350,7 +346,7 @@ describe('ContentNodeSelectorPanelComponent', () => {
|
||||
typeToSearchBox('vegeta');
|
||||
tick(debounceSearch);
|
||||
|
||||
expect(getCorrespondingNodeIdsSpy.calls.count()).toBe(0, 'getCorrespondingNodeIdsSpy should not be called');
|
||||
expect(getCorrespondingNodeIdsSpy.calls.count()).toBe(0);
|
||||
|
||||
component.siteChanged({ entry: { guid: 'namek' } } as SiteEntry);
|
||||
|
||||
@@ -364,8 +360,8 @@ describe('ContentNodeSelectorPanelComponent', () => {
|
||||
const searchIcon = fixture.debugElement.query(By.css('[data-automation-id="content-node-selector-search-icon"]'));
|
||||
const 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');
|
||||
expect(searchIcon).not.toBeNull();
|
||||
expect(clearIcon).toBeNull();
|
||||
}));
|
||||
|
||||
it('should show the X (clear) icon without the search icon when the search contains at least one character', fakeAsync(() => {
|
||||
@@ -378,8 +374,8 @@ describe('ContentNodeSelectorPanelComponent', () => {
|
||||
const searchIcon = fixture.debugElement.query(By.css('[data-automation-id="content-node-selector-search-icon"]'));
|
||||
const 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');
|
||||
expect(searchIcon).toBeNull();
|
||||
expect(clearIcon).not.toBeNull();
|
||||
}));
|
||||
|
||||
it('should clear the search field, nodes and chosenNode when clicking on the X (clear) icon', async () => {
|
||||
@@ -420,7 +416,7 @@ describe('ContentNodeSelectorPanelComponent', () => {
|
||||
spyOn(customResourcesService, 'hasCorrespondingNodeIds').and.returnValue(true);
|
||||
const showingSearchSpy = spyOn(component.showingSearch, 'emit');
|
||||
|
||||
component.queryBuilderService.execute({ query: { query: 'search' } });
|
||||
await component.queryBuilderService.execute({ query: { query: 'search' } });
|
||||
|
||||
triggerSearchResults(fakeResultSetPaging);
|
||||
fixture.detectChanges();
|
||||
@@ -464,7 +460,7 @@ describe('ContentNodeSelectorPanelComponent', () => {
|
||||
searchQueryBuilderService.update();
|
||||
getCorrespondingNodeIdsSpy.and.throwError('Failed');
|
||||
const showingSearchSpy = spyOn(component.showingSearch, 'emit');
|
||||
component.queryBuilderService.execute({ query: { query: 'search' } });
|
||||
await component.queryBuilderService.execute({ query: { query: 'search' } });
|
||||
|
||||
triggerSearchResults(fakeResultSetPaging);
|
||||
fixture.detectChanges();
|
||||
@@ -481,9 +477,7 @@ describe('ContentNodeSelectorPanelComponent', () => {
|
||||
component.siteChanged({ entry: { guid: 'my-site-id' } } as SiteEntry);
|
||||
|
||||
const expectedQueryBodyWithSiteChange = mockQueryBody;
|
||||
expectedQueryBodyWithSiteChange.filterQueries = [
|
||||
{ query: `ANCESTOR:'workspace://SpacesStore/my-site-id'` }
|
||||
];
|
||||
expectedQueryBodyWithSiteChange.filterQueries = [{ query: `ANCESTOR:'workspace://SpacesStore/my-site-id'` }];
|
||||
|
||||
expect(searchSpy).toHaveBeenCalledWith(expectedQueryBodyWithSiteChange);
|
||||
});
|
||||
@@ -516,9 +510,9 @@ describe('ContentNodeSelectorPanelComponent', () => {
|
||||
tick(debounceSearch);
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(searchSpy.calls.count()).toBe(1, 'no other search has been performed');
|
||||
expect(searchSpy.calls.count()).toBe(1);
|
||||
expect(component.clearSearch).toHaveBeenCalled();
|
||||
expect(component.folderIdToShow).toBe('cat-girl-nuku-nuku', 'back to the folder in which the search was performed');
|
||||
expect(component.folderIdToShow).toBe('cat-girl-nuku-nuku');
|
||||
flush();
|
||||
}));
|
||||
|
||||
@@ -558,38 +552,40 @@ describe('ContentNodeSelectorPanelComponent', () => {
|
||||
expect(component.folderIdToShow).toBe('namek');
|
||||
}));
|
||||
|
||||
it('should show the current folder\'s content instead of search results if search was not performed', async () => {
|
||||
it('should show the current folder content instead of search results if search was not performed', async () => {
|
||||
const documentList = fixture.debugElement.query(By.directive(DocumentListComponent));
|
||||
expect(documentList).not.toBeNull('Document list should be shown');
|
||||
expect(documentList).not.toBeNull();
|
||||
expect(documentList.componentInstance.currentFolderId).toBe('cat-girl-nuku-nuku');
|
||||
});
|
||||
|
||||
it('should pass through the rowFilter to the documentList', async () => {
|
||||
const filter = (shareDataRow: ShareDataRow) =>
|
||||
shareDataRow.node.entry.name === 'impossible-name';
|
||||
const filter = (shareDataRow: ShareDataRow) => shareDataRow.node.entry.name === 'impossible-name';
|
||||
|
||||
component.rowFilter = filter;
|
||||
|
||||
fixture.detectChanges();
|
||||
|
||||
const documentList = fixture.debugElement.query(By.directive(DocumentListComponent));
|
||||
expect(documentList).not.toBeNull('Document list should be shown');
|
||||
expect(documentList.componentInstance.rowFilter({
|
||||
node: {
|
||||
entry: new Node({
|
||||
name: 'impossible-name',
|
||||
id: 'name'
|
||||
})
|
||||
}
|
||||
}))
|
||||
.toBe(filter({
|
||||
expect(documentList).not.toBeNull();
|
||||
expect(
|
||||
documentList.componentInstance.rowFilter({
|
||||
node: {
|
||||
entry: new Node({
|
||||
name: 'impossible-name',
|
||||
id: 'name'
|
||||
})
|
||||
}
|
||||
} as ShareDataRow));
|
||||
})
|
||||
).toBe(
|
||||
filter({
|
||||
node: {
|
||||
entry: new Node({
|
||||
name: 'impossible-name',
|
||||
id: 'name'
|
||||
})
|
||||
}
|
||||
} as ShareDataRow)
|
||||
);
|
||||
});
|
||||
|
||||
it('should pass through the excludeSiteContent to the rowFilter of the documentList', async () => {
|
||||
@@ -598,12 +594,11 @@ describe('ContentNodeSelectorPanelComponent', () => {
|
||||
fixture.detectChanges();
|
||||
|
||||
const 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');
|
||||
expect(documentList).not.toBeNull();
|
||||
expect(documentList.componentInstance.rowFilter).toBeTruthy();
|
||||
|
||||
const testSiteContent = new Node({ id: 'blog-id', properties: { 'st:componentId': 'blog' } });
|
||||
expect(documentList.componentInstance.rowFilter({ node: { entry: testSiteContent } }, null, null))
|
||||
.toBe(false);
|
||||
expect(documentList.componentInstance.rowFilter({ node: { entry: testSiteContent } }, null, null)).toBe(false);
|
||||
});
|
||||
|
||||
it('should pass through the imageResolver to the documentList', async () => {
|
||||
@@ -613,7 +608,7 @@ describe('ContentNodeSelectorPanelComponent', () => {
|
||||
fixture.detectChanges();
|
||||
|
||||
const documentList = fixture.debugElement.query(By.directive(DocumentListComponent));
|
||||
expect(documentList).not.toBeNull('Document list should be shown');
|
||||
expect(documentList).not.toBeNull();
|
||||
expect(documentList.componentInstance.imageResolver).toBe(resolver);
|
||||
});
|
||||
|
||||
@@ -625,7 +620,7 @@ describe('ContentNodeSelectorPanelComponent', () => {
|
||||
|
||||
fixture.detectChanges();
|
||||
const documentList = fixture.debugElement.query(By.css('[data-automation-id="content-node-selector-document-list"]'));
|
||||
expect(documentList).not.toBeNull('Document list should be shown');
|
||||
expect(documentList).not.toBeNull();
|
||||
expect(component.hasValidQuery).toEqual(true);
|
||||
expect(documentList.componentInstance.currentFolderId).toBeNull();
|
||||
done();
|
||||
@@ -670,12 +665,12 @@ describe('ContentNodeSelectorPanelComponent', () => {
|
||||
|
||||
fixture.whenStable().then(() => {
|
||||
const clearButton = fixture.debugElement.query(By.css('[data-automation-id="content-node-selector-search-clear"]'));
|
||||
expect(clearButton).not.toBeNull('Clear button should be in DOM');
|
||||
expect(clearButton).not.toBeNull();
|
||||
clearButton.triggerEventHandler('click', {});
|
||||
fixture.detectChanges();
|
||||
|
||||
const documentList = fixture.debugElement.query(By.css('[data-automation-id="content-node-selector-document-list"]'));
|
||||
expect(documentList).not.toBeNull('Document list should be shown');
|
||||
expect(documentList).not.toBeNull();
|
||||
expect(documentList.componentInstance.currentFolderId).toBe('cat-girl-nuku-nuku');
|
||||
done();
|
||||
});
|
||||
@@ -714,7 +709,6 @@ describe('ContentNodeSelectorPanelComponent', () => {
|
||||
});
|
||||
|
||||
describe('Pagination "Load more" button', () => {
|
||||
|
||||
it('should NOT be shown by default', () => {
|
||||
fixture.detectChanges();
|
||||
const pagination = fixture.debugElement.query(By.css('[data-automation-id="adf-infinite-pagination-button"]'));
|
||||
@@ -745,7 +739,9 @@ describe('ContentNodeSelectorPanelComponent', () => {
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
const spinnerSelector = By.css('[data-automation-id="content-node-selector-search-pagination"] [data-automation-id="adf-infinite-pagination-spinner"]');
|
||||
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();
|
||||
@@ -782,6 +778,5 @@ describe('ContentNodeSelectorPanelComponent', () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
|
@@ -18,22 +18,8 @@
|
||||
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
|
||||
import { ComponentFixture, fakeAsync, TestBed, tick } from '@angular/core/testing';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import {
|
||||
MinimalNode,
|
||||
Node,
|
||||
NodeEntry,
|
||||
NodePaging,
|
||||
ResultSetPaging,
|
||||
SiteEntry,
|
||||
SitePaging,
|
||||
UserInfo
|
||||
} from '@alfresco/js-api';
|
||||
import {
|
||||
AppConfigService,
|
||||
DataRow,
|
||||
ThumbnailService,
|
||||
DataColumn
|
||||
} from '@alfresco/adf-core';
|
||||
import { Node, NodeEntry, NodePaging, ResultSetPaging, SiteEntry, SitePaging, UserInfo } from '@alfresco/js-api';
|
||||
import { AppConfigService, DataRow, ThumbnailService, DataColumn } from '@alfresco/adf-core';
|
||||
import { ContentService } from '../common/services/content.service';
|
||||
import { UploadService } from '../common/services/upload.service';
|
||||
import { NodesApiService } from '../common/services/nodes-api.service';
|
||||
@@ -90,17 +76,13 @@ describe('ContentNodeSelectorPanelComponent', () => {
|
||||
};
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [
|
||||
TranslateModule.forRoot(),
|
||||
ContentTestingModule
|
||||
],
|
||||
schemas: [CUSTOM_ELEMENTS_SCHEMA]
|
||||
});
|
||||
TestBed.configureTestingModule({
|
||||
imports: [TranslateModule.forRoot(), ContentTestingModule],
|
||||
schemas: [CUSTOM_ELEMENTS_SCHEMA]
|
||||
});
|
||||
});
|
||||
|
||||
describe('General component features', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(ContentNodeSelectorPanelComponent);
|
||||
component = fixture.componentInstance;
|
||||
@@ -116,10 +98,14 @@ describe('ContentNodeSelectorPanelComponent', () => {
|
||||
searchQueryBuilderService = component.queryBuilderService;
|
||||
component.queryBuilderService.resetToDefaults();
|
||||
|
||||
spyOn(nodeService, 'getNode').and.returnValue(of(new MinimalNode({
|
||||
id: 'fake-node',
|
||||
path: { elements: [{ nodeType: 'st:site', name: 'fake-site' }] }
|
||||
})));
|
||||
spyOn(nodeService, 'getNode').and.returnValue(
|
||||
of(
|
||||
new Node({
|
||||
id: 'fake-node',
|
||||
path: { elements: [{ nodeType: 'st:site', name: 'fake-site' }] }
|
||||
})
|
||||
)
|
||||
);
|
||||
const fakeSite = new SiteEntry({
|
||||
entry: {
|
||||
id: 'fake-site',
|
||||
@@ -136,7 +122,6 @@ describe('ContentNodeSelectorPanelComponent', () => {
|
||||
});
|
||||
|
||||
describe('Site selection', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
spyOn(sitesService, 'getSites').and.returnValue(of(new SitePaging({ list: { entries: [] } })));
|
||||
component.currentFolderId = 'fake-starting-folder';
|
||||
@@ -167,7 +152,6 @@ describe('ContentNodeSelectorPanelComponent', () => {
|
||||
});
|
||||
|
||||
describe('Parameters', () => {
|
||||
|
||||
let documentListService: DocumentListService;
|
||||
|
||||
beforeEach(() => {
|
||||
@@ -175,14 +159,15 @@ describe('ContentNodeSelectorPanelComponent', () => {
|
||||
|
||||
spyOn(documentListService, 'getFolderNode').and.returnValue(of(new NodeEntry()));
|
||||
spyOn(documentListService, 'getFolder').and.returnValue(throwError('No results for test'));
|
||||
spyOn(sitesService, 'getSites').and.returnValue(of(new SitePaging({
|
||||
list: {
|
||||
entries: [
|
||||
{ entry: { guid: 'namek', id: 'namek' } },
|
||||
{ entry: { guid: 'blog', id: 'blog' } }
|
||||
]
|
||||
}
|
||||
})));
|
||||
spyOn(sitesService, 'getSites').and.returnValue(
|
||||
of(
|
||||
new SitePaging({
|
||||
list: {
|
||||
entries: [{ entry: { guid: 'namek', id: 'namek' } }, { entry: { guid: 'blog', id: 'blog' } }]
|
||||
}
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
component.currentFolderId = 'cat-girl-nuku-nuku';
|
||||
fixture.detectChanges();
|
||||
@@ -207,8 +192,7 @@ describe('ContentNodeSelectorPanelComponent', () => {
|
||||
fixture.detectChanges();
|
||||
|
||||
const testSiteContent = new Node({ id: 'blog-id', properties: { 'st:componentId': 'blog' } });
|
||||
expect(component.rowFilter({ node: { entry: testSiteContent } } as any, null, null))
|
||||
.toBe(false, 'did not filter out blog');
|
||||
expect(component.rowFilter({ node: { entry: testSiteContent } } as any, null, null)).toBe(false, 'did not filter out blog');
|
||||
});
|
||||
|
||||
it('should still be able to filter out the exclude site content after rowFilter changes', () => {
|
||||
@@ -227,13 +211,17 @@ describe('ContentNodeSelectorPanelComponent', () => {
|
||||
properties: { 'st:componentId': 'blog' },
|
||||
isFile: true
|
||||
});
|
||||
expect(component.rowFilter({ node: { entry: testSiteContent } } as any, null, null))
|
||||
.toBe(false, 'did not filter out blog with filterFunction1');
|
||||
expect(component.rowFilter({ node: { entry: testSiteContent } } as any, null, null)).toBe(
|
||||
false,
|
||||
'did not filter out blog with filterFunction1'
|
||||
);
|
||||
|
||||
component.rowFilter = filterFunction2;
|
||||
fixture.detectChanges();
|
||||
expect(component.rowFilter({ node: { entry: testSiteContent } } as any, null, null))
|
||||
.toBe(false, 'did not filter out blog with filterFunction2');
|
||||
expect(component.rowFilter({ node: { entry: testSiteContent } } as any, null, null)).toBe(
|
||||
false,
|
||||
'did not filter out blog with filterFunction2'
|
||||
);
|
||||
});
|
||||
|
||||
it('should NOT filter out any site content by default', () => {
|
||||
@@ -245,33 +233,28 @@ describe('ContentNodeSelectorPanelComponent', () => {
|
||||
|
||||
it('should render search input by default', () => {
|
||||
fixture.detectChanges();
|
||||
expect(fixture.debugElement.nativeElement.querySelector('.adf-content-node-selector-content-input'))
|
||||
.not.toBe(null);
|
||||
expect(fixture.debugElement.nativeElement.querySelector('.adf-content-node-selector-content-input')).not.toBe(null);
|
||||
});
|
||||
|
||||
it('should not render search input if `showSearch` is false', () => {
|
||||
component.showSearch = false;
|
||||
fixture.detectChanges();
|
||||
expect(fixture.debugElement.nativeElement.querySelector('.adf-content-node-selector-content-input'))
|
||||
.toBe(null);
|
||||
expect(fixture.debugElement.nativeElement.querySelector('.adf-content-node-selector-content-input')).toBe(null);
|
||||
});
|
||||
|
||||
it('should render sites list dropdown by default', () => {
|
||||
fixture.detectChanges();
|
||||
expect(fixture.debugElement.nativeElement.querySelector('adf-sites-dropdown'))
|
||||
.not.toBe(null);
|
||||
expect(fixture.debugElement.nativeElement.querySelector('adf-sites-dropdown')).not.toBe(null);
|
||||
});
|
||||
|
||||
it('should not render sites list dropdown if `showDropdownSiteList` is false', () => {
|
||||
component.showDropdownSiteList = false;
|
||||
fixture.detectChanges();
|
||||
expect(fixture.debugElement.nativeElement.querySelector('adf-sites-dropdown'))
|
||||
.toBe(null);
|
||||
expect(fixture.debugElement.nativeElement.querySelector('adf-sites-dropdown')).toBe(null);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Breadcrumbs', () => {
|
||||
|
||||
let documentListService: DocumentListService;
|
||||
|
||||
beforeEach(() => {
|
||||
@@ -292,7 +275,6 @@ describe('ContentNodeSelectorPanelComponent', () => {
|
||||
const breadcrumb = fixture.debugElement.query(By.directive(DropdownBreadcrumbComponent));
|
||||
expect(breadcrumb).not.toBeNull();
|
||||
expect(breadcrumb.componentInstance.folderNode).toEqual(undefined);
|
||||
|
||||
});
|
||||
|
||||
it('should not show the breadcrumb if search was performed as last action', async () => {
|
||||
@@ -314,7 +296,6 @@ describe('ContentNodeSelectorPanelComponent', () => {
|
||||
fixture.detectChanges();
|
||||
const breadcrumb = fixture.debugElement.query(By.directive(DropdownBreadcrumbComponent));
|
||||
expect(breadcrumb).not.toBeNull();
|
||||
|
||||
});
|
||||
|
||||
it('should show the breadcrumb in search results for a valid node selection', async () => {
|
||||
@@ -377,7 +358,7 @@ describe('ContentNodeSelectorPanelComponent', () => {
|
||||
name: 'trans-node-name',
|
||||
path: { elements: [{ id: 'testId', name: 'testName' }] }
|
||||
};
|
||||
component.breadcrumbTransform = (() => transformedFolderNode);
|
||||
component.breadcrumbTransform = () => transformedFolderNode;
|
||||
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
@@ -391,7 +372,6 @@ describe('ContentNodeSelectorPanelComponent', () => {
|
||||
});
|
||||
|
||||
describe('Chosen node', () => {
|
||||
|
||||
const entry: Node = { id: 'fakeid' } as Node;
|
||||
const nodePage: NodePaging = { list: { pagination: {} } };
|
||||
let hasAllowableOperations;
|
||||
@@ -464,7 +444,6 @@ describe('ContentNodeSelectorPanelComponent', () => {
|
||||
});
|
||||
|
||||
describe('in the case when isSelectionValid is a custom function for checking permissions,', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
component.isSelectionValid = returnHasPermission;
|
||||
});
|
||||
@@ -528,7 +507,6 @@ describe('ContentNodeSelectorPanelComponent', () => {
|
||||
});
|
||||
|
||||
describe('in the case when isSelectionValid is null', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
component.isSelectionValid = null;
|
||||
});
|
||||
@@ -579,7 +557,6 @@ describe('ContentNodeSelectorPanelComponent', () => {
|
||||
});
|
||||
|
||||
describe('in the case when isSelectionValid is not defined', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
component.isSelectionValid = undefined;
|
||||
});
|
||||
@@ -632,10 +609,13 @@ describe('ContentNodeSelectorPanelComponent', () => {
|
||||
const isUploadingSpy = spyOn(uploadService, 'isUploading').and.returnValue(true);
|
||||
const documentListReloadSpy = spyOn(component.documentList, 'reloadWithoutResettingSelection');
|
||||
|
||||
const fakeFileModels = [new FileModel({
|
||||
name: 'fake-name',
|
||||
size: 100
|
||||
} as File), new FileModel({ name: 'fake-name-2', size: 200 } as File)];
|
||||
const fakeFileModels = [
|
||||
new FileModel({
|
||||
name: 'fake-name',
|
||||
size: 100
|
||||
} as File),
|
||||
new FileModel({ name: 'fake-name-2', size: 200 } as File)
|
||||
];
|
||||
const fileUploadCompleteEvent = new FileUploadCompleteEvent(fakeFileModels[0], 1, fakeFileModels[0], 0);
|
||||
uploadService.fileUploadComplete.next(fileUploadCompleteEvent);
|
||||
|
||||
@@ -698,11 +678,9 @@ describe('ContentNodeSelectorPanelComponent', () => {
|
||||
expect(component.getPreselectNodesBasedOnSelectionMode()).toEqual([]);
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('Search panel', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
contentNodeSelectorPanelService.customModels = undefined;
|
||||
});
|
||||
|
Reference in New Issue
Block a user