mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-31 17:38:48 +00:00
[ADF-1088] Task Header in TaskDetails component shows Assignee but is not editable (#2176)
* added translate keyword for assignee header * changed people-search component to change the header according to filter type * changed tash-header component to make assignee clickable * imlemented people-search component to assign the task to new user * added handler for assign task to new user * added testcase for assign task to user * changed mdl textbox to angular material * changed button to md and fixed issues in testcase after changed md * changed property for people-search component * added ng-content selector to pass header text and action button text and removed property from people-search component * added no_error_schema to fix testcase issue in people component * fixed no-task-details component test case bug * added people-search component in read me
This commit is contained in:
committed by
Mario Romano
parent
ecc6aecd80
commit
5ad4fe171a
@@ -17,18 +17,30 @@
|
||||
|
||||
import { NO_ERRORS_SCHEMA, SimpleChange } from '@angular/core';
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { MdButtonModule, MdInputModule } from '@angular/material';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { Observable } from 'rxjs/Rx';
|
||||
|
||||
import { ActivitiFormModule, FormModel, FormOutcomeEvent, FormOutcomeModel, FormService } from 'ng2-activiti-form';
|
||||
import { AlfrescoTranslationService, CoreModule } from 'ng2-alfresco-core';
|
||||
import { AlfrescoTranslationService, CoreModule, LogService } from 'ng2-alfresco-core';
|
||||
|
||||
import { TaskDetailsModel } from '../models/task-details.model';
|
||||
import { User } from '../models/user.model';
|
||||
import { noDataMock, taskDetailsMock, taskFormMock, tasksMock } from './../assets/task-details.mock';
|
||||
import { PeopleService } from './../services/people.service';
|
||||
import { TaskListService } from './../services/tasklist.service';
|
||||
import { PeopleSearchComponent } from './people-search.component';
|
||||
import { TaskDetailsComponent } from './task-details.component';
|
||||
|
||||
declare let jasmine: any;
|
||||
|
||||
const fakeUser: User = new User({
|
||||
id: 'fake-id',
|
||||
firstName: 'fake-name',
|
||||
lastName: 'fake-last',
|
||||
email: 'fake@mail.com'
|
||||
});
|
||||
|
||||
describe('TaskDetailsComponent', () => {
|
||||
|
||||
let componentHandler: any;
|
||||
@@ -39,17 +51,22 @@ describe('TaskDetailsComponent', () => {
|
||||
let getTaskDetailsSpy: jasmine.Spy;
|
||||
let getFormSpy: jasmine.Spy;
|
||||
let getTasksSpy: jasmine.Spy;
|
||||
let assignTaskSpy: jasmine.Spy;
|
||||
let getFormTaskSpy: jasmine.Spy;
|
||||
let completeTaskSpy: jasmine.Spy;
|
||||
let logService: LogService;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [
|
||||
CoreModule.forRoot(),
|
||||
ActivitiFormModule.forRoot()
|
||||
ActivitiFormModule.forRoot(),
|
||||
MdButtonModule,
|
||||
MdInputModule
|
||||
],
|
||||
declarations: [
|
||||
TaskDetailsComponent
|
||||
TaskDetailsComponent,
|
||||
PeopleSearchComponent
|
||||
],
|
||||
providers: [
|
||||
TaskListService,
|
||||
@@ -58,6 +75,7 @@ describe('TaskDetailsComponent', () => {
|
||||
schemas: [ NO_ERRORS_SCHEMA ]
|
||||
}).compileComponents();
|
||||
|
||||
logService = TestBed.get(LogService);
|
||||
let translateService = TestBed.get(AlfrescoTranslationService);
|
||||
spyOn(translateService, 'addTranslationFolder').and.stub();
|
||||
spyOn(translateService.translate, 'get').and.callFake((key) => { return Observable.of(key); });
|
||||
@@ -76,6 +94,7 @@ describe('TaskDetailsComponent', () => {
|
||||
getFormTaskSpy = spyOn(formService, 'getTask').and.returnValue(Observable.of(taskDetailsMock));
|
||||
|
||||
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, 'getComments').and.returnValue(Observable.of(noDataMock));
|
||||
spyOn(service, 'getTaskChecklist').and.returnValue(Observable.of(noDataMock));
|
||||
@@ -260,4 +279,77 @@ describe('TaskDetailsComponent', () => {
|
||||
|
||||
});
|
||||
|
||||
describe('assign task to user', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
component.taskId = '123';
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
jasmine.Ajax.install();
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
jasmine.Ajax.uninstall();
|
||||
});
|
||||
|
||||
it('should return an observable with user search results', (done) => {
|
||||
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');
|
||||
expect(users[0].email).toBe('fake-test-1@test.com');
|
||||
expect(users[0].id).toBe(1);
|
||||
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) => {
|
||||
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(() => {
|
||||
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', () => {
|
||||
component.assignTaskToUser(fakeUser);
|
||||
expect(assignTaskSpy).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
Reference in New Issue
Block a user