mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
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:
committed by
Eugenio Romano
parent
9fbfcfa96e
commit
382ea3c1b3
@@ -15,15 +15,15 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { DebugElement, Component } from '@angular/core';
|
||||
import { DebugElement, Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { AppsProcessService } from '@alfresco/adf-core';
|
||||
import { AppsProcessService, setupTestBed } from '@alfresco/adf-core';
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
|
||||
import { defaultApp, deployedApps, nonDeployedApps } from '../mock/apps-list.mock';
|
||||
import { AppsListComponent } from './apps-list.component';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { ProcessTestingModule } from '../testing/process.testing.module';
|
||||
|
||||
describe('AppsListComponent', () => {
|
||||
|
||||
@@ -33,17 +33,9 @@ describe('AppsListComponent', () => {
|
||||
let service: AppsProcessService;
|
||||
let getAppsSpy: jasmine.Spy;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [
|
||||
TranslateModule
|
||||
],
|
||||
declarations: [
|
||||
AppsListComponent
|
||||
]
|
||||
}).compileComponents();
|
||||
|
||||
}));
|
||||
setupTestBed({
|
||||
imports: [ProcessTestingModule]
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(AppsListComponent);
|
||||
@@ -263,23 +255,23 @@ class CustomEmptyAppListTemplateComponent {
|
||||
describe('Custom CustomEmptyAppListTemplateComponent', () => {
|
||||
let fixture: ComponentFixture<CustomEmptyAppListTemplateComponent>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [
|
||||
AppsListComponent,
|
||||
CustomEmptyAppListTemplateComponent
|
||||
]
|
||||
}).compileComponents();
|
||||
}));
|
||||
setupTestBed({
|
||||
imports: [ProcessTestingModule],
|
||||
declarations: [CustomEmptyAppListTemplateComponent],
|
||||
schemas: [ CUSTOM_ELEMENTS_SCHEMA ]
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(CustomEmptyAppListTemplateComponent);
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
fixture.destroy();
|
||||
});
|
||||
|
||||
it('should render the custom no-apps template', async(() => {
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
fixture.detectChanges();
|
||||
let title: any = fixture.debugElement.queryAll(By.css('[adf-empty-list-header]'));
|
||||
expect(title.length).toBe(1);
|
||||
expect(title[0].nativeElement.innerText).toBe('No Apps');
|
||||
|
@@ -16,33 +16,29 @@
|
||||
*/
|
||||
|
||||
import { Component } from '@angular/core';
|
||||
import { async, TestBed } from '@angular/core/testing';
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
import { ComponentFixture } from '@angular/core/testing';
|
||||
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
|
||||
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material';
|
||||
import { BrowserDynamicTestingModule } from '@angular/platform-browser-dynamic/testing';
|
||||
import { MatDialog } from '@angular/material';
|
||||
import { OverlayContainer } from '@angular/cdk/overlay';
|
||||
import { AppsProcessService } from '@alfresco/adf-core';
|
||||
import { AppsProcessService, setupTestBed } from '@alfresco/adf-core';
|
||||
import { deployedApps } from '../mock/apps-list.mock';
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
|
||||
import { SelectAppsDialogComponent } from './select-apps-dialog-component';
|
||||
import { ProcessTestingModule } from '../testing/process.testing.module';
|
||||
|
||||
@Component({
|
||||
selector: 'adf-dialog-test',
|
||||
template: ''
|
||||
})
|
||||
export class DialogSelectAppTestComponent {
|
||||
|
||||
processId: any;
|
||||
|
||||
dialogRef: any;
|
||||
|
||||
constructor(private dialog: MatDialog) {
|
||||
}
|
||||
constructor(private dialog: MatDialog) {}
|
||||
|
||||
startProcesAction() {
|
||||
startProcessAction() {
|
||||
this.dialogRef = this.dialog.open(SelectAppsDialogComponent, {
|
||||
width: '630px'
|
||||
});
|
||||
@@ -51,57 +47,41 @@ export class DialogSelectAppTestComponent {
|
||||
this.processId = selectedProcess.id;
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
describe('Select app dialog', () => {
|
||||
|
||||
let fixture: ComponentFixture<DialogSelectAppTestComponent>;
|
||||
let component: DialogSelectAppTestComponent;
|
||||
let dialogRef;
|
||||
let dialogRef = {
|
||||
close: jasmine.createSpy('close')
|
||||
};
|
||||
let overlayContainerElement: HTMLElement;
|
||||
let service: AppsProcessService;
|
||||
|
||||
beforeEach(async(() => {
|
||||
dialogRef = {
|
||||
close: jasmine.createSpy('close')
|
||||
};
|
||||
|
||||
TestBed.configureTestingModule({
|
||||
imports: [
|
||||
FormsModule,
|
||||
ReactiveFormsModule,
|
||||
BrowserDynamicTestingModule
|
||||
],
|
||||
declarations: [
|
||||
SelectAppsDialogComponent,
|
||||
DialogSelectAppTestComponent
|
||||
],
|
||||
providers: [
|
||||
AppsProcessService,
|
||||
{
|
||||
provide: OverlayContainer,
|
||||
useFactory: () => {
|
||||
overlayContainerElement = document.createElement('div');
|
||||
return { getContainerElement: () => overlayContainerElement };
|
||||
}
|
||||
setupTestBed({
|
||||
imports: [ProcessTestingModule],
|
||||
declarations: [DialogSelectAppTestComponent],
|
||||
providers: [
|
||||
AppsProcessService,
|
||||
{
|
||||
provide: OverlayContainer,
|
||||
useFactory: () => {
|
||||
overlayContainerElement = document.createElement('div');
|
||||
return {
|
||||
getContainerElement: () => overlayContainerElement
|
||||
};
|
||||
}
|
||||
{
|
||||
provide: MatDialogRef, useValue: dialogRef
|
||||
},
|
||||
{
|
||||
provide: MAT_DIALOG_DATA,
|
||||
useValue: {}
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
TestBed.overrideModule(BrowserDynamicTestingModule, {
|
||||
set: { entryComponents: [SelectAppsDialogComponent] }
|
||||
});
|
||||
|
||||
TestBed.compileComponents();
|
||||
}));
|
||||
},
|
||||
{
|
||||
provide: MatDialogRef,
|
||||
useValue: dialogRef
|
||||
},
|
||||
{
|
||||
provide: MAT_DIALOG_DATA,
|
||||
useValue: {}
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(DialogSelectAppTestComponent);
|
||||
@@ -109,21 +89,29 @@ describe('Select app dialog', () => {
|
||||
|
||||
service = TestBed.get(AppsProcessService);
|
||||
|
||||
spyOn(service, 'getDeployedApplications').and.returnValue(Observable.of(deployedApps));
|
||||
spyOn(service, 'getDeployedApplications').and.returnValue(
|
||||
Observable.of(deployedApps)
|
||||
);
|
||||
});
|
||||
|
||||
describe('Dialog', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
fixture.detectChanges();
|
||||
};
|
||||
});
|
||||
|
||||
it('should init title and dropdown', () => {
|
||||
component.startProcesAction();
|
||||
component.startProcessAction();
|
||||
|
||||
expect(overlayContainerElement.querySelector('.adf-selet-app-dialog-title')).toBeDefined();
|
||||
expect(overlayContainerElement.querySelector('.adf-selet-app-dialog-dropdown')).toBeDefined();
|
||||
expect(
|
||||
overlayContainerElement.querySelector(
|
||||
'.adf-selet-app-dialog-title'
|
||||
)
|
||||
).toBeDefined();
|
||||
expect(
|
||||
overlayContainerElement.querySelector(
|
||||
'.adf-selet-app-dialog-dropdown'
|
||||
)
|
||||
).toBeDefined();
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
Reference in New Issue
Block a user