[no-issue] speed up test CS part 2 (#3009)

* remove tag and rating service the testbed

* remove unused import in modules

* pdf viewer async

* viewer test fixed

* remove testbed share datatable

* remove unused dependencies

* add missing parameter

* remove testbed from folder actions service

* TaskHeaderComponent async

* remove testbed from document actions and list

* remove unused import

* use done for nested test

* fast finish false
This commit is contained in:
Eugenio Romano
2018-02-28 17:15:52 +00:00
committed by GitHub
parent b359579078
commit 45426fd246
52 changed files with 410 additions and 561 deletions

View File

@@ -18,7 +18,6 @@
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { async, TestBed } from '@angular/core/testing';
import { DataTableModule } from '@alfresco/adf-core';
import { MaterialModule } from '../../../material.module';
import { DocumentListService } from '../../services/document-list.service';
import { ContentActionModel } from './../../models/content-action.model';
import { DocumentListComponent } from './../document-list.component';
@@ -32,8 +31,7 @@ describe('ContentColumnList', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [
DataTableModule,
MaterialModule
DataTableModule
],
declarations: [
DocumentListComponent

View File

@@ -20,7 +20,6 @@ import { EventEmitter } from '@angular/core';
import { async, TestBed } from '@angular/core/testing';
import { ContentService } from '@alfresco/adf-core';
import { DataTableModule } from '@alfresco/adf-core';
import { MaterialModule } from '../../../material.module';
import { FileNode } from '../../../mock';
import { DocumentListService } from '../../services/document-list.service';
import { ContentActionHandler } from './../../models/content-action.model';
@@ -45,8 +44,7 @@ describe('ContentAction', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [
DataTableModule,
MaterialModule
DataTableModule
],
providers: [
DocumentListService

View File

@@ -18,7 +18,6 @@
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { async, TestBed } from '@angular/core/testing';
import { DataColumn, DataTableModule } from '@alfresco/adf-core';
import { MaterialModule } from '../../../material.module';
import { LogService } from '@alfresco/adf-core';
import { DocumentListService } from '../../services/document-list.service';
@@ -34,8 +33,7 @@ describe('ContentColumnList', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [
DataTableModule,
MaterialModule
DataTableModule
],
declarations: [
DocumentListComponent

View File

@@ -19,7 +19,6 @@ import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { async, TestBed } from '@angular/core/testing';
import { LogService } from '@alfresco/adf-core';
import { DataTableModule } from '@alfresco/adf-core';
import { MaterialModule } from '../../../material.module';
import { DocumentListService } from '../../services/document-list.service';
import { DocumentListComponent } from './../document-list.component';
import { ContentColumnListComponent } from './content-column-list.component';
@@ -34,8 +33,7 @@ describe('ContentColumn', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [
DataTableModule,
MaterialModule
DataTableModule
],
declarations: [
DocumentListComponent

View File

@@ -31,7 +31,6 @@ import {
fakeGetSitesAnswer,
fakeGetSiteMembership
} from '../../mock';
import { MaterialModule } from '../../material.module';
import { ContentActionModel } from '../models/content-action.model';
import { NodeMinimal, NodeMinimalEntry, NodePaging } from '../models/document-library.model';
import { ImageResolver } from './../data/image-resolver.model';
@@ -56,8 +55,7 @@ describe('DocumentList', () => {
TestBed.configureTestingModule({
imports: [
DataTableModule,
MaterialModule
DataTableModule
],
declarations: [
DocumentListComponent

View File

@@ -18,7 +18,6 @@
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { async, TestBed } from '@angular/core/testing';
import { DataTableComponent, DataTableModule } from '@alfresco/adf-core';
import { MaterialModule } from '../../../material.module';
import { DocumentListService } from '../../services/document-list.service';
import { DocumentListComponent } from './../document-list.component';
@@ -32,8 +31,7 @@ describe('EmptyFolderContent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [
DataTableModule,
MaterialModule
DataTableModule
],
declarations: [
DocumentListComponent

View File

@@ -19,7 +19,6 @@ import { async, TestBed } from '@angular/core/testing';
import { MatProgressSpinnerModule } from '@angular/material';
import { DataTableComponent, DataTableModule } from '@alfresco/adf-core';
import { DocumentListService } from '../../services/document-list.service';
import { MaterialModule } from '../../../material.module';
import { DocumentListComponent } from './../document-list.component';
import { NoPermissionContentDirective } from './no-permission-content.directive';
@@ -32,7 +31,6 @@ describe('NoPermissionContentDirective', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [
MaterialModule,
DataTableModule,
MatProgressSpinnerModule
],

View File

@@ -15,8 +15,7 @@
* limitations under the License.
*/
import { async, TestBed } from '@angular/core/testing';
import { DataColumn, DataRow, DataSorting } from '@alfresco/adf-core';
import { DataColumn, DataRow, DataSorting, ContentService } from '@alfresco/adf-core';
import { FileNode, FolderNode } from './../../mock';
import { DocumentListService } from './../services/document-list.service';
import { ShareDataRow } from './share-data-row.model';
@@ -26,17 +25,11 @@ describe('ShareDataTableAdapter', () => {
let documentListService: DocumentListService;
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [],
providers: [
DocumentListService
]
}).compileComponents();
}));
beforeEach(() => {
documentListService = TestBed.get(DocumentListService);
let imageUrl: string = 'http://<addresss>';
let contentService = new ContentService(null, null, null, null);
documentListService = new DocumentListService(null, contentService, null, null, null);
spyOn(documentListService, 'getDocumentThumbnailUrl').and.returnValue(imageUrl);
});
it('should setup rows and columns with constructor', () => {
@@ -194,13 +187,15 @@ describe('ShareDataTableAdapter', () => {
});
it('should generate fallback icon for a file thumbnail with missing mime type', () => {
spyOn(documentListService, 'getDefaultMimeTypeIcon').and.returnValue(`assets/images/ft_ic_miscellaneouse.svg`);
let adapter = new ShareDataTableAdapter(documentListService, null);
let file = new FileNode();
file.entry.content.mimeType = null;
let row = new ShareDataRow(file, documentListService, null);
let col = <DataColumn> {type: 'image', key: '$thumbnail'};
let col = <DataColumn> { type: 'image', key: '$thumbnail' };
let value = adapter.getValue(row, col);
expect(value).toContain(`assets/images/ft_ic_miscellaneous`);
@@ -208,13 +203,15 @@ describe('ShareDataTableAdapter', () => {
});
it('should generate fallback icon for a file with no content entry', () => {
spyOn(documentListService, 'getDefaultMimeTypeIcon').and.returnValue(`assets/images/ft_ic_miscellaneouse.svg`);
let adapter = new ShareDataTableAdapter(documentListService, null);
let file = new FileNode();
file.entry.content = null;
let row = new ShareDataRow(file, documentListService, null);
let col = <DataColumn> {type: 'image', key: '$thumbnail'};
let col = <DataColumn> { type: 'image', key: '$thumbnail' };
let value = adapter.getValue(row, col);
expect(value).toContain(`assets/images/ft_ic_miscellaneous`);
@@ -229,17 +226,19 @@ describe('ShareDataTableAdapter', () => {
let adapter = new ShareDataTableAdapter(documentListService, null);
let row = new ShareDataRow(file, documentListService, null);
let col = <DataColumn> {type: 'image', key: 'icon'};
let col = <DataColumn> { type: 'image', key: 'icon' };
let value = adapter.getValue(row, col);
expect(value).toBe(imageUrl);
});
it('should resolve folder icon', () => {
spyOn(documentListService, 'getMimeTypeIcon').and.returnValue(`assets/images/ft_ic_folder.svg`);
let adapter = new ShareDataTableAdapter(documentListService, null);
let row = new ShareDataRow(new FolderNode(), documentListService, null);
let col = <DataColumn> {type: 'image', key: '$thumbnail'};
let col = <DataColumn> { type: 'image', key: '$thumbnail' };
let value = adapter.getValue(row, col);
expect(value).toContain(`assets/images/ft_ic_folder`);
@@ -247,15 +246,13 @@ describe('ShareDataTableAdapter', () => {
});
it('should resolve file thumbnail', () => {
let imageUrl: string = 'http://<addresss>';
spyOn(documentListService, 'getDocumentThumbnailUrl').and.returnValue(imageUrl);
let imageUrl = 'http://<addresss>';
let adapter = new ShareDataTableAdapter(documentListService, null);
adapter.thumbnails = true;
let file = new FileNode();
let row = new ShareDataRow(file, documentListService, null);
let col = <DataColumn> {type: 'image', key: '$thumbnail'};
let col = <DataColumn> { type: 'image', key: '$thumbnail' };
let value = adapter.getValue(row, col);
expect(value).toBe(imageUrl);
@@ -263,6 +260,8 @@ describe('ShareDataTableAdapter', () => {
});
it('should resolve fallback file icon for unknown node', () => {
spyOn(documentListService, 'getDefaultMimeTypeIcon').and.returnValue(`assets/images/ft_ic_miscellaneous.svg`);
let adapter = new ShareDataTableAdapter(documentListService, null);
let file = new FileNode();
@@ -271,7 +270,7 @@ describe('ShareDataTableAdapter', () => {
file.entry.content = null;
let row = new ShareDataRow(file, documentListService, null);
let col = <DataColumn> {type: 'image', key: '$thumbnail'};
let col = <DataColumn> { type: 'image', key: '$thumbnail' };
let value = adapter.getValue(row, col);
expect(value).toContain(`assets/images/ft_ic_miscellaneous`);
@@ -279,6 +278,7 @@ describe('ShareDataTableAdapter', () => {
});
it('should resolve file icon for content type', () => {
spyOn(documentListService, 'getMimeTypeIcon').and.returnValue(`assets/images/ft_ic_raster_image.svg`);
let adapter = new ShareDataTableAdapter(documentListService, null);
let file = new FileNode();
@@ -287,7 +287,7 @@ describe('ShareDataTableAdapter', () => {
file.entry.content.mimeType = 'image/png';
let row = new ShareDataRow(file, documentListService, null);
let col = <DataColumn> {type: 'image', key: '$thumbnail'};
let col = <DataColumn> { type: 'image', key: '$thumbnail' };
let value = adapter.getValue(row, col);
expect(value).toContain(`assets/images/ft_ic_raster_image`);
@@ -299,7 +299,7 @@ describe('ShareDataTableAdapter', () => {
let file2 = new FileNode('file2');
let folder = new FolderNode();
let col = <DataColumn> {key: 'name'};
let col = <DataColumn> { key: 'name' };
let adapter = new ShareDataTableAdapter(documentListService, [col]);
adapter.setSorting(new DataSorting('name', 'asc'));
@@ -322,7 +322,7 @@ describe('ShareDataTableAdapter', () => {
let file2 = new FileNode('file2');
file2.entry['dateProp'] = new Date(2016, 6, 30, 13, 14, 2);
let col = <DataColumn> {key: 'dateProp'};
let col = <DataColumn> { key: 'dateProp' };
let adapter = new ShareDataTableAdapter(documentListService, [col]);
adapter.setRows([
@@ -352,7 +352,7 @@ describe('ShareDataTableAdapter', () => {
file3.entry.content.sizeInBytes = 4224120; // 4.03 MB
file4.entry.content.sizeInBytes = 2852791665; // 2.66 GB
let col = <DataColumn> {key: 'content.sizeInBytes'};
let col = <DataColumn> { key: 'content.sizeInBytes' };
let adapter = new ShareDataTableAdapter(documentListService, [col]);
adapter.setRows([
@@ -385,7 +385,7 @@ describe('ShareDataTableAdapter', () => {
let file5 = new FileNode('a');
let file6 = new FileNode('b');
let col = <DataColumn> {key: 'name'};
let col = <DataColumn> { key: 'name' };
let adapter = new ShareDataTableAdapter(documentListService, [col]);
adapter.setRows([
@@ -415,71 +415,57 @@ describe('ShareDataTableAdapter', () => {
expect((<ShareDataRow> rows[4]).node).toBe(file6);
expect((<ShareDataRow> rows[5]).node).toBe(file5);
});
});
describe('ShareDataRow', () => {
describe('ShareDataRow', () => {
let documentListService: DocumentListService;
it('should wrap node', () => {
let file = new FileNode();
let row = new ShareDataRow(file, documentListService, null);
expect(row.node).toBe(file);
});
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [],
providers: [
DocumentListService
]
}).compileComponents();
}));
it('should require object source', () => {
expect(() => {
return new ShareDataRow(null, documentListService, null);
}).toThrowError(ShareDataRow.ERR_OBJECT_NOT_FOUND);
});
beforeEach(() => {
documentListService = TestBed.get(DocumentListService);
});
it('should resolve value from node entry', () => {
let file = new FileNode('test');
let row = new ShareDataRow(file, documentListService, null);
expect(row.getValue('name')).toBe('test');
});
it('should wrap node', () => {
let file = new FileNode();
let row = new ShareDataRow(file, documentListService, null);
expect(row.node).toBe(file);
});
it('should check value', () => {
let file = new FileNode('test');
let row = new ShareDataRow(file, documentListService, null);
it('should require object source', () => {
expect(() => {
return new ShareDataRow(null, documentListService, null);
}).toThrowError(ShareDataRow.ERR_OBJECT_NOT_FOUND);
});
expect(row.hasValue('name')).toBeTruthy();
expect(row.hasValue('missing')).toBeFalsy();
});
it('should resolve value from node entry', () => {
let file = new FileNode('test');
let row = new ShareDataRow(file, documentListService, null);
expect(row.getValue('name')).toBe('test');
});
it('should be set as drop target when user has permission for that node', () => {
let file = new FolderNode('test');
file.entry['allowableOperations'] = ['create'];
let row = new ShareDataRow(file, documentListService, null);
it('should check value', () => {
let file = new FileNode('test');
let row = new ShareDataRow(file, documentListService, null);
expect(row.isDropTarget).toBeTruthy();
});
expect(row.hasValue('name')).toBeTruthy();
expect(row.hasValue('missing')).toBeFalsy();
});
it('should not be set as drop target when user has permission for that node', () => {
let file = new FolderNode('test');
let row = new ShareDataRow(file, documentListService, null);
it('should be set as drop target when user has permission for that node', () => {
let file = new FolderNode('test');
file.entry['allowableOperations'] = ['create'];
let row = new ShareDataRow(file, documentListService, null);
expect(row.isDropTarget).toBeFalsy();
});
expect(row.isDropTarget).toBeTruthy();
});
it('should not be set as drop target when element is not a Folder', () => {
let file = new FileNode('test');
let row = new ShareDataRow(file, documentListService, null);
it('should not be set as drop target when user has permission for that node', () => {
let file = new FolderNode('test');
let row = new ShareDataRow(file, documentListService, null);
expect(row.isDropTarget).toBeFalsy();
});
expect(row.isDropTarget).toBeFalsy();
});
it('should not be set as drop target when element is not a Folder', () => {
let file = new FileNode('test');
let row = new ShareDataRow(file, documentListService, null);
expect(row.isDropTarget).toBeFalsy();
});
});

View File

@@ -15,16 +15,17 @@
* limitations under the License.
*/
import { async, TestBed } from '@angular/core/testing';
import {
AlfrescoApiService,
AppConfigService,
StorageService,
ContentService
} from '@alfresco/adf-core';
import { FileNode, FolderNode } from '../../mock';
import { DocumentListModule } from '../document-list.module';
import { ContentActionHandler } from '../models/content-action.model';
import { DocumentActionsService } from './document-actions.service';
import { DocumentListService } from './document-list.service';
import { NodeActionsService } from './node-actions.service';
import { DialogModule } from '../../dialogs/dialog.module';
import { ContentNodeDialogService } from '../../content-node-selector/content-node-dialog.service';
import { Observable } from 'rxjs/Observable';
describe('DocumentActionsService', () => {
@@ -33,22 +34,12 @@ describe('DocumentActionsService', () => {
let documentListService: DocumentListService;
let nodeActionsService: NodeActionsService;
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [
DialogModule,
DocumentListModule
],
providers: [
ContentNodeDialogService
]
}).compileComponents();
}));
beforeEach(() => {
documentListService = TestBed.get(DocumentListService);
nodeActionsService = TestBed.get(NodeActionsService);
service = TestBed.get(DocumentActionsService);
let contentService = new ContentService(null, null, null, null);
let alfrescoApiService = new AlfrescoApiService(new AppConfigService(null), new StorageService());
documentListService = new DocumentListService(null, contentService, alfrescoApiService, null, null);
service = new DocumentActionsService(null, documentListService, contentService);
});
it('should register default download action', () => {

View File

@@ -15,9 +15,12 @@
* limitations under the License.
*/
import { async, TestBed } from '@angular/core/testing';
import { CookieService, LogService } from '@alfresco/adf-core';
import { CookieServiceMock } from '@alfresco/adf-core';
import {
AlfrescoApiService,
AppConfigService,
StorageService,
ContentService
} from '@alfresco/adf-core';
import { DocumentListService } from './document-list.service';
declare let jasmine: any;
@@ -87,19 +90,10 @@ describe('DocumentListService', () => {
}
};
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [],
providers: [
DocumentListService,
{ provide: CookieService, useClass: CookieServiceMock },
LogService
]
}).compileComponents();
}));
beforeEach(() => {
service = TestBed.get(DocumentListService);
let contentService = new ContentService(null, null, null, null);
let alfrescoApiService = new AlfrescoApiService(new AppConfigService(null), new StorageService());
service = new DocumentListService(null, contentService, alfrescoApiService, null, null);
jasmine.Ajax.install();
});

View File

@@ -15,41 +15,32 @@
* limitations under the License.
*/
import { async, TestBed } from '@angular/core/testing';
import { TranslationService, AppConfigService, NotificationService } from '@alfresco/adf-core';
import { TestBed } from '@angular/core/testing';
import {
AlfrescoApiService,
AppConfigService,
StorageService,
ContentService
} from '@alfresco/adf-core';
import { Observable } from 'rxjs/Observable';
import { FileNode, FolderNode } from '../../mock';
import { ContentActionHandler } from '../models/content-action.model';
import { DocumentListService } from './document-list.service';
import { FolderActionsService } from './folder-actions.service';
import { NodeActionsService } from './node-actions.service';
import { ContentNodeDialogService } from '../../content-node-selector/content-node-dialog.service';
describe('FolderActionsService', () => {
let service: FolderActionsService;
let documentListService: DocumentListService;
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [],
providers: [
DocumentListService,
FolderActionsService,
NodeActionsService,
TranslationService,
NotificationService,
ContentNodeDialogService
]
}).compileComponents();
}));
beforeEach(() => {
let appConfig: AppConfigService = TestBed.get(AppConfigService);
appConfig.config.ecmHost = 'http://localhost:9876/ecm';
service = TestBed.get(FolderActionsService);
documentListService = TestBed.get(DocumentListService);
let contentService = new ContentService(null, null, null, null);
let alfrescoApiService = new AlfrescoApiService(new AppConfigService(null), new StorageService());
documentListService = new DocumentListService(null, contentService, alfrescoApiService, null, null);
service = new FolderActionsService(null, documentListService, contentService);
});
it('should register custom action handler', () => {