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,14 @@
* limitations under the License.
*/
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { ChartsModule } from 'ng2-charts';
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { DiagramsModule } from '../../diagram/diagram.module';
import { Chart } from '../../diagram/models/chart/chart.model';
import { ReportQuery } from '../../diagram/models/report/reportQuery.model';
import * as analyticMock from '../../mock';
import { AnalyticsGeneratorComponent } from '../components/analytics-generator.component';
import { AnalyticsProcessModule } from '../analytics-process.module';
import { setupTestBed } from '@alfresco/adf-core';
import { InsightsTestingModule } from '../../testing/insights.testing.module';
declare let jasmine: any;
@@ -32,15 +31,9 @@ describe('AnalyticsGeneratorComponent', () => {
let component: any;
let fixture: ComponentFixture<AnalyticsGeneratorComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [
ChartsModule,
DiagramsModule,
AnalyticsProcessModule
]
}).compileComponents();
}));
setupTestBed({
imports: [InsightsTestingModule]
});
beforeEach(() => {
fixture = TestBed.createComponent(AnalyticsGeneratorComponent);

View File

@@ -16,9 +16,9 @@
*/
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { DiagramsModule } from '../../diagram/diagram.module';
import { AnalyticsReportHeatMapComponent } from '../components/analytics-report-heat-map.component';
import { AnalyticsProcessModule } from '../analytics-process.module';
import { setupTestBed } from '@alfresco/adf-core';
import { InsightsTestingModule } from '../../testing/insights.testing.module';
declare let jasmine: any;
@@ -36,15 +36,9 @@ describe('AnalyticsReportHeatMapComponent', () => {
let totalTimeValues: any = { 'sid-fake-id': 1, 'fake-start-event': 4 };
let avgTimeValues: any = { 'sid-fake-id': 4, 'fake-start-event': 5 };
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [
DiagramsModule,
AnalyticsProcessModule
]
}).compileComponents();
}));
setupTestBed({
imports: [InsightsTestingModule]
});
beforeEach(() => {
fixture = TestBed.createComponent(AnalyticsReportHeatMapComponent);

View File

@@ -15,11 +15,11 @@
* limitations under the License.
*/
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { DiagramsModule } from '../../diagram/diagram.module';
import { AnalyticsProcessModule } from '../analytics-process.module';
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { AnalyticsReportListComponent } from '../components/analytics-report-list.component';
import { ReportParametersModel } from '../../diagram/models/report/reportParameters.model';
import { setupTestBed } from '@alfresco/adf-core';
import { InsightsTestingModule } from '../../testing/insights.testing.module';
declare let jasmine: any;
@@ -39,14 +39,9 @@ describe('AnalyticsReportListComponent', () => {
let fixture: ComponentFixture<AnalyticsReportListComponent>;
let element: HTMLElement;
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [
DiagramsModule,
AnalyticsProcessModule
]
}).compileComponents();
}));
setupTestBed({
imports: [InsightsTestingModule]
});
beforeEach(() => {
fixture = TestBed.createComponent(AnalyticsReportListComponent);

View File

@@ -20,7 +20,8 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { ReportParametersModel } from '../../diagram/models/report/reportParameters.model';
import * as analyticParamsMock from '../../mock';
import { AnalyticsReportParametersComponent } from '../components/analytics-report-parameters.component';
import { AnalyticsProcessModule } from '../analytics-process.module';
import { setupTestBed } from '@alfresco/adf-core';
import { InsightsTestingModule } from '../../testing/insights.testing.module';
declare let jasmine: any;
@@ -30,13 +31,9 @@ describe('AnalyticsReportParametersComponent', () => {
let fixture: ComponentFixture<AnalyticsReportParametersComponent>;
let element: HTMLElement;
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [
AnalyticsProcessModule
]
}).compileComponents();
}));
setupTestBed({
imports: [InsightsTestingModule]
});
beforeEach(() => {
fixture = TestBed.createComponent(AnalyticsReportParametersComponent);

View File

@@ -15,40 +15,26 @@
* limitations under the License.
*/
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { DiagramsModule } from '../../diagram/diagram.module';
import { ChartsModule } from 'ng2-charts';
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { AnalyticsComponent } from '../components/analytics.component';
declare let jasmine: any;
import { setupTestBed } from '@alfresco/adf-core';
import { InsightsTestingModule } from '../../testing/insights.testing.module';
describe('AnalyticsComponent', () => {
let fixture: ComponentFixture<AnalyticsComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [
ChartsModule,
DiagramsModule
]
}).compileComponents();
}));
setupTestBed({
imports: [InsightsTestingModule]
});
beforeEach(() => {
fixture = TestBed.createComponent(AnalyticsComponent);
fixture.detectChanges();
});
describe('Rendering tests', () => {
beforeEach(() => {
jasmine.Ajax.install();
});
afterEach(() => {
jasmine.Ajax.uninstall();
});
it('should create component', () => {
expect(fixture.componentInstance).toBeDefined();
});
});

View File

@@ -18,19 +18,20 @@
import { TestBed } from '@angular/core/testing';
import { fakeReportList } from '../../mock';
import { AnalyticsService } from './analytics.service';
import { setupTestBed } from '@alfresco/adf-core';
import { InsightsTestingModule } from '../../testing/insights.testing.module';
declare let jasmine: any;
describe('Activiti Analytics Service', () => {
describe('AnalyticsService', () => {
let service: AnalyticsService;
setupTestBed({
imports: [InsightsTestingModule]
});
beforeEach(() => {
TestBed.configureTestingModule({
providers: [
AnalyticsService
]
});
service = TestBed.get(AnalyticsService);
});

View File

@@ -18,8 +18,9 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import * as diagramsActivitiesMock from '../../mock/diagram/diagramActivities.mock';
import { DiagramsModule } from '../diagram.module';
import { DiagramComponent } from './diagram.component';
import { setupTestBed } from '@alfresco/adf-core';
import { InsightsTestingModule } from '../../testing/insights.testing.module';
declare let jasmine: any;
@@ -29,11 +30,9 @@ describe('Diagrams activities', () => {
let fixture: ComponentFixture<DiagramComponent>;
let element: HTMLElement;
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [DiagramsModule]
}).compileComponents();
}));
setupTestBed({
imports: [InsightsTestingModule]
});
beforeEach(() => {
fixture = TestBed.createComponent(DiagramComponent);
@@ -51,6 +50,7 @@ describe('Diagrams activities', () => {
afterEach(() => {
component.success.unsubscribe();
fixture.destroy();
jasmine.Ajax.uninstall();
});

View File

@@ -18,8 +18,9 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import * as boundaryEventMock from '../../mock/diagram/diagramBoundary.mock';
import { DiagramsModule } from '../diagram.module';
import { DiagramComponent } from './diagram.component';
import { setupTestBed } from '@alfresco/adf-core';
import { InsightsTestingModule } from '../../testing/insights.testing.module';
declare let jasmine: any;
@@ -29,11 +30,9 @@ describe('Diagrams boundary', () => {
let fixture: ComponentFixture<DiagramComponent>;
let element: HTMLElement;
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [DiagramsModule]
}).compileComponents();
}));
setupTestBed({
imports: [InsightsTestingModule]
});
beforeEach(() => {
fixture = TestBed.createComponent(DiagramComponent);
@@ -51,6 +50,7 @@ describe('Diagrams boundary', () => {
afterEach(() => {
component.success.unsubscribe();
fixture.destroy();
jasmine.Ajax.uninstall();
});

View File

@@ -19,7 +19,8 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import * as intermediateCatchingMock from '../../mock/diagram/diagramIntermediate.mock';
import { DiagramComponent } from './diagram.component';
import { DiagramsModule } from '../diagram.module';
import { setupTestBed } from '@alfresco/adf-core';
import { InsightsTestingModule } from '../../testing/insights.testing.module';
declare let jasmine: any;
@@ -29,11 +30,9 @@ describe('Diagrams Catching', () => {
let fixture: ComponentFixture<DiagramComponent>;
let element: HTMLElement;
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [DiagramsModule]
}).compileComponents();
}));
setupTestBed({
imports: [InsightsTestingModule]
});
beforeEach(() => {
fixture = TestBed.createComponent(DiagramComponent);
@@ -51,6 +50,7 @@ describe('Diagrams Catching', () => {
afterEach(() => {
component.success.unsubscribe();
fixture.destroy();
jasmine.Ajax.uninstall();
});

View File

@@ -19,7 +19,8 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import * as diagramsEventsMock from '../../mock/diagram/diagramEvents.mock';
import { DiagramComponent } from './diagram.component';
import { DiagramsModule } from '../diagram.module';
import { setupTestBed } from '@alfresco/adf-core';
import { InsightsTestingModule } from '../../testing/insights.testing.module';
declare let jasmine: any;
@@ -29,11 +30,9 @@ describe('Diagrams events', () => {
let fixture: ComponentFixture<DiagramComponent>;
let element: HTMLElement;
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [DiagramsModule]
}).compileComponents();
}));
setupTestBed({
imports: [InsightsTestingModule]
});
beforeEach(() => {
fixture = TestBed.createComponent(DiagramComponent);
@@ -51,6 +50,7 @@ describe('Diagrams events', () => {
afterEach(() => {
component.success.unsubscribe();
fixture.destroy();
jasmine.Ajax.uninstall();
});

View File

@@ -19,7 +19,8 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import * as flowsMock from '../../mock/diagram/diagramFlows.mock';
import { DiagramComponent } from './diagram.component';
import { DiagramsModule } from '../diagram.module';
import { setupTestBed } from '@alfresco/adf-core';
import { InsightsTestingModule } from '../../testing/insights.testing.module';
declare let jasmine: any;
@@ -29,11 +30,9 @@ describe('Diagrams flows', () => {
let fixture: ComponentFixture<DiagramComponent>;
let element: HTMLElement;
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [DiagramsModule]
}).compileComponents();
}));
setupTestBed({
imports: [InsightsTestingModule]
});
beforeEach(() => {
fixture = TestBed.createComponent(DiagramComponent);
@@ -51,6 +50,7 @@ describe('Diagrams flows', () => {
afterEach(() => {
component.success.unsubscribe();
fixture.destroy();
jasmine.Ajax.uninstall();
});

View File

@@ -19,7 +19,8 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import * as diagramsGatewaysMock from '../../mock/diagram/diagramGateways.mock';
import { DiagramComponent } from './diagram.component';
import { DiagramsModule } from '../diagram.module';
import { setupTestBed } from '@alfresco/adf-core';
import { InsightsTestingModule } from '../../testing/insights.testing.module';
declare let jasmine: any;
@@ -29,11 +30,9 @@ describe('Diagrams gateways', () => {
let fixture: ComponentFixture<DiagramComponent>;
let element: HTMLElement;
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [DiagramsModule]
}).compileComponents();
}));
setupTestBed({
imports: [InsightsTestingModule]
});
beforeEach(() => {
fixture = TestBed.createComponent(DiagramComponent);
@@ -51,6 +50,7 @@ describe('Diagrams gateways', () => {
afterEach(() => {
component.success.unsubscribe();
fixture.destroy();
jasmine.Ajax.uninstall();
});

View File

@@ -19,7 +19,8 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import * as structuralMock from '../../mock/diagram/diagramStructural.mock';
import { DiagramComponent } from './diagram.component';
import { DiagramsModule } from '../diagram.module';
import { setupTestBed } from '@alfresco/adf-core';
import { InsightsTestingModule } from '../../testing/insights.testing.module';
declare let jasmine: any;
@@ -29,11 +30,9 @@ describe('Diagrams structural', () => {
let fixture: ComponentFixture<DiagramComponent>;
let element: HTMLElement;
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [DiagramsModule]
}).compileComponents();
}));
setupTestBed({
imports: [InsightsTestingModule]
});
beforeEach(() => {
fixture = TestBed.createComponent(DiagramComponent);
@@ -51,6 +50,7 @@ describe('Diagrams structural', () => {
afterEach(() => {
component.success.unsubscribe();
fixture.destroy();
jasmine.Ajax.uninstall();
});

View File

@@ -19,7 +19,8 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import * as swimLanesMock from '../../mock/diagram/diagramSwimlanes.mock';
import { DiagramComponent } from './diagram.component';
import { DiagramsModule } from '../diagram.module';
import { setupTestBed } from '@alfresco/adf-core';
import { InsightsTestingModule } from '../../testing/insights.testing.module';
declare let jasmine: any;
@@ -29,11 +30,9 @@ describe('Diagrams swim', () => {
let fixture: ComponentFixture<DiagramComponent>;
let element: HTMLElement;
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [DiagramsModule]
}).compileComponents();
}));
setupTestBed({
imports: [InsightsTestingModule]
});
beforeEach(() => {
fixture = TestBed.createComponent(DiagramComponent);
@@ -51,6 +50,7 @@ describe('Diagrams swim', () => {
afterEach(() => {
component.success.unsubscribe();
fixture.destroy();
jasmine.Ajax.uninstall();
});

View File

@@ -19,7 +19,8 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import * as throwEventMock from '../../mock/diagram/diagramThrow.mock';
import { DiagramComponent } from './diagram.component';
import { DiagramsModule } from '../diagram.module';
import { setupTestBed } from '@alfresco/adf-core';
import { InsightsTestingModule } from '../../testing/insights.testing.module';
declare let jasmine: any;
@@ -29,25 +30,26 @@ describe('Diagrams throw', () => {
let fixture: ComponentFixture<DiagramComponent>;
let element: HTMLElement;
setupTestBed({
imports: [InsightsTestingModule]
});
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [DiagramsModule]
}).compileComponents().then(() => {
jasmine.Ajax.install();
jasmine.Ajax.install();
fixture = TestBed.createComponent(DiagramComponent);
component = fixture.componentInstance;
element = fixture.nativeElement;
component.processInstanceId = '38399';
component.processDefinitionId = 'fakeprocess:24:38399';
component.metricPercentages = { startEvent: 0 };
fixture = TestBed.createComponent(DiagramComponent);
component = fixture.componentInstance;
element = fixture.nativeElement;
component.processInstanceId = '38399';
component.processDefinitionId = 'fakeprocess:24:38399';
component.metricPercentages = { startEvent: 0 };
fixture.detectChanges();
});
fixture.detectChanges();
}));
afterEach(() => {
component.success.unsubscribe();
fixture.destroy();
jasmine.Ajax.uninstall();
});

View File

@@ -15,9 +15,10 @@
* limitations under the License.
*/
import { async, TestBed } from '@angular/core/testing';
import { AppConfigService } from '@alfresco/adf-core';
import { TestBed } from '@angular/core/testing';
import { AppConfigService, setupTestBed } from '@alfresco/adf-core';
import { DiagramsService } from './diagrams.service';
import { InsightsTestingModule } from '../../testing/insights.testing.module';
declare let jasmine: any;
@@ -25,13 +26,9 @@ describe('DiagramsService', () => {
let service: DiagramsService;
beforeEach(async(() => {
TestBed.configureTestingModule({
providers: [
DiagramsService
]
}).compileComponents();
}));
setupTestBed({
imports: [InsightsTestingModule]
});
beforeEach(() => {
let appConfig: AppConfigService = TestBed.get(AppConfigService);

View File

@@ -18,56 +18,8 @@ appContext.keys().forEach(appContext);
const TestBed = require('@angular/core/testing').TestBed;
const browser = require('@angular/platform-browser-dynamic/testing');
const NoopAnimationsModule = require('@angular/platform-browser/animations').NoopAnimationsModule;
const CoreModule = require('@alfresco/adf-core').CoreModule;
const AppConfigService = require('@alfresco/adf-core').AppConfigService;
const AppConfigServiceMock = require('@alfresco/adf-core').AppConfigServiceMock;
const TranslationService = require('@alfresco/adf-core').TranslationService;
const TranslationMock = require('@alfresco/adf-core').TranslationMock;
const AlfrescoApiServiceMock = require('@alfresco/adf-core').AlfrescoApiServiceMock;
const AlfrescoApiService = require('@alfresco/adf-core').AlfrescoApiService;
TestBed.initTestEnvironment(browser.BrowserDynamicTestingModule, browser.platformBrowserDynamicTesting());
patchTestBedToDestroyFixturesAfterEveryTest(TestBed);
beforeEach(() => {
TestBed.configureTestingModule({
imports: [
NoopAnimationsModule,
CoreModule.forRoot()
],
providers: [
{provide: AlfrescoApiService, useClass: AlfrescoApiServiceMock},
{provide: AppConfigService, useClass: AppConfigServiceMock},
{provide: TranslationService, useClass: TranslationMock}
]
});
});
afterEach(() => {
TestBed.resetTestingModule();
});
function patchTestBedToDestroyFixturesAfterEveryTest(testBed) {
// Original resetTestingModule function of the TestBed.
var _resetTestingModule = testBed.resetTestingModule;
// Monkey-patch the resetTestingModule to destroy fixtures outside of a try/catch block.
// With https://github.com/angular/angular/commit/2c5a67134198a090a24f6671dcdb7b102fea6eba
// errors when destroying components are no longer causing Jasmine to fail.
testBed.resetTestingModule = function() {
try {
if(this._activeFixtures) {
this._activeFixtures.forEach(function (fixture) {
fixture.destroy();
});
}
} finally {
this._activeFixtures = [];
// Regardless of errors or not, run the original reset testing module function.
_resetTestingModule.call(this);
}
};
};
TestBed.initTestEnvironment(
browser.BrowserDynamicTestingModule,
browser.platformBrowserDynamicTesting()
);

View File

@@ -0,0 +1,38 @@
/*!
* @license
* Copyright 2016 Alfresco Software, Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { NgModule } from '@angular/core';
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
import { InsightsModule } from '../insights.module';
import {
AlfrescoApiService,
AlfrescoApiServiceMock,
AppConfigService,
AppConfigServiceMock,
TranslationService,
TranslationMock
} from '@alfresco/adf-core';
@NgModule({
imports: [NoopAnimationsModule, InsightsModule],
providers: [
{ provide: AlfrescoApiService, useClass: AlfrescoApiServiceMock },
{ provide: AppConfigService, useClass: AppConfigServiceMock },
{ provide: TranslationService, useClass: TranslationMock }
]
})
export class InsightsTestingModule {}