diff --git a/lib/process-services-cloud/src/lib/task/task-header/components/task-header-cloud.component.spec.ts b/lib/process-services-cloud/src/lib/task/task-header/components/task-header-cloud.component.spec.ts index 98fc7938a9..6c5e6ade61 100644 --- a/lib/process-services-cloud/src/lib/task/task-header/components/task-header-cloud.component.spec.ts +++ b/lib/process-services-cloud/src/lib/task/task-header/components/task-header-cloud.component.spec.ts @@ -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, AlfrescoApiService } from '@alfresco/adf-core'; +import { setupTestBed, AppConfigService, AlfrescoApiService, CardViewArrayItem } 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'; @@ -216,6 +216,17 @@ describe('TaskHeaderCloudComponent', () => { const loading = fixture.debugElement.query(By.css('.adf-task-header-loading')); expect(loading).toBeTruthy(); }); + + it('should not render edit icon if the task in assigned state and assingned user is different from current logged-in user', () => { + isTaskEditableSpy.and.returnValue(false); + fixture.detectChanges(); + const priorityEditIcon = fixture.debugElement.query(By.css(`[data-automation-id="card-textitem-edit-icon-priority"]`)); + 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(dueDateEditIcon).toBeNull('Edit icon should NOT be shown'); + }); }); describe('Task with parentTaskId', () => { @@ -268,7 +279,7 @@ describe('TaskHeaderCloudComponent', () => { 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 () => { + it('should render defined edit icon for assignee property if the task in assigned state and shared among candidate users', 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"]`)); @@ -276,7 +287,7 @@ describe('TaskHeaderCloudComponent', () => { expect(value.nativeElement.innerText).toBe('create'); }); - it('should not render defined edit icon for assignee property if the task in created state and shared among condidates', async () => { + it('should not render defined edit icon for assignee property if the task in created state and shared among condidate users', async () => { getTaskByIdSpy.and.returnValue(of(createdTaskDetailsCloudMock)); component.ngOnChanges(); @@ -287,6 +298,28 @@ describe('TaskHeaderCloudComponent', () => { expect(editIcon).toBeNull(); }); + it('should not render defined edit icon for assignee property if the task in assigned state and shared among candidate groups', async () => { + component.candidateGroups = [{ value: 'mock-group-1', icon: 'edit' }, { value: 'mock-group-2', icon: 'edit' }]; + component.candidateUsers = []; + 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'); + }); + + it('should not render defined edit icon for assignee property if the task in created state and shared among condidate groups', async () => { + getTaskByIdSpy.and.returnValue(of(createdTaskDetailsCloudMock)); + component.candidateGroups = [{ value: 'mock-group-1', icon: 'edit' }, { value: 'mock-group-2', icon: 'edit' }]; + component.candidateUsers = []; + component.ngOnChanges(); + fixture.detectChanges(); + await fixture.whenStable(); + + const editIcon = fixture.debugElement.query(By.css(`[data-automation-id="header-assignee"] [data-automation-id="card-textitem-clickable-icon-assignee"]`)); + expect(editIcon).toBeNull(); + }); + it('should render edit icon if the task in assigned state and assingee should be current user', () => { fixture.detectChanges(); const priorityEditIcon = fixture.debugElement.query(By.css(`[data-automation-id="header-priority"] [class*="adf-textitem-edit-icon"]`)); @@ -304,17 +337,6 @@ describe('TaskHeaderCloudComponent', () => { const value = fixture.debugElement.query(By.css(`[data-automation-id="card-textitem-clickable-icon-assignee"]`)); expect(value).toBeNull('Edit icon should NOT be shown'); }); - - it('should not render edit icon if the task in assigned state and assingned user is different from current logged-in user', () => { - isTaskEditableSpy.and.returnValue(false); - fixture.detectChanges(); - const priorityEditIcon = fixture.debugElement.query(By.css(`[data-automation-id="card-textitem-edit-icon-priority"]`)); - 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(dueDateEditIcon).toBeNull('Edit icon should NOT be shown'); - }); }); describe('Created Task', () => { diff --git a/lib/process-services-cloud/src/lib/task/task-header/components/task-header-cloud.component.ts b/lib/process-services-cloud/src/lib/task/task-header/components/task-header-cloud.component.ts index 3cb8e5e892..227ab9fd27 100644 --- a/lib/process-services-cloud/src/lib/task/task-header/components/task-header-cloud.component.ts +++ b/lib/process-services-cloud/src/lib/task/task-header/components/task-header-cloud.component.ts @@ -318,8 +318,12 @@ export class TaskHeaderCloudComponent implements OnInit, OnDestroy, OnChanges { return this.taskCloudService.isTaskEditable(this.taskDetails); } + /** + * as per [ACA-3960] it required an empty array argument for now + * Empty array will be replaced with candidateGroups in feature + */ isAssigneePropertyClickable(): boolean { - return this.taskCloudService.isAssigneePropertyClickable(this.taskDetails, this.candidateUsers, this.candidateGroups); + return this.taskCloudService.isAssigneePropertyClickable(this.taskDetails, this.candidateUsers, []); } private isValidSelection(filteredProperties: string[], cardItem: CardViewBaseItemModel): boolean {