mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
first part random test fix (#3376)
fixing random test executions first part
This commit is contained in:
@@ -79,6 +79,11 @@ describe('StartFormComponent', () => {
|
||||
component.ngOnChanges({ 'appId': change });
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
fixture.destroy();
|
||||
TestBed.resetTestingModule();
|
||||
});
|
||||
|
||||
it('should enable start button when name and process filled out', async(() => {
|
||||
component.selectedProcessDef = testProcessDefRepr;
|
||||
fixture.detectChanges();
|
||||
@@ -155,13 +160,17 @@ describe('StartFormComponent', () => {
|
||||
describe('CS content connection', () => {
|
||||
|
||||
it('alfrescoRepositoryName default configuration property', () => {
|
||||
appConfig.config = Object.assign(appConfig.config, {
|
||||
'alfrescoRepositoryName': null
|
||||
});
|
||||
|
||||
expect(component.getAlfrescoRepositoryName()).toBe('alfresco-1Alfresco');
|
||||
});
|
||||
|
||||
it('alfrescoRepositoryName configuration property should be fetched', () => {
|
||||
appConfig.config = Object.assign(appConfig.config, {
|
||||
'alfrescoRepositoryName': 'alfresco-123'
|
||||
};
|
||||
});
|
||||
|
||||
expect(component.getAlfrescoRepositoryName()).toBe('alfresco-123Alfresco');
|
||||
});
|
||||
@@ -171,7 +180,7 @@ describe('StartFormComponent', () => {
|
||||
component.values = {};
|
||||
component.values['file'] = {
|
||||
isFile: true,
|
||||
name= 'example-file'
|
||||
name: 'example-file'
|
||||
};
|
||||
|
||||
component.moveNodeFromCStoPS();
|
||||
|
@@ -29,8 +29,7 @@ import { noDataMock, taskDetailsMock, taskFormMock, tasksMock, taskDetailsWithOu
|
||||
import { TaskListService } from './../services/tasklist.service';
|
||||
import { TaskDetailsComponent } from './task-details.component';
|
||||
import { ProcessTestingModule } from '../../testing/process.testing.module';
|
||||
|
||||
declare let jasmine: any;
|
||||
import { PeopleProcessService } from '@alfresco/adf-core';
|
||||
|
||||
const fakeUser: UserProcessModel = new UserProcessModel({
|
||||
id: 'fake-id',
|
||||
@@ -51,6 +50,7 @@ describe('TaskDetailsComponent', () => {
|
||||
let completeTaskSpy: jasmine.Spy;
|
||||
let logService: LogService;
|
||||
let commentProcessService: CommentProcessService;
|
||||
let peopleProcessService: PeopleProcessService;
|
||||
|
||||
setupTestBed({
|
||||
imports: [
|
||||
@@ -87,6 +87,7 @@ describe('TaskDetailsComponent', () => {
|
||||
]));
|
||||
|
||||
fixture = TestBed.createComponent(TaskDetailsComponent);
|
||||
peopleProcessService = TestBed.get(PeopleProcessService);
|
||||
component = fixture.componentInstance;
|
||||
});
|
||||
|
||||
@@ -412,16 +413,20 @@ describe('TaskDetailsComponent', () => {
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
jasmine.Ajax.install();
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
jasmine.Ajax.uninstall();
|
||||
});
|
||||
|
||||
it('should return an observable with user search results', (done) => {
|
||||
component.peopleSearch$.subscribe((users) => {
|
||||
spyOn(peopleProcessService, 'getWorkflowUsers').and.returnValue(Observable.of([{
|
||||
id: 1,
|
||||
firstName: 'fake-test-1',
|
||||
lastName: 'fake-last-1',
|
||||
email: 'fake-test-1@test.com'
|
||||
}, {
|
||||
id: 2,
|
||||
firstName: 'fake-test-2',
|
||||
lastName: 'fake-last-2',
|
||||
email: 'fake-test-2@test.com'
|
||||
}]));
|
||||
|
||||
component.peopleSearch.subscribe((users) => {
|
||||
expect(users.length).toBe(2);
|
||||
expect(users[0].firstName).toBe('fake-test-1');
|
||||
expect(users[0].lastName).toBe('fake-last-1');
|
||||
@@ -430,46 +435,25 @@ describe('TaskDetailsComponent', () => {
|
||||
done();
|
||||
});
|
||||
component.searchUser('fake-search-word');
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
status: 200,
|
||||
contentType: 'json',
|
||||
responseText: {
|
||||
data: [{
|
||||
id: 1,
|
||||
firstName: 'fake-test-1',
|
||||
lastName: 'fake-last-1',
|
||||
email: 'fake-test-1@test.com'
|
||||
}, {
|
||||
id: 2,
|
||||
firstName: 'fake-test-2',
|
||||
lastName: 'fake-last-2',
|
||||
email: 'fake-test-2@test.com'
|
||||
}]
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
it('should return an empty list for not valid search', (done) => {
|
||||
component.peopleSearch$.subscribe((users) => {
|
||||
spyOn(peopleProcessService, 'getWorkflowUsers').and.returnValue(Observable.of([]));
|
||||
|
||||
component.peopleSearch.subscribe((users) => {
|
||||
expect(users.length).toBe(0);
|
||||
done();
|
||||
});
|
||||
component.searchUser('fake-search-word');
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
status: 200,
|
||||
contentType: 'json',
|
||||
responseText: {}
|
||||
});
|
||||
});
|
||||
|
||||
it('should log error message when search fails', async(() => {
|
||||
component.peopleSearch$.subscribe(() => {
|
||||
spyOn(peopleProcessService, 'getWorkflowUsers').and.returnValue(Observable.throw(''));
|
||||
|
||||
component.peopleSearch.subscribe(() => {
|
||||
expect(logService.error).toHaveBeenCalledWith('Could not load users');
|
||||
});
|
||||
component.searchUser('fake-search');
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
status: 403
|
||||
});
|
||||
}));
|
||||
|
||||
it('should assign task to user', () => {
|
||||
|
@@ -177,7 +177,7 @@ export class TaskDetailsComponent implements OnInit, OnChanges {
|
||||
private peopleSearchObserver: Observer<UserProcessModel[]>;
|
||||
public errorDialogRef: MatDialogRef<TemplateRef<any>>;
|
||||
|
||||
peopleSearch$: Observable<UserProcessModel[]>;
|
||||
peopleSearch: Observable<UserProcessModel[]>;
|
||||
|
||||
constructor(private taskListService: TaskListService,
|
||||
private authService: AuthenticationService,
|
||||
@@ -189,7 +189,7 @@ export class TaskDetailsComponent implements OnInit, OnChanges {
|
||||
|
||||
this.formRenderingService.setComponentTypeResolver('select-folder', () => AttachFolderWidgetComponent, true);
|
||||
this.formRenderingService.setComponentTypeResolver('upload', () => AttachFileWidgetComponent, true);
|
||||
this.peopleSearch$ = new Observable<UserProcessModel[]>(observer => this.peopleSearchObserver = observer).share();
|
||||
this.peopleSearch = new Observable<UserProcessModel[]>(observer => this.peopleSearchObserver = observer).share();
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
|
Reference in New Issue
Block a user