fix random test failing part 2 (#3395)

* fix random failing test core search/comment/auth/user

* fix node delete directive

* fix lint issues

* node restore fix

* fix comment test

* remove fdescribe

* fix tests and tslint

* fix upload test

* unsubscribe success event task test

* copy comment object during test

* use the data pipe performance improvement and standard usage

* uncomment random test

* fix comment date random failing test

* disposable unsubscribe

* fix start process

* remove fdescribe

* change start process test and remove commented code

* fix error event check double click

* clone object form test

* refactor date time test

* fix service mock

* fix test dropdown and context

* git hook lint

* fix language test

* unsubscribe documentlist event test

* fix disposable error

* fix console log service error document list

* unusbscribe search test

* clear input field

* remove wrong test
This commit is contained in:
Eugenio Romano
2018-05-29 11:18:17 +02:00
committed by Denys Vuika
parent 22006395c7
commit eb0f91c5db
43 changed files with 4475 additions and 4332 deletions

View File

@@ -32,6 +32,7 @@ describe('TaskAttachmentList', () => {
let mockAttachment: any;
let deleteContentSpy: jasmine.Spy;
let getFileRawContentSpy: jasmine.Spy;
let disposablelSuccess: any;
setupTestBed({
imports: [ProcessTestingModule],
@@ -83,7 +84,7 @@ describe('TaskAttachmentList', () => {
mockAttachment
));
deleteContentSpy = spyOn(service, 'deleteRelatedContent').and.returnValue(Observable.of({successCode: true}));
deleteContentSpy = spyOn(service, 'deleteRelatedContent').and.returnValue(Observable.of({ successCode: true }));
let blobObj = new Blob();
getFileRawContentSpy = spyOn(service, 'getFileRawContent').and.returnValue(Observable.of(blobObj));
@@ -94,6 +95,10 @@ describe('TaskAttachmentList', () => {
overlayContainers.forEach((overlayContainer) => {
overlayContainer.innerHTML = '';
});
if (disposablelSuccess) {
disposablelSuccess.unsubscribe();
}
});
it('should load attachments when taskId specified', () => {
@@ -112,7 +117,7 @@ describe('TaskAttachmentList', () => {
it('should emit a success event when the attachments are loaded', () => {
let change = new SimpleChange(null, '123', true);
component.success.subscribe((attachments) => {
disposablelSuccess = component.success.subscribe((attachments) => {
expect(attachments[0].name).toEqual(mockAttachment.data[0].name);
expect(attachments[0].id).toEqual(mockAttachment.data[0].id);
});
@@ -307,12 +312,12 @@ describe('TaskAttachmentList', () => {
@Component({
template: `
<adf-task-attachment-list>
<adf-empty-list>
<div adf-empty-list-header class="adf-empty-list-header">Custom header</div>
</adf-empty-list>
</adf-task-attachment-list>
`
<adf-task-attachment-list>
<adf-empty-list>
<div adf-empty-list-header class="adf-empty-list-header">Custom header</div>
</adf-empty-list>
</adf-task-attachment-list>
`
})
class CustomEmptyTemplateComponent {
}
@@ -323,7 +328,7 @@ describe('Custom CustomEmptyTemplateComponent', () => {
setupTestBed({
imports: [ProcessTestingModule],
declarations: [CustomEmptyTemplateComponent],
schemas: [ CUSTOM_ELEMENTS_SCHEMA ]
schemas: [CUSTOM_ELEMENTS_SCHEMA]
});
beforeEach(() => {

View File

@@ -22,7 +22,7 @@ export let taskDetailsMock = new TaskDetailsModel({
'name': 'Request translation',
'description': null,
'category': null,
'assignee': {'id': 1001, 'firstName': 'Wilbur', 'lastName': 'Adams', 'email': 'wilbur@app.activiti.com'},
'assignee': { 'id': 1001, 'firstName': 'Wilbur', 'lastName': 'Adams', 'email': 'wilbur@app.activiti.com' },
'created': '2016-11-03T15:25:42.749+0000',
'dueDate': null,
'endDate': null,
@@ -104,20 +104,20 @@ export let claimableTaskDetailsMock = new TaskDetailsModel({
'processInstanceName': null,
'processDefinitionId': 'TranslationProcess:2:8',
'processDefinitionName': 'Translation Process',
'involvedGroups': [{'id': 7007, 'name': 'group1', 'externalId': null, 'status': 'active', 'groups': null},
{'id': 8008, 'name': 'group2', 'externalId': null, 'status': 'active', 'groups': null}],
'involvedGroups': [{ 'id': 7007, 'name': 'group1', 'externalId': null, 'status': 'active', 'groups': null },
{ 'id': 8008, 'name': 'group2', 'externalId': null, 'status': 'active', 'groups': null }],
'involvedPeople': [],
'managerOfCandidateGroup': true,
'memberOfCandidateGroup': true,
'memberOfCandidateUsers': false
});
export let claimedTaskDetailsMock = new TaskDetailsModel({
export let claimedTaskDetailsMock = new TaskDetailsModel({
'id': '91',
'name': 'Request translation',
'description': null,
'category': null,
'assignee': {'id': 1001, 'firstName': 'Wilbur', 'lastName': 'Adams', 'email': 'wilbur@app.activiti.com'},
'assignee': { 'id': 1001, 'firstName': 'Wilbur', 'lastName': 'Adams', 'email': 'wilbur@app.activiti.com' },
'created': '2016-11-03T15:25:42.749+0000',
'dueDate': null,
'endDate': null,
@@ -129,9 +129,9 @@ export let claimedTaskDetailsMock = new TaskDetailsModel({
'processInstanceName': null,
'processDefinitionId': 'TranslationProcess:2:8',
'processDefinitionName': 'Translation Process',
'involvedGroups': [{'id': 7007, 'name': 'group1', 'externalId': null, 'status': 'active', 'groups': null}],
'involvedPeople': [{'id': 1001, 'firstName': 'Wilbur', 'lastName': 'Adams', 'email': 'wilbur@app.activiti.com'},
{'id': 111, 'firstName': 'fake-first-name', 'lastName': 'fake-last-name', 'email': 'fake@app.activiti.com'}],
'involvedGroups': [{ 'id': 7007, 'name': 'group1', 'externalId': null, 'status': 'active', 'groups': null }],
'involvedPeople': [{ 'id': 1001, 'firstName': 'Wilbur', 'lastName': 'Adams', 'email': 'wilbur@app.activiti.com' },
{ 'id': 111, 'firstName': 'fake-first-name', 'lastName': 'fake-last-name', 'email': 'fake@app.activiti.com' }],
'managerOfCandidateGroup': true,
'memberOfCandidateGroup': true,
'memberOfCandidateUsers': true
@@ -142,7 +142,12 @@ export let claimedByGroupMemberMock = new TaskDetailsModel({
'name': 'Request translation',
'description': null,
'category': null,
'assignee': {'id': 111, 'firstName': 'fake-first-name', 'lastName': 'fake-last-name', 'email': 'fake@app.activiti.com'},
'assignee': {
'id': 111,
'firstName': 'fake-first-name',
'lastName': 'fake-last-name',
'email': 'fake@app.activiti.com'
},
'created': '2016-11-03T15:25:42.749+0000',
'dueDate': null,
'endDate': null,
@@ -154,9 +159,9 @@ export let claimedByGroupMemberMock = new TaskDetailsModel({
'processInstanceName': null,
'processDefinitionId': 'TranslationProcess:2:8',
'processDefinitionName': 'Translation Process',
'involvedGroups': [{'id': 7007, 'name': 'group1', 'externalId': null, 'status': 'active', 'groups': null}],
'involvedPeople': [{'id': 1001, 'firstName': 'Wilbur', 'lastName': 'Adams', 'email': 'wilbur@app.activiti.com'},
{'id': 111, 'firstName': 'fake-first-name', 'lastName': 'fake-last-name', 'email': 'fake@app.activiti.com'}],
'involvedGroups': [{ 'id': 7007, 'name': 'group1', 'externalId': null, 'status': 'active', 'groups': null }],
'involvedPeople': [{ 'id': 1001, 'firstName': 'Wilbur', 'lastName': 'Adams', 'email': 'wilbur@app.activiti.com' },
{ 'id': 111, 'firstName': 'fake-first-name', 'lastName': 'fake-last-name', 'email': 'fake@app.activiti.com' }],
'managerOfCandidateGroup': true,
'memberOfCandidateGroup': true,
'memberOfCandidateUsers': true
@@ -167,7 +172,7 @@ export let taskDetailsWithOutCandidateGroup = new TaskDetailsModel({
'name': 'Request translation',
'description': null,
'category': null,
'assignee': {'id': 1001, 'firstName': 'Wilbur', 'lastName': 'Adams', 'email': 'wilbur@app.activiti.com'},
'assignee': { 'id': 1001, 'firstName': 'Wilbur', 'lastName': 'Adams', 'email': 'wilbur@app.activiti.com' },
'created': '2016-11-03T15:25:42.749+0000',
'dueDate': null,
'endDate': null,
@@ -183,8 +188,8 @@ export let taskDetailsWithOutCandidateGroup = new TaskDetailsModel({
'memberOfCandidateGroup': false,
'memberOfCandidateUsers': false,
'involvedGroups': [],
'involvedPeople': [{'id': 1001, 'firstName': 'Wilbur', 'lastName': 'Adams', 'email': 'wilbur@app.activiti.com'},
{'id': 111, 'firstName': 'fake-first-name', 'lastName': 'fake-last-name', 'email': 'fake@app.activiti.com'}]
'involvedPeople': [{ 'id': 1001, 'firstName': 'Wilbur', 'lastName': 'Adams', 'email': 'wilbur@app.activiti.com' },
{ 'id': 111, 'firstName': 'fake-first-name', 'lastName': 'fake-last-name', 'email': 'fake@app.activiti.com' }]
});
export let completedTaskDetailsMock = new TaskDetailsModel({
@@ -192,7 +197,7 @@ export let completedTaskDetailsMock = new TaskDetailsModel({
'name': 'Request translation',
'description': null,
'category': null,
'assignee': {'id': 1001, 'firstName': 'Wilbur', 'lastName': 'Adams', 'email': 'wilbur@app.activiti.com'},
'assignee': { 'id': 1001, 'firstName': 'Wilbur', 'lastName': 'Adams', 'email': 'wilbur@app.activiti.com' },
'created': '2016-11-03T15:25:42.749+0000',
'dueDate': null,
'endDate': '2016-11-03T15:25:42.749+0000',
@@ -282,7 +287,7 @@ export let taskFormMock = new TaskDetailsModel({
'className': null,
'params': {},
'dateDisplayFormat': null,
'layout': {'row': -1, 'column': -1, 'colspan': 1},
'layout': { 'row': -1, 'column': -1, 'colspan': 1 },
'sizeX': 1,
'sizeY': 1,
'row': -1,
@@ -308,19 +313,19 @@ export let taskFormMock = new TaskDetailsModel({
'regexPattern': null,
'optionType': null,
'hasEmptyValue': true,
'options': [{'id': 'empty', 'name': 'Choose one...'}, {'id': 'fr', 'name': 'French'}, {
'options': [{ 'id': 'empty', 'name': 'Choose one...' }, { 'id': 'fr', 'name': 'French' }, {
'id': 'de',
'name': 'German'
}, {'id': 'es', 'name': 'Spanish'}],
}, { 'id': 'es', 'name': 'Spanish' }],
'restUrl': null,
'restResponsePath': null,
'restIdProperty': null,
'restLabelProperty': null,
'tab': null,
'className': null,
'params': {'existingColspan': 1, 'maxColspan': 1},
'params': { 'existingColspan': 1, 'maxColspan': 1 },
'dateDisplayFormat': null,
'layout': {'row': -1, 'column': -1, 'colspan': 1},
'layout': { 'row': -1, 'column': -1, 'colspan': 1 },
'sizeX': 1,
'sizeY': 1,
'row': -1,
@@ -342,22 +347,11 @@ export let taskFormMock = new TaskDetailsModel({
'globalDateFormat': 'D-M-YYYY'
});
export let tasksMock = new TaskDetailsModel({
data: [
taskDetailsMock
]
});
export let tasksMock = [new TaskDetailsModel(taskDetailsMock)];
export let noDataMock = new TaskDetailsModel({
data: [{
'size': 1,
'total': 1,
'start': 0,
'data': [{
'id': 1005,
'message': 'example-message',
'created': '2017-10-06T11:54:53.443+0000',
'createdBy': {'id': 4004, 'firstName': 'gadget', 'lastName': 'inspector', 'email': 'gadget@inspector.com'}
}]
}]
});
export let noDataMock = [new TaskDetailsModel({
'id': 1005,
'message': 'example-message',
'created': '2017-10-06T11:54:53.443+0000',
'createdBy': { 'id': 4004, 'firstName': 'gadget', 'lastName': 'inspector', 'email': 'gadget@inspector.com' }
})];

View File

@@ -65,6 +65,11 @@ describe('StartFormComponent', () => {
spyOn(activitiContentService, 'applyAlfrescoNode').and.returnValue(Observable.of({ id: 1234 }));
});
afterEach(() => {
fixture.destroy();
TestBed.resetTestingModule();
});
it('should create instance of StartProcessInstanceComponent', () => {
expect(fixture.componentInstance instanceof StartProcessInstanceComponent).toBe(true, 'should create StartProcessInstanceComponent');
});
@@ -79,14 +84,16 @@ 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;
spyOn(component, 'loadStartProcess').and.callThrough();
component.processDefinitionName = 'My Process 1';
let change = new SimpleChange(null, 123, true);
component.ngOnChanges({ 'appId': change });
fixture.detectChanges();
fixture.whenStable().then(() => {
let startBtn = fixture.nativeElement.querySelector('#button-start');
expect(startBtn.disabled).toBe(false);
@@ -434,18 +441,17 @@ describe('StartFormComponent', () => {
});
}));
it('should emit start event when start select a process and add a name', async(() => {
let startSpy: jasmine.Spy = spyOn(component.start, 'emit');
it('should emit start event when start select a process and add a name', (done) => {
let disposableStart = component.start.subscribe(() => {
disposableStart.unsubscribe();
done();
});
component.selectedProcessDef = testProcessDefRepr;
component.name = 'my:Process';
component.startProcess();
fixture.detectChanges();
fixture.whenStable().then(() => {
let startButton = fixture.nativeElement.querySelector('#button-start');
startButton.click();
expect(startSpy).toHaveBeenCalled();
});
}));
});
it('should not emit start event when start the process without select a process and name', () => {
component.name = null;
@@ -472,17 +478,17 @@ describe('StartFormComponent', () => {
expect(startSpy).not.toHaveBeenCalled();
});
it('should able to start the process when the required fields are filled up', async(() => {
let startSpy: jasmine.Spy = spyOn(component.start, 'emit');
it('should able to start the process when the required fields are filled up', (done) => {
component.name = 'my:process1';
component.selectedProcessDef = testProcessDefRepr;
fixture.detectChanges();
fixture.whenStable().then(() => {
let startButton = fixture.nativeElement.querySelector('#button-start');
startButton.click();
expect(startSpy).toHaveBeenCalled();
let disposableStart = component.start.subscribe(() => {
disposableStart.unsubscribe();
done();
});
}));
component.startProcess();
});
it('should return true if startFrom defined', async(() => {
component.selectedProcessDef = testProcessDefRepr;

View File

@@ -21,19 +21,8 @@ import { TaskDetailsModel } from '../models/task-details.model';
import { ChecklistComponent } from './checklist.component';
import { setupTestBed } from '@alfresco/adf-core';
import { ProcessTestingModule } from '../../testing/process.testing.module';
declare let jasmine: any;
const fakeTaskDetail = new TaskDetailsModel({
id: 'fake-check-id',
name: 'fake-check-name'
});
const fakeTaskDetailCompleted = new TaskDetailsModel({
id: 'fake-completed-id',
name: 'fake-completed-name',
endDate: '2018-05-23T11:25:14.552+0000'
});
import { TaskListService } from './../services/tasklist.service';
import { Observable } from 'rxjs/Observable';
describe('ChecklistComponent', () => {
@@ -41,12 +30,16 @@ describe('ChecklistComponent', () => {
let fixture: ComponentFixture<ChecklistComponent>;
let element: HTMLElement;
let showChecklistDialog;
let service: TaskListService;
setupTestBed({
imports: [ProcessTestingModule]
});
beforeEach(async(() => {
service = TestBed.get(TaskListService);
spyOn(service, 'getTaskChecklist').and.returnValue(Observable.of([{ id: 'fake-check-changed-id', name: 'fake-check-changed-name' }] ));
fixture = TestBed.createComponent(ChecklistComponent);
checklistComponent = fixture.componentInstance;
element = fixture.nativeElement;
@@ -68,7 +61,10 @@ describe('ChecklistComponent', () => {
beforeEach(() => {
checklistComponent.taskId = 'fake-task-id';
checklistComponent.checklist.push(fakeTaskDetail);
checklistComponent.checklist.push(new TaskDetailsModel({
id: 'fake-check-id',
name: 'fake-check-name'
}));
checklistComponent.readOnly = true;
fixture.detectChanges();
@@ -89,7 +85,10 @@ describe('ChecklistComponent', () => {
beforeEach(() => {
checklistComponent.taskId = 'fake-task-id';
checklistComponent.readOnly = false;
checklistComponent.checklist.push(fakeTaskDetail);
checklistComponent.checklist.push(new TaskDetailsModel({
id: 'fake-check-id',
name: 'fake-check-name'
}));
fixture.detectChanges();
showChecklistDialog = <HTMLElement> element.querySelector('#add-checklist');
@@ -133,12 +132,7 @@ describe('ChecklistComponent', () => {
showChecklistDialog = <HTMLElement> element.querySelector('#add-checklist');
});
beforeEach(() => {
jasmine.Ajax.install();
});
afterEach(() => {
jasmine.Ajax.uninstall();
const overlayContainers = <any> window.document.querySelectorAll('.cdk-overlay-container');
overlayContainers.forEach((overlayContainer) => {
overlayContainer.innerHTML = '';
@@ -146,15 +140,25 @@ describe('ChecklistComponent', () => {
});
it('should show task checklist', () => {
checklistComponent.checklist.push(fakeTaskDetail);
checklistComponent.checklist.push(new TaskDetailsModel({
id: 'fake-check-id',
name: 'fake-check-name'
}));
fixture.detectChanges();
expect(element.querySelector('#check-fake-check-id')).not.toBeNull();
expect(element.querySelector('#check-fake-check-id').textContent).toContain('fake-check-name');
});
it('should not show delete icon when checklist task is completed', () => {
checklistComponent.checklist.push(fakeTaskDetail);
checklistComponent.checklist.push(fakeTaskDetailCompleted);
checklistComponent.checklist.push(new TaskDetailsModel({
id: 'fake-check-id',
name: 'fake-check-name'
}));
checklistComponent.checklist.push(new TaskDetailsModel({
id: 'fake-completed-id',
name: 'fake-completed-name',
endDate: '2018-05-23T11:25:14.552+0000'
}));
fixture.detectChanges();
expect(element.querySelector('#remove-fake-check-id')).not.toBeNull();
expect(element.querySelector('#check-fake-completed-id')).not.toBeNull();
@@ -163,14 +167,14 @@ describe('ChecklistComponent', () => {
});
it('should add checklist', async(() => {
spyOn(service, 'addTask').and.returnValue(Observable.of({
id: 'fake-check-added-id', name: 'fake-check-added-name'
}));
showChecklistDialog.click();
let addButtonDialog = <HTMLElement> window.document.querySelector('#add-check');
addButtonDialog.click();
jasmine.Ajax.requests.mostRecent().respondWith({
status: 200,
contentType: 'json',
responseText: { id: 'fake-check-added-id', name: 'fake-check-added-name' }
});
fixture.whenStable().then(() => {
fixture.detectChanges();
expect(element.querySelector('#check-fake-check-added-id')).not.toBeNull();
@@ -179,17 +183,19 @@ describe('ChecklistComponent', () => {
}));
it('should remove a checklist element', async(() => {
spyOn(service, 'deleteTask').and.returnValue(Observable.of(''));
checklistComponent.taskId = 'new-fake-task-id';
checklistComponent.checklist.push(fakeTaskDetail);
checklistComponent.checklist.push(new TaskDetailsModel({
id: 'fake-check-id',
name: 'fake-check-name'
}));
fixture.detectChanges();
let checklistElementRemove = <HTMLElement> element.querySelector('#remove-fake-check-id');
expect(checklistElementRemove).toBeDefined();
expect(checklistElementRemove).not.toBeNull();
checklistElementRemove.click();
jasmine.Ajax.requests.mostRecent().respondWith({
status: 200,
contentType: 'json'
});
fixture.whenStable().then(() => {
fixture.detectChanges();
expect(element.querySelector('#fake-check-id')).toBeNull();
@@ -197,36 +203,38 @@ describe('ChecklistComponent', () => {
}));
it('should send an event when the checklist is deleted', (done) => {
spyOn(service, 'deleteTask').and.returnValue(Observable.of(''));
let disposableDelete = checklistComponent.checklistTaskDeleted.subscribe(() => {
expect(element.querySelector('#fake-check-id')).toBeNull();
disposableDelete.unsubscribe();
done();
});
checklistComponent.taskId = 'new-fake-task-id';
checklistComponent.checklist.push(fakeTaskDetail);
checklistComponent.checklist.push(new TaskDetailsModel({
id: 'fake-check-id',
name: 'fake-check-name'
}));
fixture.detectChanges();
let checklistElementRemove = <HTMLElement> element.querySelector('#remove-fake-check-id');
expect(checklistElementRemove).toBeDefined();
expect(checklistElementRemove).not.toBeNull();
checklistElementRemove.click();
jasmine.Ajax.requests.mostRecent().respondWith({
status: 200,
contentType: 'json'
});
checklistComponent.checklistTaskDeleted.subscribe(() => {
expect(element.querySelector('#fake-check-id')).toBeNull();
done();
});
});
it('should show load task checklist on change', async(() => {
checklistComponent.taskId = 'new-fake-task-id';
checklistComponent.checklist.push(fakeTaskDetail);
checklistComponent.checklist.push(new TaskDetailsModel({
id: 'fake-check-id',
name: 'fake-check-name'
}));
fixture.detectChanges();
let change = new SimpleChange(null, 'new-fake-task-id', true);
checklistComponent.ngOnChanges({
taskId: change
});
jasmine.Ajax.requests.mostRecent().respondWith({
status: 200,
contentType: 'json',
responseText: { data: [{ id: 'fake-check-changed-id', name: 'fake-check-changed-name' }] }
});
fixture.whenStable().then(() => {
fixture.detectChanges();
expect(element.querySelector('#check-fake-check-changed-id')).not.toBeNull();
@@ -236,7 +244,10 @@ describe('ChecklistComponent', () => {
it('should show empty checklist when task id is null', async(() => {
checklistComponent.taskId = 'new-fake-task-id';
checklistComponent.checklist.push(fakeTaskDetail);
checklistComponent.checklist.push(new TaskDetailsModel({
id: 'fake-check-id',
name: 'fake-check-name'
}));
fixture.detectChanges();
checklistComponent.taskId = null;
let change = new SimpleChange(null, 'new-fake-task-id', true);
@@ -251,22 +262,20 @@ describe('ChecklistComponent', () => {
}));
it('should emit checklist task created event when the checklist is successfully added', (done) => {
checklistComponent.checklistTaskCreated.subscribe((taskAdded: TaskDetailsModel) => {
spyOn(service, 'addTask').and.returnValue(Observable.of({ id: 'fake-check-added-id', name: 'fake-check-added-name' }));
let disposableCreated = checklistComponent.checklistTaskCreated.subscribe((taskAdded: TaskDetailsModel) => {
fixture.detectChanges();
expect(taskAdded.id).toEqual('fake-check-added-id');
expect(taskAdded.name).toEqual('fake-check-added-name');
expect(element.querySelector('#check-fake-check-added-id')).not.toBeNull();
expect(element.querySelector('#check-fake-check-added-id').textContent).toContain('fake-check-added-name');
disposableCreated.unsubscribe();
done();
});
showChecklistDialog.click();
let addButtonDialog = <HTMLElement> window.document.querySelector('#add-check');
addButtonDialog.click();
jasmine.Ajax.requests.mostRecent().respondWith({
status: 200,
contentType: 'json',
responseText: { id: 'fake-check-added-id', name: 'fake-check-added-name' }
});
});
});

View File

@@ -15,20 +15,17 @@
* limitations under the License.
*/
import { Component, EventEmitter, Input, OnChanges, OnInit, Output, SimpleChanges, ViewChild } from '@angular/core';
import { Component, EventEmitter, Input, OnChanges, Output, SimpleChanges, ViewChild } from '@angular/core';
import { MatDialog } from '@angular/material';
import { Observable } from 'rxjs/Observable';
import { Observer } from 'rxjs/Observer';
import { TaskDetailsModel } from '../models/task-details.model';
import { TaskListService } from './../services/tasklist.service';
@Component({
selector: 'adf-checklist',
templateUrl: './checklist.component.html',
styleUrls: ['./checklist.component.scss'],
providers: [TaskListService]
styleUrls: ['./checklist.component.scss']
})
export class ChecklistComponent implements OnInit, OnChanges {
export class ChecklistComponent implements OnChanges {
/** (required) The id of the parent task to which subtasks are
* attached.
@@ -50,7 +47,7 @@ export class ChecklistComponent implements OnInit, OnChanges {
@Output()
checklistTaskCreated: EventEmitter<TaskDetailsModel> = new EventEmitter<TaskDetailsModel>();
/** Emitted when a checklist task is deleted. */
/** Emitted when a checklitst task is deleted. */
@Output()
checklistTaskDeleted: EventEmitter<string> = new EventEmitter<string>();
@@ -65,25 +62,13 @@ export class ChecklistComponent implements OnInit, OnChanges {
checklist: TaskDetailsModel [] = [];
private taskObserver: Observer<TaskDetailsModel>;
task$: Observable<TaskDetailsModel>;
/**
* Constructor
* @param auth
* @param translate
*/
constructor(
private activitiTaskList: TaskListService,
private dialog: MatDialog
) {
this.task$ = new Observable<TaskDetailsModel>(observer => this.taskObserver = observer).share();
}
ngOnInit() {
this.task$.subscribe((task: TaskDetailsModel) => {
this.checklist.push(task);
});
constructor(private activitiTaskList: TaskListService,
private dialog: MatDialog) {
}
ngOnChanges(changes: SimpleChanges) {
@@ -98,9 +83,9 @@ export class ChecklistComponent implements OnInit, OnChanges {
this.checklist = [];
if (this.taskId) {
this.activitiTaskList.getTaskChecklist(this.taskId).subscribe(
(res: TaskDetailsModel[]) => {
res.forEach((task) => {
this.taskObserver.next(task);
(taskDetailsModel: TaskDetailsModel[]) => {
taskDetailsModel.forEach((task) => {
this.checklist.push(task);
});
},
(error) => {
@@ -148,9 +133,6 @@ export class ChecklistComponent implements OnInit, OnChanges {
public cancel() {
this.dialog.closeAll();
// if (this.addNewDialog) {
// this.addNewDialog.nativeElement.close();
// }
this.taskName = '';
}
}

View File

@@ -21,7 +21,6 @@ import { Observable } from 'rxjs/Observable';
import { startTaskMock } from '../../mock';
import { StartTaskModel } from '../models/start-task.model';
import { TaskListService } from '../services/tasklist.service';
import { } from './../assets/start-task.mock';
import { StartTaskComponent } from './start-task.component';
import { ProcessTestingModule } from '../../testing/process.testing.module';
@@ -49,23 +48,6 @@ describe('StartTaskComponent', () => {
imports: [ProcessTestingModule]
});
// beforeEach(async(() => {
// TestBed.configureTestingModule({
// declarations: [
// StartTaskComponent,
// PeopleSearchFieldComponent,
// PeopleListComponent,
// PeopleSelectorComponent
// ],
// providers: [
// TaskListService,
// { provide: TranslationService, useClass: TranslationMock }
// ]
// }).compileComponents().then(() => {
// });
// }));
beforeEach(async(() => {
fixture = TestBed.createComponent(StartTaskComponent);
component = fixture.componentInstance;

View File

@@ -267,7 +267,7 @@ describe('TaskDetailsComponent', () => {
});
it('should show placeholder message if there is no next task', () => {
getTasksSpy.and.returnValue(Observable.of(noDataMock));
getTasksSpy.and.returnValue(Observable.of([]));
component.onComplete();
fixture.detectChanges();
expect(fixture.nativeElement.innerText).toBe('ADF_TASK_LIST.DETAILS.MESSAGES.NONE');

View File

@@ -659,7 +659,6 @@ class EmptyTemplateComponent {
}
describe('Custom EmptyTemplateComponent', () => {
let component: EmptyTemplateComponent;
let fixture: ComponentFixture<EmptyTemplateComponent>;
setupTestBed({
@@ -671,7 +670,6 @@ describe('Custom EmptyTemplateComponent', () => {
beforeEach(() => {
fixture = TestBed.createComponent(EmptyTemplateComponent);
fixture.detectChanges();
component = fixture.componentInstance;
});
it('should render the custom template', async(() => {

View File

@@ -27,7 +27,6 @@ import {
fakeRepresentationFilter2,
fakeTaskDetails,
fakeTaskList,
fakeTaskListDifferentProcessDefinitionKey,
fakeTasksChecklist,
fakeUser1,
fakeUser2,