mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-05-12 17:04:57 +00:00
AAE-11739 removed unnecessary api call when cancelling not started pr… (#8041)
* AAE-11739 removed unnecessary api call when cancelling not started process * AAE-11739 added unit tests for cancelling process * AAE-11739 fixed erroneous test * AAE-11739 fix for test related error thrown in afterAll * AAE-11739 added proper way to test wheter button exist
This commit is contained in:
parent
0cb1c502c0
commit
ef278bde79
@ -45,6 +45,7 @@ import { ProcessNameCloudPipe } from '../../../pipes/process-name-cloud.pipe';
|
|||||||
import { ProcessInstanceCloud } from '../models/process-instance-cloud.model';
|
import { ProcessInstanceCloud } from '../models/process-instance-cloud.model';
|
||||||
import { ESCAPE } from '@angular/cdk/keycodes';
|
import { ESCAPE } from '@angular/cdk/keycodes';
|
||||||
import { ProcessDefinitionCloud, TaskVariableCloud } from '@alfresco/adf-process-services-cloud';
|
import { ProcessDefinitionCloud, TaskVariableCloud } from '@alfresco/adf-process-services-cloud';
|
||||||
|
import { first } from 'rxjs/operators';
|
||||||
|
|
||||||
describe('StartProcessCloudComponent', () => {
|
describe('StartProcessCloudComponent', () => {
|
||||||
|
|
||||||
@ -939,4 +940,34 @@ describe('StartProcessCloudComponent', () => {
|
|||||||
expect(card).toBeTruthy();
|
expect(card).toBeTruthy();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('cancel process', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
fixture.detectChanges();
|
||||||
|
component.name = 'NewProcess 1';
|
||||||
|
component.appName = 'myApp';
|
||||||
|
component.ngOnChanges({});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('user should see cancel button', () => {
|
||||||
|
fixture.whenStable().then(() => {
|
||||||
|
fixture.detectChanges();
|
||||||
|
const cancelBtn = fixture.debugElement.query(By.css('#cancel_process'));
|
||||||
|
expect(cancelBtn.nativeElement).toBeDefined();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('currentCreatedProcess should be null when cancel button clicked', () => {
|
||||||
|
component.cancelStartProcess();
|
||||||
|
expect(component.currentCreatedProcess).toBeNull();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('undefined should be emitted when cancel button clicked', () => {
|
||||||
|
component.cancel.pipe(first()).subscribe((data: any) => {
|
||||||
|
expect(data).toBe(undefined);
|
||||||
|
});
|
||||||
|
component.cancelStartProcess();
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@ -334,11 +334,7 @@ export class StartProcessCloudComponent implements OnChanges, OnInit, OnDestroy
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async cancelStartProcess() {
|
cancelStartProcess() {
|
||||||
if (this.currentCreatedProcess) {
|
|
||||||
await this.startProcessCloudService.deleteProcess(this.appName, this.currentCreatedProcess.id);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.currentCreatedProcess = null;
|
this.currentCreatedProcess = null;
|
||||||
this.cancel.emit();
|
this.cancel.emit();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user