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,25 +15,19 @@
* limitations under the License.
*/
import { CommonModule } from '@angular/common';
import { NgModule } from '@angular/core';
import { TranslateModule } from '@ngx-translate/core';
import { MaterialModule } from '../material.module';
import { DataColumnModule, DataTableModule, DirectiveModule } from '@alfresco/adf-core';
import { TaskAttachmentListComponent } from './task-attachment-list.component';
import { ProcessAttachmentListComponent } from './process-attachment-list.component';
import { CreateProcessAttachmentComponent } from './create-process-attachment.component';
import { AttachmentComponent } from './create-task-attachment.component';
import { CoreModule } from '@alfresco/adf-core';
@NgModule({
imports: [
DataColumnModule,
DataTableModule,
MaterialModule,
CommonModule,
TranslateModule,
DirectiveModule
CoreModule,
MaterialModule
],
declarations: [
TaskAttachmentListComponent,

View File

@@ -17,12 +17,13 @@
import { SimpleChange } from '@angular/core';
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { ProcessContentService, CoreModule } from '@alfresco/adf-core';
import { setupTestBed } from '@alfresco/adf-core';
import { CreateProcessAttachmentComponent } from './create-process-attachment.component';
import { ProcessTestingModule } from '../testing/process.testing.module';
declare let jasmine: any;
describe('Activiti Process Create Attachment', () => {
describe('CreateProcessAttachmentComponent', () => {
let component: CreateProcessAttachmentComponent;
let fixture: ComponentFixture<CreateProcessAttachmentComponent>;
@@ -46,19 +47,11 @@ describe('Activiti Process Create Attachment', () => {
thumbnailStatus: 'queued'
};
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [
CoreModule.forRoot()
],
declarations: [
CreateProcessAttachmentComponent
],
providers: [
ProcessContentService
]
}).compileComponents();
}));
setupTestBed({
imports: [
ProcessTestingModule
]
});
beforeEach(() => {
fixture = TestBed.createComponent(CreateProcessAttachmentComponent);

View File

@@ -16,31 +16,23 @@
*/
import { SimpleChange } from '@angular/core';
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { Observable } from 'rxjs/Observable';
import { ProcessContentService } from '@alfresco/adf-core';
import { ProcessContentService, setupTestBed } from '@alfresco/adf-core';
import { AttachmentComponent } from './create-task-attachment.component';
import { ProcessTestingModule } from '../testing/process.testing.module';
describe('Activiti Task Create Attachment', () => {
describe('AttachmentComponent', () => {
let service: ProcessContentService;
let component: AttachmentComponent;
let fixture: ComponentFixture<AttachmentComponent>;
let createTaskRelatedContentSpy: jasmine.Spy;
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [
],
declarations: [
AttachmentComponent
],
providers: [
ProcessContentService
]
}).compileComponents();
}));
setupTestBed({
imports: [ProcessTestingModule]
});
beforeEach(() => {

View File

@@ -15,14 +15,13 @@
* limitations under the License.
*/
import { NgZone, SimpleChange, Component } from '@angular/core';
import { SimpleChange, Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { MatProgressSpinnerModule } from '@angular/material';
import { By } from '@angular/platform-browser';
import { TranslateService } from '@ngx-translate/core';
import { ProcessContentService } from '@alfresco/adf-core';
import { ProcessContentService, setupTestBed } from '@alfresco/adf-core';
import { Observable } from 'rxjs/Observable';
import { ProcessAttachmentListComponent } from './process-attachment-list.component';
import { ProcessTestingModule } from '../testing/process.testing.module';
describe('ProcessAttachmentListComponent', () => {
@@ -32,21 +31,9 @@ describe('ProcessAttachmentListComponent', () => {
let getProcessRelatedContentSpy: jasmine.Spy;
let mockAttachment: any;
beforeEach(async(() => {
let zone = new NgZone({enableLongStackTrace: false});
TestBed.configureTestingModule({
imports: [
MatProgressSpinnerModule
],
declarations: [
ProcessAttachmentListComponent
],
providers: [
ProcessContentService,
{ provide: NgZone, useValue: zone }
]
}).compileComponents();
}));
setupTestBed({
imports: [ProcessTestingModule]
});
beforeEach(() => {
@@ -54,11 +41,6 @@ describe('ProcessAttachmentListComponent', () => {
component = fixture.componentInstance;
service = fixture.debugElement.injector.get(ProcessContentService);
const translateService: TranslateService = TestBed.get(TranslateService);
spyOn(translateService, 'get').and.callFake((key) => {
return Observable.of(key);
});
mockAttachment = {
size: 2,
total: 2,
@@ -161,7 +143,7 @@ describe('ProcessAttachmentListComponent', () => {
});
}));
it('should display all actions if attachements are not read only', async(() => {
it('should display all actions if attachments are not read only', async(() => {
let change = new SimpleChange(null, '123', true);
component.ngOnChanges({ 'processInstanceId': change });
@@ -317,16 +299,11 @@ class CustomEmptyTemplateComponent {
describe('Custom CustomEmptyTemplateComponent', () => {
let fixture: ComponentFixture<CustomEmptyTemplateComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [
ProcessAttachmentListComponent,
CustomEmptyTemplateComponent
],
imports: [
]
}).compileComponents();
}));
setupTestBed({
imports: [ProcessTestingModule],
declarations: [CustomEmptyTemplateComponent],
schemas: [ CUSTOM_ELEMENTS_SCHEMA ]
});
beforeEach(() => {
fixture = TestBed.createComponent(CustomEmptyTemplateComponent);

View File

@@ -15,12 +15,13 @@
* limitations under the License.
*/
import { SimpleChange, Component } from '@angular/core';
import { SimpleChange, Component, CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA } from '@angular/core';
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { By } from '@angular/platform-browser';
import { Observable } from 'rxjs/Observable';
import { TaskAttachmentListComponent } from './task-attachment-list.component';
import { ProcessContentService } from '@alfresco/adf-core';
import { ProcessContentService, setupTestBed } from '@alfresco/adf-core';
import { ProcessTestingModule } from '../testing/process.testing.module';
describe('TaskAttachmentList', () => {
@@ -32,17 +33,10 @@ describe('TaskAttachmentList', () => {
let deleteContentSpy: jasmine.Spy;
let getFileRawContentSpy: jasmine.Spy;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [
TaskAttachmentListComponent
],
providers: [
ProcessContentService
]
}).compileComponents();
}));
setupTestBed({
imports: [ProcessTestingModule],
schemas: [NO_ERRORS_SCHEMA]
});
beforeEach(() => {
@@ -257,8 +251,13 @@ describe('TaskAttachmentList', () => {
describe('change detection', () => {
let change = new SimpleChange('123', '456', true);
let nullChange = new SimpleChange('123', null, true);
let change;
let nullChange;
beforeEach(() => {
change = new SimpleChange('123', '456', true);
nullChange = new SimpleChange('123', null, true);
});
beforeEach(async(() => {
component.taskId = '123';
@@ -267,10 +266,13 @@ describe('TaskAttachmentList', () => {
});
}));
it('should fetch new attachments when taskId changed', () => {
component.ngOnChanges({ 'taskId': change });
expect(getTaskRelatedContentSpy).toHaveBeenCalledWith('456');
});
it('should fetch new attachments when taskId changed', async(() => {
fixture.detectChanges();
fixture.whenStable().then(() => {
component.ngOnChanges({ 'taskId': change });
expect(getTaskRelatedContentSpy).toHaveBeenCalledWith('456');
});
}));
it('should NOT fetch new attachments when empty change set made', () => {
component.ngOnChanges({});
@@ -318,14 +320,11 @@ class CustomEmptyTemplateComponent {
describe('Custom CustomEmptyTemplateComponent', () => {
let fixture: ComponentFixture<CustomEmptyTemplateComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [
TaskAttachmentListComponent,
CustomEmptyTemplateComponent
]
}).compileComponents();
}));
setupTestBed({
imports: [ProcessTestingModule],
declarations: [CustomEmptyTemplateComponent],
schemas: [ CUSTOM_ELEMENTS_SCHEMA ]
});
beforeEach(() => {
fixture = TestBed.createComponent(CustomEmptyTemplateComponent);