mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ADF-4522] Metadata value is not rolled back upon error (#5550)
* * initial commit * * removed breaking change * * fixed ts * * fixed minor changes * * fixed changes * * minor changes * * fixed unit test * * docs added * * fixed date clear problem * * fixed unit test
This commit is contained in:
@@ -39,7 +39,6 @@ describe('TaskHeaderCloudComponent', () => {
|
||||
let appConfigService: AppConfigService;
|
||||
let taskCloudService: TaskCloudService;
|
||||
let getTaskByIdSpy: jasmine.Spy;
|
||||
let updateTaskSpy: jasmine.Spy;
|
||||
let getCandidateGroupsSpy: jasmine.Spy;
|
||||
let getCandidateUsersSpy: jasmine.Spy;
|
||||
let isTaskEditableSpy: jasmine.Spy;
|
||||
@@ -64,7 +63,6 @@ describe('TaskHeaderCloudComponent', () => {
|
||||
component.appName = 'mock-app-name';
|
||||
component.taskId = 'mock-task-id';
|
||||
getTaskByIdSpy = spyOn(taskCloudService, 'getTaskById').and.returnValue(of(assignedTaskDetailsCloudMock));
|
||||
updateTaskSpy = spyOn(taskCloudService, 'updateTask').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));
|
||||
@@ -162,6 +160,7 @@ describe('TaskHeaderCloudComponent', () => {
|
||||
}));
|
||||
|
||||
it('should be able to call update service on updating task description', async(() => {
|
||||
spyOn(taskCloudService, 'updateTask').and.returnValue(of(assignedTaskDetailsCloudMock));
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
const descriptionEditIcon = fixture.debugElement.query(By.css('[data-automation-id="card-textitem-edit-icon-description"]'));
|
||||
@@ -176,10 +175,36 @@ describe('TaskHeaderCloudComponent', () => {
|
||||
const submitEl = fixture.debugElement.query(By.css('[data-automation-id="card-textitem-update-description"]'));
|
||||
submitEl.nativeElement.click();
|
||||
fixture.detectChanges();
|
||||
expect(updateTaskSpy).toHaveBeenCalled();
|
||||
expect(taskCloudService.updateTask).toHaveBeenCalled();
|
||||
});
|
||||
}));
|
||||
});
|
||||
|
||||
it('should roll back task description on error', async () => {
|
||||
spyOn(taskCloudService, 'updateTask').and.returnValue(throwError('fake'));
|
||||
fixture.detectChanges();
|
||||
|
||||
await fixture.whenStable();
|
||||
let description = fixture.debugElement.query(By.css('[data-automation-id="card-textitem-value-description"]'));
|
||||
expect(description.nativeElement.innerText.trim()).toEqual('This is the description');
|
||||
|
||||
const descriptionEditIcon = fixture.debugElement.query(By.css('[data-automation-id="card-textitem-edit-icon-description"]'));
|
||||
descriptionEditIcon.nativeElement.click();
|
||||
fixture.detectChanges();
|
||||
|
||||
const inputEl = fixture.debugElement.query(By.css('[data-automation-id="card-textitem-edittextarea-description"]'));
|
||||
inputEl.nativeElement.value = 'updated description';
|
||||
inputEl.nativeElement.dispatchEvent(new Event('input'));
|
||||
|
||||
const submitEl = fixture.debugElement.query(By.css('[data-automation-id="card-textitem-update-description"]'));
|
||||
submitEl.nativeElement.click();
|
||||
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.innerText.trim()).toEqual('This is the description');
|
||||
});
|
||||
});
|
||||
|
||||
describe('Task with parentTaskId', () => {
|
||||
|
||||
|
@@ -16,7 +16,7 @@
|
||||
*/
|
||||
|
||||
import { Component, Input, EventEmitter, Output, OnDestroy, OnChanges, OnInit } from '@angular/core';
|
||||
import { takeUntil, concatMap } from 'rxjs/operators';
|
||||
import { takeUntil, concatMap, catchError } from 'rxjs/operators';
|
||||
import { Subject, of, forkJoin } from 'rxjs';
|
||||
import {
|
||||
CardViewDateItemModel,
|
||||
@@ -274,12 +274,16 @@ export class TaskHeaderCloudComponent implements OnInit, OnDestroy, OnChanges {
|
||||
*/
|
||||
private updateTaskDetails(updateNotification: UpdateNotification) {
|
||||
this.taskCloudService.updateTask(this.appName, this.taskId, updateNotification.changed)
|
||||
.subscribe(
|
||||
(taskDetails) => {
|
||||
this.taskDetails = taskDetails;
|
||||
.pipe(catchError(() => {
|
||||
this.cardViewUpdateService.updateElement(updateNotification.target);
|
||||
return of(null);
|
||||
}))
|
||||
.subscribe((taskDetails) => {
|
||||
if (taskDetails) {
|
||||
this.taskDetails = taskDetails;
|
||||
}
|
||||
this.refreshData();
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
private loadParentName(taskId: string) {
|
||||
|
Reference in New Issue
Block a user