[ADF-2238] added a condition to avoid checklist delete for completed task

This commit is contained in:
VitoAlbano
2018-05-23 12:48:03 +01:00
parent 049e514541
commit fc2227ea04
2 changed files with 17 additions and 1 deletions

View File

@@ -14,7 +14,7 @@
<mat-chip-list class="mat-chip-list-stacked"> <mat-chip-list class="mat-chip-list-stacked">
<mat-chip id="check-{{check.id}}" class="adf-checklist-chip" *ngFor="let check of checklist"> <mat-chip id="check-{{check.id}}" class="adf-checklist-chip" *ngFor="let check of checklist">
<span>{{check.name}}</span> <span>{{check.name}}</span>
<button *ngIf="!readOnly" mat-icon-button type="button" class="adf-checklist-cancel-button" (click)="delete(check.id)"> <button *ngIf="!readOnly && !check.endDate" mat-icon-button type="button" class="adf-checklist-cancel-button" (click)="delete(check.id)">
<mat-icon id="remove-{{check.id}}" matChipRemove>cancel</mat-icon> <mat-icon id="remove-{{check.id}}" matChipRemove>cancel</mat-icon>
</button> </button>
</mat-chip> </mat-chip>

View File

@@ -29,6 +29,12 @@ const fakeTaskDetail = new TaskDetailsModel({
name: 'fake-check-name' name: 'fake-check-name'
}); });
const fakeTaskDetailCompleted = new TaskDetailsModel({
id: 'fake-completed-id',
name: 'fake-completed-name',
endDate: '2018-05-23T11:25:14.552+0000'
});
describe('ChecklistComponent', () => { describe('ChecklistComponent', () => {
let checklistComponent: ChecklistComponent; let checklistComponent: ChecklistComponent;
@@ -146,6 +152,16 @@ describe('ChecklistComponent', () => {
expect(element.querySelector('#check-fake-check-id').textContent).toContain('fake-check-name'); 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);
fixture.detectChanges();
expect(element.querySelector('#remove-fake-check-id')).not.toBeNull();
expect(element.querySelector('#check-fake-completed-id')).not.toBeNull();
expect(element.querySelector('#check-fake-completed-id')).toBeDefined();
expect(element.querySelector('#remove-fake-completed-id')).toBeNull();
});
it('should add checklist', async(() => { it('should add checklist', async(() => {
showChecklistDialog.click(); showChecklistDialog.click();
let addButtonDialog = <HTMLElement> window.document.querySelector('#add-check'); let addButtonDialog = <HTMLElement> window.document.querySelector('#add-check');