unit test performance (#3194)

* DataTable (-4 sec)

* PaginationComponent (-1 sec)

* DocumentList

* custom testbed setup, test upgrades

* test fixes

* more test fixes

* remove fdescribe

* test fixes

* test fixes

* more test fixes

* test fixes

* upgrade tests

* update tests

* upgrade tests

* upgrade tests

* upgrade tests

* upgrade tests

* update tests

* translate loader fixes

* auth and cookie fixes

* upgrade tests

* upgrade tests

* test fixes

* almost there

* diable broken tests

* process tests (part 1)

* fix lint issues

* another test upgrade

* almost there

* cleanup

* insights testing upgrade

* improve tests

* tests cleanup

* tests cleanup

* cleanup tests

* test cleanup

* favorite nodes tests

* rebase fix syntax

* fix core test

* give up test focus

* flush tabs

* fix search test

* Update document-list.component.spec.ts

* fix document list lock

* increase tick time

* remove duplicate test
This commit is contained in:
Denys Vuika
2018-04-23 09:55:22 +01:00
committed by Eugenio Romano
parent 9fbfcfa96e
commit 382ea3c1b3
204 changed files with 3093 additions and 4389 deletions

View File

@@ -15,15 +15,15 @@
* limitations under the License.
*/
import { async, TestBed, fakeAsync, tick } from '@angular/core/testing';
import { TestBed, fakeAsync, tick } from '@angular/core/testing';
import { MinimalNodeEntryEntity, SitePaging } from 'alfresco-js-api';
import { AppConfigService, SitesService } from '@alfresco/adf-core';
import { AppConfigService, SitesService, setupTestBed } from '@alfresco/adf-core';
import { DocumentListService } from '../document-list/services/document-list.service';
import { CustomResourcesService } from '../document-list/services/custom-resources.service';
import { ContentNodeDialogService } from './content-node-dialog.service';
import { MatDialog } from '@angular/material';
import { Observable } from 'rxjs/Observable';
import { Subject } from 'rxjs/Subject';
import { ContentTestingModule } from '../testing/content.testing.module';
const fakeNode: MinimalNodeEntryEntity = <MinimalNodeEntryEntity> {
id: 'fake',
@@ -60,18 +60,9 @@ describe('ContentNodeDialogService', () => {
let spyOnDialogOpen: jasmine.Spy;
let afterOpenObservable: Subject<any>;
beforeEach(async(() => {
TestBed.configureTestingModule({
providers: [
ContentNodeDialogService,
DocumentListService,
CustomResourcesService,
SitesService,
MatDialog
]
}).compileComponents();
}));
setupTestBed({
imports: [ContentTestingModule]
});
beforeEach(() => {
let appConfig: AppConfigService = TestBed.get(AppConfigService);
@@ -89,7 +80,6 @@ describe('ContentNodeDialogService', () => {
error: new Subject<any>()
}
});
});
it('should not open the lock node dialog if have no permission', () => {

View File

@@ -19,21 +19,16 @@ import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { async, fakeAsync, tick, ComponentFixture, TestBed } from '@angular/core/testing';
import { By } from '@angular/platform-browser';
import { MinimalNodeEntryEntity, SiteEntry, SitePaging } from 'alfresco-js-api';
import { SearchService, SitesService } from '@alfresco/adf-core';
import { DataTableModule } from '@alfresco/adf-core';
import { SearchService, SitesService, setupTestBed } from '@alfresco/adf-core';
import { Observable } from 'rxjs/Observable';
import { Observer } from 'rxjs/Observer';
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';
import { ContentNodeSelectorService } from './content-node-selector.service';
import { NodePaging } from 'alfresco-js-api';
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';
const ONE_FOLDER_RESULT = {
list: {
@@ -74,37 +69,13 @@ describe('ContentNodeSelectorComponent', () => {
_observer.next(result);
}
afterEach(() => {
fixture.destroy();
TestBed.resetTestingModule();
setupTestBed({
imports: [ContentTestingModule],
schemas: [CUSTOM_ELEMENTS_SCHEMA]
});
describe('General component features', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [
DataTableModule
],
declarations: [
DocumentListComponent,
EmptyFolderContentDirective,
DropdownSitesComponent,
DropdownBreadcrumbComponent,
ContentNodeSelectorPanelComponent
],
providers: [
CustomResourcesService,
SearchService,
DocumentListService,
SitesService,
ContentNodeSelectorService
],
schemas: [CUSTOM_ELEMENTS_SCHEMA]
});
TestBed.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(ContentNodeSelectorPanelComponent);
component = fixture.componentInstance;
@@ -120,6 +91,10 @@ describe('ContentNodeSelectorComponent', () => {
});
});
afterEach(() => {
fixture.destroy();
});
describe('Parameters', () => {
it('should trigger the select event when selection has been made', (done) => {
@@ -518,7 +493,7 @@ describe('ContentNodeSelectorComponent', () => {
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', () => {
let documentList = fixture.debugElement.query(By.directive(DocumentListComponent));

View File

@@ -18,74 +18,50 @@
import { MAT_DIALOG_DATA } from '@angular/material';
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { EventEmitter } from '@angular/core';
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { ContentNodeSelectorComponent } from './content-node-selector.component';
import { ContentNodeSelectorPanelComponent } from './content-node-selector-panel.component';
import { ContentNodeSelectorService } from './content-node-selector.service';
import { MinimalNodeEntryEntity } from 'alfresco-js-api';
import { By } from '@angular/platform-browser';
import {
EmptyFolderContentDirective,
DocumentListComponent,
DocumentListService,
CustomResourcesService
} from '../document-list';
import { ContentService } from '@alfresco/adf-core';
import { setupTestBed } from '@alfresco/adf-core';
import { Observable } from 'rxjs/Observable';
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';
describe('ContentNodeSelectorDialogComponent', () => {
let component: ContentNodeSelectorComponent;
let fixture: ComponentFixture<ContentNodeSelectorComponent>;
let data: any;
let data: any = {
title: 'Move along citizen...',
actionName: 'move',
select: new EventEmitter<MinimalNodeEntryEntity>(),
rowFilter: () => {},
imageResolver: () => 'piccolo',
currentFolderId: 'cat-girl-nuku-nuku'
};
function setupTestbed(plusProviders) {
TestBed.configureTestingModule({
imports: [
],
declarations: [
ContentNodeSelectorComponent,
ContentNodeSelectorPanelComponent,
DocumentListComponent,
EmptyFolderContentDirective
],
providers: [
CustomResourcesService,
ContentNodeSelectorService,
ContentNodeSelectorPanelComponent,
DocumentListService,
ContentService,
DocumentListService,
ContentNodeSelectorService,
...plusProviders
],
schemas: [CUSTOM_ELEMENTS_SCHEMA]
});
}
setupTestBed({
imports: [ContentTestingModule],
providers: [
{ provide: MAT_DIALOG_DATA, useValue: data }
],
schemas: [CUSTOM_ELEMENTS_SCHEMA]
});
beforeEach(() => {
const documentListService: DocumentListService = TestBed.get(DocumentListService);
spyOn(documentListService, 'getFolder').and.returnValue(Observable.of({ list: [] }));
spyOn(documentListService, 'getFolderNode').and.returnValue(Observable.of({}));
fixture = TestBed.createComponent(ContentNodeSelectorComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
afterEach(() => {
fixture.destroy();
TestBed.resetTestingModule();
});
beforeEach(async(() => {
data = {
title: 'Move along citizen...',
actionName: 'move',
select: new EventEmitter<MinimalNodeEntryEntity>(),
rowFilter: () => {
},
imageResolver: () => 'piccolo',
currentFolderId: 'cat-girl-nuku-nuku'
};
setupTestbed([{ provide: MAT_DIALOG_DATA, useValue: data }]);
TestBed.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(ContentNodeSelectorComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
describe('Data injecting with the "Material dialog way"', () => {
@@ -98,6 +74,7 @@ describe('ContentNodeSelectorDialogComponent', () => {
it('should have the INJECTED actionName on the name of the choose button', () => {
const actionButton = fixture.debugElement.query(By.css('[data-automation-id="content-node-selector-actions-choose"]'));
expect(component.buttonActionName).toBe('NODE_SELECTOR.MOVE');
expect(actionButton).not.toBeNull();
expect(actionButton.nativeElement.innerText).toBe('NODE_SELECTOR.MOVE');
});
@@ -108,10 +85,14 @@ describe('ContentNodeSelectorDialogComponent', () => {
expect(documentList.componentInstance.currentFolderId).toBe('cat-girl-nuku-nuku');
});
it('should pass through the injected rowFilter to the documentlist', () => {
let documentList = fixture.debugElement.query(By.directive(DocumentListComponent));
expect(documentList).not.toBeNull('Document list should be shown');
expect(documentList.componentInstance.rowFilter).toBe(data.rowFilter);
it('should pass through the injected rowFilter to the documentlist', (done) => {
fixture.whenStable().then(() => {
let documentList = fixture.debugElement.query(By.directive(DocumentListComponent));
expect(documentList).not.toBeNull('Document list should be shown');
expect(documentList.componentInstance.rowFilter).toBe(data.rowFilter);
done();
});
});
it('should pass through the injected imageResolver to the documentlist', () => {

View File

@@ -15,10 +15,11 @@
* limitations under the License.
*/
import { async, TestBed } from '@angular/core/testing';
import { TestBed } from '@angular/core/testing';
import { QueryBody } from 'alfresco-js-api';
import { SearchService } from '@alfresco/adf-core';
import { SearchService, setupTestBed } from '@alfresco/adf-core';
import { ContentNodeSelectorService } from './content-node-selector.service';
import { ContentTestingModule } from '../testing/content.testing.module';
class SearchServiceMock {
public query: QueryBody;
@@ -29,17 +30,15 @@ class SearchServiceMock {
describe('ContentNodeSelectorService', () => {
let service: ContentNodeSelectorService,
search: SearchServiceMock;
let service: ContentNodeSelectorService;
let search: SearchServiceMock;
beforeEach(async(() => {
TestBed.configureTestingModule({
providers: [
ContentNodeSelectorService,
{ provide: SearchService, useClass: SearchServiceMock }
]
}).compileComponents();
}));
setupTestBed({
imports: [ContentTestingModule],
providers: [
{ provide: SearchService, useClass: SearchServiceMock }
]
});
beforeEach(() => {
service = TestBed.get(ContentNodeSelectorService);