mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ADF-3499] Make Card View Text Item reactive to user input (#5953)
* [ADF-3499] Make Card View Text Item reactive to user input * Improve code and fix APS2 tests * Fix tests * Improve tests * Add missing async
This commit is contained in:
@@ -19,7 +19,7 @@ import { TaskHeaderCloudComponent } from './task-header-cloud.component';
|
||||
import { of, throwError } from 'rxjs';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { ComponentFixture, TestBed, async } from '@angular/core/testing';
|
||||
import { setupTestBed, AppConfigService } from '@alfresco/adf-core';
|
||||
import { setupTestBed, AppConfigService, AlfrescoApiService } from '@alfresco/adf-core';
|
||||
import { ProcessServiceCloudTestingModule } from '../../../testing/process-service-cloud.testing.module';
|
||||
import { TaskCloudService } from '../../services/task-cloud.service';
|
||||
import { TaskHeaderCloudModule } from '../task-header-cloud.module';
|
||||
@@ -43,10 +43,17 @@ describe('TaskHeaderCloudComponent', () => {
|
||||
let getCandidateGroupsSpy: jasmine.Spy;
|
||||
let getCandidateUsersSpy: jasmine.Spy;
|
||||
let isTaskEditableSpy: jasmine.Spy;
|
||||
let alfrescoApiService: AlfrescoApiService;
|
||||
|
||||
const mockCandidateUsers = ['mockuser1', 'mockuser2', 'mockuser3'];
|
||||
const mockCandidateGroups = ['mockgroup1', 'mockgroup2', 'mockgroup3'];
|
||||
|
||||
const mock = {
|
||||
oauth2Auth: {
|
||||
callCustomApi: () => Promise.resolve({})
|
||||
}
|
||||
};
|
||||
|
||||
setupTestBed({
|
||||
imports: [
|
||||
TranslateModule.forRoot(),
|
||||
@@ -60,14 +67,20 @@ describe('TaskHeaderCloudComponent', () => {
|
||||
component = fixture.componentInstance;
|
||||
appConfigService = TestBed.inject(AppConfigService);
|
||||
taskCloudService = TestBed.inject(TaskCloudService);
|
||||
alfrescoApiService = TestBed.inject(AlfrescoApiService);
|
||||
component.appName = 'mock-app-name';
|
||||
component.taskId = 'mock-task-id';
|
||||
spyOn(alfrescoApiService, 'getInstance').and.returnValue(mock);
|
||||
getTaskByIdSpy = spyOn(taskCloudService, 'getTaskById').and.returnValue(of(assignedTaskDetailsCloudMock));
|
||||
isTaskEditableSpy = spyOn(taskCloudService, 'isTaskEditable').and.returnValue(true);
|
||||
getCandidateUsersSpy = spyOn(taskCloudService, 'getCandidateUsers').and.returnValue(of(mockCandidateUsers));
|
||||
getCandidateGroupsSpy = spyOn(taskCloudService, 'getCandidateGroups').and.returnValue(of(mockCandidateGroups));
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
fixture.destroy();
|
||||
});
|
||||
|
||||
describe('Task Details', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
@@ -86,121 +99,116 @@ describe('TaskHeaderCloudComponent', () => {
|
||||
expect(taskTitle).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should fectch task details when appName and taskId defined', async(() => {
|
||||
it('should fectch task details when appName and taskId defined', async () => {
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
expect(getTaskByIdSpy).toHaveBeenCalled();
|
||||
expect(component.taskDetails).toBe(assignedTaskDetailsCloudMock);
|
||||
});
|
||||
}));
|
||||
await fixture.whenStable();
|
||||
expect(getTaskByIdSpy).toHaveBeenCalled();
|
||||
expect(component.taskDetails).toBe(assignedTaskDetailsCloudMock);
|
||||
|
||||
it('should display assignee', async(() => {
|
||||
});
|
||||
|
||||
it('should display assignee', async () => {
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
const assigneeEl = fixture.debugElement.query(By.css('[data-automation-id="card-textitem-value-assignee"]'));
|
||||
expect(assigneeEl.nativeElement.value).toBe('AssignedTaskUser');
|
||||
});
|
||||
}));
|
||||
await fixture.whenStable();
|
||||
const assigneeEl = fixture.debugElement.query(By.css('[data-automation-id="card-textitem-value-assignee"]'));
|
||||
expect(assigneeEl.nativeElement.value).toBe('AssignedTaskUser');
|
||||
});
|
||||
|
||||
it('should display status', async(() => {
|
||||
it('should display status', async () => {
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
const statusEl = fixture.debugElement.query(By.css('[data-automation-id="card-textitem-value-status"]'));
|
||||
expect(statusEl.nativeElement.value).toBe('ASSIGNED');
|
||||
});
|
||||
}));
|
||||
await fixture.whenStable();
|
||||
fixture.detectChanges();
|
||||
const statusEl = fixture.debugElement.query(By.css('[data-automation-id="card-textitem-value-status"]'));
|
||||
expect(statusEl.nativeElement.value).toBe('ASSIGNED');
|
||||
});
|
||||
|
||||
it('should display priority', async(() => {
|
||||
it('should display priority', async () => {
|
||||
fixture.detectChanges();
|
||||
|
||||
fixture.whenStable().then(() => {
|
||||
const priorityEl = fixture.debugElement.query(By.css('[data-automation-id="card-textitem-value-priority"]'));
|
||||
expect(priorityEl.nativeElement.value).toBe('5');
|
||||
});
|
||||
}));
|
||||
await fixture.whenStable();
|
||||
fixture.detectChanges();
|
||||
const priorityEl = fixture.debugElement.query(By.css('[data-automation-id="card-textitem-value-priority"]'));
|
||||
expect(priorityEl.nativeElement.value).toBe('5');
|
||||
});
|
||||
|
||||
it('should display error if priority is not a number', async(() => {
|
||||
it('should display error if priority is not a number', async (done) => {
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
fixture.detectChanges();
|
||||
|
||||
fixture.whenStable().then(() => {
|
||||
const formPriorityEl = fixture.debugElement.query(By.css('[data-automation-id="card-textitem-value-priority"]'));
|
||||
formPriorityEl.nativeElement.value = 'stringValue';
|
||||
formPriorityEl.nativeElement.dispatchEvent(new Event('input'));
|
||||
|
||||
const formPriorityEl = fixture.debugElement.query(By.css('[data-automation-id="card-textitem-value-priority"]'));
|
||||
formPriorityEl.nativeElement.value = 'stringValue';
|
||||
formPriorityEl.nativeElement.dispatchEvent(new Event('input'));
|
||||
formPriorityEl.nativeElement.dispatchEvent(new Event('blur'));
|
||||
fixture.detectChanges();
|
||||
|
||||
const errorMessageEl = fixture.debugElement.query(By.css('[data-automation-id="card-textitem-error-priority"]'));
|
||||
expect(errorMessageEl).not.toBeNull();
|
||||
});
|
||||
}));
|
||||
|
||||
it('should display due date', async(() => {
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
fixture.detectChanges();
|
||||
|
||||
fixture.whenStable().then(() => {
|
||||
const valueEl = fixture.debugElement.query(By.css('[data-automation-id="header-dueDate"] .adf-property-value'));
|
||||
expect(valueEl.nativeElement.innerText.trim()).toBe(moment(assignedTaskDetailsCloudMock.dueDate, 'x').format('MMM D, Y, H:mm'));
|
||||
});
|
||||
}));
|
||||
const errorMessageEl = fixture.debugElement.query(By.css('[data-automation-id="card-textitem-error-priority"]'));
|
||||
expect(errorMessageEl).not.toBeNull();
|
||||
done();
|
||||
|
||||
it('should display placeholder if no due date', async(() => {
|
||||
});
|
||||
|
||||
it('should display due date', async () => {
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
fixture.detectChanges();
|
||||
|
||||
const valueEl = fixture.debugElement.query(By.css('[data-automation-id="header-dueDate"] .adf-property-value'));
|
||||
expect(valueEl.nativeElement.innerText.trim()).toBe(moment(assignedTaskDetailsCloudMock.dueDate, 'x').format('MMM D, Y, H:mm'));
|
||||
});
|
||||
|
||||
it('should display placeholder if no due date', async () => {
|
||||
component.taskDetails.dueDate = null;
|
||||
component.refreshData();
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
const valueEl = fixture.debugElement.query(By.css('[data-automation-id="header-dueDate"] .adf-property-value'));
|
||||
expect(valueEl.nativeElement.innerText.trim()).toBe('ADF_CLOUD_TASK_HEADER.PROPERTIES.DUE_DATE_DEFAULT');
|
||||
});
|
||||
|
||||
fixture.whenStable().then(() => {
|
||||
const valueEl = fixture.debugElement.query(By.css('[data-automation-id="header-dueDate"] .adf-property-value'));
|
||||
expect(valueEl.nativeElement.innerText.trim()).toBe('ADF_CLOUD_TASK_HEADER.PROPERTIES.DUE_DATE_DEFAULT');
|
||||
});
|
||||
}));
|
||||
|
||||
it('should display the default parent value if is undefined', async(() => {
|
||||
it('should display the default parent value if is undefined', async () => {
|
||||
component.taskDetails.processInstanceId = null;
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
const valueEl = fixture.debugElement.query(By.css('[data-automation-id="header-parentName"] input'));
|
||||
expect(valueEl.nativeElement.value).toEqual('ADF_CLOUD_TASK_HEADER.PROPERTIES.PARENT_NAME_DEFAULT');
|
||||
});
|
||||
|
||||
fixture.whenStable().then(() => {
|
||||
const valueEl = fixture.debugElement.query(By.css('[data-automation-id="header-parentName"] input'));
|
||||
expect(valueEl.nativeElement.value).toEqual('ADF_CLOUD_TASK_HEADER.PROPERTIES.PARENT_NAME_DEFAULT');
|
||||
});
|
||||
}));
|
||||
|
||||
it('should be able to call update service on updating task description', async(() => {
|
||||
it('should be able to call update service on updating task description', async (done) => {
|
||||
spyOn(taskCloudService, 'updateTask').and.returnValue(of(assignedTaskDetailsCloudMock));
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
await fixture.whenStable();
|
||||
fixture.detectChanges();
|
||||
const inputEl = fixture.debugElement.query(By.css('[data-automation-id="card-textitem-value-description"]'));
|
||||
inputEl.nativeElement.value = 'updated description';
|
||||
inputEl.nativeElement.dispatchEvent(new Event('input'));
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
fixture.detectChanges();
|
||||
expect(taskCloudService.updateTask).toHaveBeenCalled();
|
||||
done();
|
||||
});
|
||||
|
||||
const inputEl = fixture.debugElement.query(By.css('[data-automation-id="card-textitem-value-description"]'));
|
||||
inputEl.nativeElement.value = 'updated description';
|
||||
inputEl.nativeElement.dispatchEvent(new Event('input'));
|
||||
inputEl.nativeElement.dispatchEvent(new Event('blur'));
|
||||
|
||||
fixture.detectChanges();
|
||||
expect(taskCloudService.updateTask).toHaveBeenCalled();
|
||||
});
|
||||
}));
|
||||
|
||||
it('should roll back task description on error', async () => {
|
||||
it('should roll back task description on error', async(async () => {
|
||||
spyOn(taskCloudService, 'updateTask').and.returnValue(throwError('fake'));
|
||||
fixture.detectChanges();
|
||||
|
||||
await fixture.whenStable();
|
||||
fixture.detectChanges();
|
||||
let description = fixture.debugElement.query(By.css('[data-automation-id="card-textitem-value-description"]'));
|
||||
expect(description.nativeElement.value.trim()).toEqual('This is the description');
|
||||
|
||||
const inputEl = fixture.debugElement.query(By.css('[data-automation-id="card-textitem-value-description"]'));
|
||||
inputEl.nativeElement.value = 'updated description';
|
||||
inputEl.nativeElement.dispatchEvent(new Event('input'));
|
||||
inputEl.nativeElement.dispatchEvent(new Event('blur'));
|
||||
|
||||
fixture.detectChanges();
|
||||
expect(taskCloudService.updateTask).toHaveBeenCalled();
|
||||
|
||||
await fixture.whenStable();
|
||||
fixture.detectChanges();
|
||||
description = fixture.debugElement.query(By.css('[data-automation-id="card-textitem-value-description"]'));
|
||||
expect(description.nativeElement.value.trim()).toEqual('This is the description');
|
||||
});
|
||||
expect(taskCloudService.updateTask).toHaveBeenCalled();
|
||||
}));
|
||||
|
||||
it('should show loading spinner when properties are not loaded', () => {
|
||||
component.properties = null;
|
||||
@@ -217,28 +225,25 @@ describe('TaskHeaderCloudComponent', () => {
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('should fectch parent task details if the task has parent id', async(() => {
|
||||
it('should fectch parent task details if the task has parent id', async () => {
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
expect(getTaskByIdSpy).toHaveBeenCalledTimes(2);
|
||||
});
|
||||
}));
|
||||
await fixture.whenStable();
|
||||
expect(getTaskByIdSpy).toHaveBeenCalledTimes(2);
|
||||
});
|
||||
|
||||
it('should display parent task id', async(() => {
|
||||
it('should display parent task id', async () => {
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
const assigneeEl = fixture.debugElement.query(By.css('[data-automation-id="card-textitem-value-parentTaskId"'));
|
||||
expect(assigneeEl.nativeElement.value).toBe('mock-parent-task-id');
|
||||
});
|
||||
}));
|
||||
await fixture.whenStable();
|
||||
const assigneeEl = fixture.debugElement.query(By.css('[data-automation-id="card-textitem-value-parentTaskId"'));
|
||||
expect(assigneeEl.nativeElement.value).toBe('mock-parent-task-id');
|
||||
});
|
||||
|
||||
it('should display parent task name', async(() => {
|
||||
it('should display parent task name', async () => {
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
const statusEl = fixture.debugElement.query(By.css('[data-automation-id="card-textitem-value-parentName"]'));
|
||||
expect(statusEl.nativeElement.value.trim()).toBe('This is a parent task name');
|
||||
});
|
||||
}));
|
||||
await fixture.whenStable();
|
||||
const statusEl = fixture.debugElement.query(By.css('[data-automation-id="card-textitem-value-parentName"]'));
|
||||
expect(statusEl.nativeElement.value.trim()).toBe('This is a parent task name');
|
||||
});
|
||||
});
|
||||
|
||||
describe('Assigned Task', () => {
|
||||
@@ -248,25 +253,24 @@ describe('TaskHeaderCloudComponent', () => {
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('should display assignee', async(() => {
|
||||
it('should display assignee', async () => {
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
const assigneeEl = fixture.debugElement.query(By.css('[data-automation-id="card-textitem-value-assignee"]'));
|
||||
expect(assigneeEl.nativeElement.value).toBe('AssignedTaskUser');
|
||||
});
|
||||
}));
|
||||
|
||||
it('should display status', async(() => {
|
||||
await fixture.whenStable();
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
const statusEl = fixture.debugElement.query(By.css('[data-automation-id="card-textitem-value-status"]'));
|
||||
expect(statusEl.nativeElement.value).toBe('ASSIGNED');
|
||||
});
|
||||
}));
|
||||
const assigneeEl = fixture.debugElement.query(By.css('[data-automation-id="card-textitem-value-assignee"]'));
|
||||
expect(assigneeEl.nativeElement.value).toBe('AssignedTaskUser');
|
||||
});
|
||||
|
||||
it('should render defined edit icon for assignee property if the task in assigned state and shared among candidates', () => {
|
||||
it('should display status', async () => {
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
const statusEl = fixture.debugElement.query(By.css('[data-automation-id="card-textitem-value-status"]'));
|
||||
expect(statusEl.nativeElement.value).toBe('ASSIGNED');
|
||||
});
|
||||
|
||||
it('should render defined edit icon for assignee property if the task in assigned state and shared among candidates', async () => {
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
const value = fixture.debugElement.query(By.css(`[data-automation-id="header-assignee"] [data-automation-id="card-textitem-clickable-icon-assignee"]`));
|
||||
expect(value).not.toBeNull();
|
||||
expect(value.nativeElement.innerText).toBe('create');
|
||||
@@ -321,21 +325,21 @@ describe('TaskHeaderCloudComponent', () => {
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('should display status', async(() => {
|
||||
it('should display status', async () => {
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
const statusEl = fixture.debugElement.query(By.css('[data-automation-id="card-textitem-value-status"]'));
|
||||
expect(statusEl.nativeElement.value).toBe('CREATED');
|
||||
});
|
||||
}));
|
||||
await fixture.whenStable();
|
||||
fixture.detectChanges();
|
||||
const statusEl = fixture.debugElement.query(By.css('[data-automation-id="card-textitem-value-status"]'));
|
||||
expect(statusEl.nativeElement.value).toBe('CREATED');
|
||||
});
|
||||
|
||||
it('should display placeholder if no assignee', async(() => {
|
||||
it('should display placeholder if no assignee', async () => {
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
const assigneeEl = fixture.debugElement.query(By.css('[data-automation-id="card-textitem-value-assignee"]'));
|
||||
expect(assigneeEl.nativeElement.value).toBe('ADF_CLOUD_TASK_HEADER.PROPERTIES.ASSIGNEE_DEFAULT');
|
||||
});
|
||||
}));
|
||||
await fixture.whenStable();
|
||||
fixture.detectChanges();
|
||||
const assigneeEl = fixture.debugElement.query(By.css('[data-automation-id="card-textitem-value-assignee"]'));
|
||||
expect(assigneeEl.nativeElement.value).toBe('ADF_CLOUD_TASK_HEADER.PROPERTIES.ASSIGNEE_DEFAULT');
|
||||
});
|
||||
|
||||
it('should not render defined clickable edit icon for assignee property if the task in created state and not assigned', () => {
|
||||
fixture.detectChanges();
|
||||
@@ -362,13 +366,12 @@ describe('TaskHeaderCloudComponent', () => {
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('should display status', async(() => {
|
||||
it('should display status', async () => {
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
const statusEl = fixture.debugElement.query(By.css('[data-automation-id="card-textitem-value-status"]'));
|
||||
expect(statusEl.nativeElement.value).toBe('COMPLETED');
|
||||
});
|
||||
}));
|
||||
await fixture.whenStable();
|
||||
const statusEl = fixture.debugElement.query(By.css('[data-automation-id="card-textitem-value-status"]'));
|
||||
expect(statusEl.nativeElement.value).toBe('COMPLETED');
|
||||
});
|
||||
|
||||
it('should not render defined clickable edit icon for assignee property if the task in completed state', () => {
|
||||
fixture.detectChanges();
|
||||
@@ -382,7 +385,7 @@ describe('TaskHeaderCloudComponent', () => {
|
||||
const descriptionEditIcon = fixture.debugElement.query(By.css(`[data-automation-id="card-textitem-edit-icon-description"]`));
|
||||
const dueDateEditIcon = fixture.debugElement.query(By.css(`[data-automation-id="datepickertoggle-dueDate"]`));
|
||||
expect(priorityEditIcon).toBeNull('Edit icon should NOT be shown');
|
||||
expect(descriptionEditIcon).toBeNull('Edit icon should NOT be shown');
|
||||
expect(descriptionEditIcon).toBeNull('Edit icon shouaaa`zld NOT be shown');
|
||||
expect(dueDateEditIcon).toBeNull('Edit icon should NOT be shown');
|
||||
});
|
||||
});
|
||||
@@ -395,13 +398,12 @@ describe('TaskHeaderCloudComponent', () => {
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('should display status', async(() => {
|
||||
it('should display status', async () => {
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
const statusEl = fixture.debugElement.query(By.css('[data-automation-id="card-textitem-value-status"]'));
|
||||
expect(statusEl.nativeElement.value).toBe('SUSPENDED');
|
||||
});
|
||||
}));
|
||||
await fixture.whenStable();
|
||||
const statusEl = fixture.debugElement.query(By.css('[data-automation-id="card-textitem-value-status"]'));
|
||||
expect(statusEl.nativeElement.value).toBe('SUSPENDED');
|
||||
});
|
||||
|
||||
it('should not render defined clickable edit icon for assignee property if the task in suspended state', () => {
|
||||
fixture.detectChanges();
|
||||
@@ -422,93 +424,86 @@ describe('TaskHeaderCloudComponent', () => {
|
||||
|
||||
describe('Task with candidates', () => {
|
||||
|
||||
it('should display candidate groups', async(() => {
|
||||
it('should display candidate groups', async () => {
|
||||
component.ngOnChanges();
|
||||
fixture.detectChanges();
|
||||
|
||||
fixture.whenStable().then(() => {
|
||||
const candidateGroup1 = fixture.nativeElement.querySelector('[data-automation-id="card-arrayitem-chip-mockgroup1"] span');
|
||||
const candidateGroup2 = fixture.nativeElement.querySelector('[data-automation-id="card-arrayitem-chip-mockgroup2"] span');
|
||||
expect(getCandidateGroupsSpy).toHaveBeenCalled();
|
||||
expect(candidateGroup1.innerText).toBe('mockgroup1');
|
||||
expect(candidateGroup2.innerText).toBe('mockgroup2');
|
||||
});
|
||||
}));
|
||||
await fixture.whenStable();
|
||||
const candidateGroup1 = fixture.nativeElement.querySelector('[data-automation-id="card-arrayitem-chip-mockgroup1"] span');
|
||||
const candidateGroup2 = fixture.nativeElement.querySelector('[data-automation-id="card-arrayitem-chip-mockgroup2"] span');
|
||||
expect(getCandidateGroupsSpy).toHaveBeenCalled();
|
||||
expect(candidateGroup1.innerText).toBe('mockgroup1');
|
||||
expect(candidateGroup2.innerText).toBe('mockgroup2');
|
||||
});
|
||||
|
||||
it('should display candidate user', async(() => {
|
||||
it('should display candidate user', async () => {
|
||||
component.ngOnChanges();
|
||||
fixture.detectChanges();
|
||||
|
||||
fixture.whenStable().then(() => {
|
||||
const candidateUser1 = fixture.nativeElement.querySelector('[data-automation-id="card-arrayitem-chip-mockuser1"] span');
|
||||
const candidateUser2 = fixture.nativeElement.querySelector('[data-automation-id="card-arrayitem-chip-mockuser2"] span');
|
||||
expect(getCandidateUsersSpy).toHaveBeenCalled();
|
||||
expect(candidateUser1.innerText).toBe('mockuser1');
|
||||
expect(candidateUser2.innerText).toBe('mockuser2');
|
||||
});
|
||||
}));
|
||||
await fixture.whenStable();
|
||||
const candidateUser1 = fixture.nativeElement.querySelector('[data-automation-id="card-arrayitem-chip-mockuser1"] span');
|
||||
const candidateUser2 = fixture.nativeElement.querySelector('[data-automation-id="card-arrayitem-chip-mockuser2"] span');
|
||||
expect(getCandidateUsersSpy).toHaveBeenCalled();
|
||||
expect(candidateUser1.innerText).toBe('mockuser1');
|
||||
expect(candidateUser2.innerText).toBe('mockuser2');
|
||||
});
|
||||
|
||||
it('should display placeholder if no candidate groups', async(() => {
|
||||
it('should display placeholder if no candidate groups', async () => {
|
||||
getCandidateGroupsSpy.and.returnValue(of([]));
|
||||
fixture.detectChanges();
|
||||
component.ngOnChanges();
|
||||
fixture.detectChanges();
|
||||
|
||||
fixture.whenStable().then(() => {
|
||||
const labelValue = fixture.debugElement.query(By.css('[data-automation-id="card-array-label-candidateGroups"]'));
|
||||
const defaultElement = fixture.debugElement.query(By.css('[data-automation-id="card-arrayitem-default"]'));
|
||||
expect(labelValue.nativeElement.innerText).toBe('ADF_CLOUD_TASK_HEADER.PROPERTIES.CANDIDATE_GROUPS');
|
||||
expect(defaultElement.nativeElement.innerText).toBe('ADF_CLOUD_TASK_HEADER.PROPERTIES.CANDIDATE_GROUPS_DEFAULT');
|
||||
});
|
||||
await fixture.whenStable();
|
||||
const labelValue = fixture.debugElement.query(By.css('[data-automation-id="card-array-label-candidateGroups"]'));
|
||||
const defaultElement = fixture.debugElement.query(By.css('[data-automation-id="card-arrayitem-default"]'));
|
||||
expect(labelValue.nativeElement.innerText).toBe('ADF_CLOUD_TASK_HEADER.PROPERTIES.CANDIDATE_GROUPS');
|
||||
expect(defaultElement.nativeElement.innerText).toBe('ADF_CLOUD_TASK_HEADER.PROPERTIES.CANDIDATE_GROUPS_DEFAULT');
|
||||
});
|
||||
|
||||
}));
|
||||
|
||||
it('should display placeholder if no candidate users', async(() => {
|
||||
it('should display placeholder if no candidate users', async () => {
|
||||
getCandidateUsersSpy.and.returnValue(of([]));
|
||||
fixture.detectChanges();
|
||||
component.ngOnChanges();
|
||||
fixture.detectChanges();
|
||||
|
||||
fixture.whenStable().then(() => {
|
||||
const labelValue = fixture.debugElement.query(By.css('[data-automation-id="card-array-label-candidateUsers"]'));
|
||||
const defaultElement = fixture.debugElement.query(By.css('[data-automation-id="card-arrayitem-default"]'));
|
||||
expect(labelValue.nativeElement.innerText).toBe('ADF_CLOUD_TASK_HEADER.PROPERTIES.CANDIDATE_USERS');
|
||||
expect(defaultElement.nativeElement.innerText).toBe('ADF_CLOUD_TASK_HEADER.PROPERTIES.CANDIDATE_USERS_DEFAULT');
|
||||
});
|
||||
}));
|
||||
await fixture.whenStable();
|
||||
const labelValue = fixture.debugElement.query(By.css('[data-automation-id="card-array-label-candidateUsers"]'));
|
||||
const defaultElement = fixture.debugElement.query(By.css('[data-automation-id="card-arrayitem-default"]'));
|
||||
expect(labelValue.nativeElement.innerText).toBe('ADF_CLOUD_TASK_HEADER.PROPERTIES.CANDIDATE_USERS');
|
||||
expect(defaultElement.nativeElement.innerText).toBe('ADF_CLOUD_TASK_HEADER.PROPERTIES.CANDIDATE_USERS_DEFAULT');
|
||||
});
|
||||
});
|
||||
|
||||
describe('Config properties', () => {
|
||||
|
||||
it('should show only the properties from the configuration file', async(() => {
|
||||
it('should show only the properties from the configuration file', async () => {
|
||||
spyOn(appConfigService, 'get').and.returnValue(['assignee', 'status']);
|
||||
component.ngOnChanges();
|
||||
fixture.detectChanges();
|
||||
const propertyList = fixture.debugElement.queryAll(By.css('.adf-property-list .adf-property'));
|
||||
|
||||
fixture.whenStable().then(() => {
|
||||
expect(propertyList).toBeDefined();
|
||||
expect(propertyList).not.toBeNull();
|
||||
expect(propertyList.length).toBe(2);
|
||||
expect(propertyList[0].nativeElement.textContent).toContain('ADF_CLOUD_TASK_HEADER.PROPERTIES.ASSIGNEE');
|
||||
expect(propertyList[1].nativeElement.textContent).toContain('ADF_CLOUD_TASK_HEADER.PROPERTIES.STATUS');
|
||||
});
|
||||
}));
|
||||
await fixture.whenStable();
|
||||
expect(propertyList).toBeDefined();
|
||||
expect(propertyList).not.toBeNull();
|
||||
expect(propertyList.length).toBe(2);
|
||||
expect(propertyList[0].nativeElement.textContent).toContain('ADF_CLOUD_TASK_HEADER.PROPERTIES.ASSIGNEE');
|
||||
expect(propertyList[1].nativeElement.textContent).toContain('ADF_CLOUD_TASK_HEADER.PROPERTIES.STATUS');
|
||||
});
|
||||
|
||||
it('should show all the default properties if there is no configuration', async(() => {
|
||||
it('should show all the default properties if there is no configuration', async () => {
|
||||
spyOn(appConfigService, 'get').and.returnValue(null);
|
||||
component.ngOnChanges();
|
||||
fixture.detectChanges();
|
||||
|
||||
fixture.whenStable().then(() => {
|
||||
const propertyList = fixture.debugElement.queryAll(By.css('.adf-property-list .adf-property'));
|
||||
expect(propertyList).toBeDefined();
|
||||
expect(propertyList).not.toBeNull();
|
||||
expect(propertyList.length).toBe(component.properties.length);
|
||||
expect(propertyList[0].nativeElement.textContent).toContain('ADF_CLOUD_TASK_HEADER.PROPERTIES.ASSIGNEE');
|
||||
expect(propertyList[1].nativeElement.textContent).toContain('ADF_CLOUD_TASK_HEADER.PROPERTIES.STATUS');
|
||||
});
|
||||
}));
|
||||
await fixture.whenStable();
|
||||
const propertyList = fixture.debugElement.queryAll(By.css('.adf-property-list .adf-property'));
|
||||
expect(propertyList).toBeDefined();
|
||||
expect(propertyList).not.toBeNull();
|
||||
expect(propertyList.length).toBe(component.properties.length);
|
||||
expect(propertyList[0].nativeElement.textContent).toContain('ADF_CLOUD_TASK_HEADER.PROPERTIES.ASSIGNEE');
|
||||
expect(propertyList[1].nativeElement.textContent).toContain('ADF_CLOUD_TASK_HEADER.PROPERTIES.STATUS');
|
||||
});
|
||||
});
|
||||
|
||||
describe('Task errors', () => {
|
||||
@@ -543,13 +538,13 @@ describe('TaskHeaderCloudComponent', () => {
|
||||
component.ngOnChanges();
|
||||
}));
|
||||
|
||||
it('should call the loadTaskDetailsById when both app name and task id are provided', async(() => {
|
||||
it('should call the loadTaskDetailsById when both app name and task id are provided', () => {
|
||||
spyOn(component, 'loadTaskDetailsById');
|
||||
component.appName = 'appName';
|
||||
component.taskId = 'taskId';
|
||||
component.ngOnChanges();
|
||||
fixture.detectChanges();
|
||||
expect(component.loadTaskDetailsById).toHaveBeenCalledWith(component.appName, component.taskId);
|
||||
}));
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user