mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-31 17:38:48 +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
@@ -17,20 +17,18 @@
|
||||
|
||||
import { NO_ERRORS_SCHEMA, SimpleChange } from '@angular/core';
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { MatButtonModule, MatInputModule } from '@angular/material';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
|
||||
import { FormModule, FormModel, FormOutcomeEvent, FormOutcomeModel, FormService } from '@alfresco/adf-core';
|
||||
import { FormModel, FormOutcomeEvent, FormOutcomeModel, FormService, setupTestBed, BpmUserService } from '@alfresco/adf-core';
|
||||
import { CommentProcessService, LogService } from '@alfresco/adf-core';
|
||||
|
||||
import { PeopleProcessService, UserProcessModel, AuthenticationService } from '@alfresco/adf-core';
|
||||
import { UserProcessModel } from '@alfresco/adf-core';
|
||||
import { TaskDetailsModel } from '../models/task-details.model';
|
||||
import { noDataMock, taskDetailsMock, taskFormMock, tasksMock, taskDetailsWithOutAssigneeMock } from '../../mock';
|
||||
import { TaskListService } from './../services/tasklist.service';
|
||||
import { PeopleSearchComponent } from '../../people';
|
||||
import { TaskDetailsComponent } from './task-details.component';
|
||||
import { DatePipe } from '@angular/common';
|
||||
import { ProcessTestingModule } from '../../testing/process.testing.module';
|
||||
|
||||
declare let jasmine: any;
|
||||
|
||||
@@ -54,37 +52,23 @@ describe('TaskDetailsComponent', () => {
|
||||
let logService: LogService;
|
||||
let commentProcessService: CommentProcessService;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [
|
||||
FormModule,
|
||||
MatButtonModule,
|
||||
MatInputModule
|
||||
],
|
||||
declarations: [
|
||||
TaskDetailsComponent,
|
||||
PeopleSearchComponent
|
||||
],
|
||||
providers: [
|
||||
TaskListService,
|
||||
PeopleProcessService,
|
||||
CommentProcessService,
|
||||
AuthenticationService,
|
||||
DatePipe
|
||||
],
|
||||
schemas: [NO_ERRORS_SCHEMA]
|
||||
}).compileComponents();
|
||||
|
||||
logService = TestBed.get(LogService);
|
||||
|
||||
}));
|
||||
setupTestBed({
|
||||
imports: [
|
||||
ProcessTestingModule
|
||||
],
|
||||
schemas: [NO_ERRORS_SCHEMA]
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
logService = TestBed.get(LogService);
|
||||
|
||||
fixture = TestBed.createComponent(TaskDetailsComponent);
|
||||
component = fixture.componentInstance;
|
||||
service = fixture.debugElement.injector.get(TaskListService);
|
||||
formService = fixture.debugElement.injector.get(FormService);
|
||||
const userService: BpmUserService = TestBed.get(BpmUserService);
|
||||
spyOn(userService, 'getCurrentUserInfo').and.returnValue(Observable.of({}));
|
||||
|
||||
service = TestBed.get(TaskListService);
|
||||
spyOn(service, 'getTaskChecklist').and.returnValue(Observable.of(noDataMock));
|
||||
|
||||
formService = TestBed.get(FormService);
|
||||
|
||||
getTaskDetailsSpy = spyOn(service, 'getTaskDetails').and.returnValue(Observable.of(taskDetailsMock));
|
||||
spyOn(formService, 'getTaskForm').and.returnValue(Observable.of(taskFormMock));
|
||||
@@ -94,14 +78,21 @@ describe('TaskDetailsComponent', () => {
|
||||
getTasksSpy = spyOn(service, 'getTasks').and.returnValue(Observable.of(tasksMock));
|
||||
assignTaskSpy = spyOn(service, 'assignTask').and.returnValue(Observable.of(fakeUser));
|
||||
completeTaskSpy = spyOn(service, 'completeTask').and.returnValue(Observable.of({}));
|
||||
spyOn(service, 'getTaskChecklist').and.returnValue(Observable.of(noDataMock));
|
||||
commentProcessService = fixture.debugElement.injector.get(CommentProcessService);
|
||||
commentProcessService = TestBed.get(CommentProcessService);
|
||||
|
||||
spyOn(commentProcessService, 'getTaskComments').and.returnValue(Observable.of([
|
||||
{message: 'Test1', created: Date.now(), createdBy: {firstName: 'Admin', lastName: 'User'}},
|
||||
{message: 'Test2', created: Date.now(), createdBy: {firstName: 'Admin', lastName: 'User'}},
|
||||
{message: 'Test3', created: Date.now(), createdBy: {firstName: 'Admin', lastName: 'User'}}
|
||||
]));
|
||||
|
||||
fixture = TestBed.createComponent(TaskDetailsComponent);
|
||||
component = fixture.componentInstance;
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
getTaskDetailsSpy.calls.reset();
|
||||
fixture.destroy();
|
||||
});
|
||||
|
||||
it('should load task details when taskId specified', () => {
|
||||
@@ -191,8 +182,13 @@ describe('TaskDetailsComponent', () => {
|
||||
|
||||
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';
|
||||
@@ -207,15 +203,21 @@ describe('TaskDetailsComponent', () => {
|
||||
expect(getTaskDetailsSpy).toHaveBeenCalledWith('456');
|
||||
});
|
||||
|
||||
it('should NOT fetch new task details when empty changeset made', () => {
|
||||
component.ngOnChanges({});
|
||||
expect(getTaskDetailsSpy).not.toHaveBeenCalled();
|
||||
});
|
||||
it('should NOT fetch new task details when empty changeset made', async(() => {
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
component.ngOnChanges({});
|
||||
expect(getTaskDetailsSpy).not.toHaveBeenCalled();
|
||||
});
|
||||
}));
|
||||
|
||||
it('should NOT fetch new task details when taskId changed to null', () => {
|
||||
component.ngOnChanges({'taskId': nullChange});
|
||||
expect(getTaskDetailsSpy).not.toHaveBeenCalled();
|
||||
});
|
||||
it('should NOT fetch new task details when taskId changed to null', async(() => {
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
component.ngOnChanges({'taskId': nullChange});
|
||||
expect(getTaskDetailsSpy).not.toHaveBeenCalled();
|
||||
});
|
||||
}));
|
||||
|
||||
it('should set a placeholder message when taskId changed to null', () => {
|
||||
component.ngOnChanges({'taskId': nullChange});
|
||||
|
Reference in New Issue
Block a user