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', () => {
|
||||||
|
|
||||||
@ -207,14 +208,14 @@ describe('StartProcessCloudComponent', () => {
|
|||||||
|
|
||||||
it('should include the static input mappings in the resolved values', fakeAsync(() => {
|
it('should include the static input mappings in the resolved values', fakeAsync(() => {
|
||||||
const values: TaskVariableCloud[] = [
|
const values: TaskVariableCloud[] = [
|
||||||
new TaskVariableCloud({name: 'value1', value: 'value'}),
|
new TaskVariableCloud({ name: 'value1', value: 'value' }),
|
||||||
new TaskVariableCloud({name: 'value2', value: 1}),
|
new TaskVariableCloud({ name: 'value2', value: 1 }),
|
||||||
new TaskVariableCloud({name: 'value3', value: false})
|
new TaskVariableCloud({ name: 'value3', value: false })
|
||||||
];
|
];
|
||||||
const staticInputs: TaskVariableCloud[] = [
|
const staticInputs: TaskVariableCloud[] = [
|
||||||
new TaskVariableCloud({name: 'static1', value: 'static value'}),
|
new TaskVariableCloud({ name: 'static1', value: 'static value' }),
|
||||||
new TaskVariableCloud({name: 'static2', value: 0}),
|
new TaskVariableCloud({ name: 'static2', value: 0 }),
|
||||||
new TaskVariableCloud({name: 'static3', value: true})
|
new TaskVariableCloud({ name: 'static3', value: true })
|
||||||
];
|
];
|
||||||
component.name = 'My new process';
|
component.name = 'My new process';
|
||||||
component.processDefinitionName = 'processwithoutform2';
|
component.processDefinitionName = 'processwithoutform2';
|
||||||
@ -831,7 +832,7 @@ describe('StartProcessCloudComponent', () => {
|
|||||||
it('should set the process name using the processName cloud pipe when a process definition gets selected', () => {
|
it('should set the process name using the processName cloud pipe when a process definition gets selected', () => {
|
||||||
const processNameCloudPipe = TestBed.inject(ProcessNameCloudPipe);
|
const processNameCloudPipe = TestBed.inject(ProcessNameCloudPipe);
|
||||||
const processNamePipeTransformSpy = spyOn(processNameCloudPipe, 'transform').and.returnValue('fake-transformed-name');
|
const processNamePipeTransformSpy = spyOn(processNameCloudPipe, 'transform').and.returnValue('fake-transformed-name');
|
||||||
const expectedProcessInstanceDetails: ProcessInstanceCloud = { processDefinitionName: fakeProcessDefinitions[0].name};
|
const expectedProcessInstanceDetails: ProcessInstanceCloud = { processDefinitionName: fakeProcessDefinitions[0].name };
|
||||||
getDefinitionsSpy = getDefinitionsSpy.and.returnValue(of(fakeProcessDefinitions));
|
getDefinitionsSpy = getDefinitionsSpy.and.returnValue(of(fakeProcessDefinitions));
|
||||||
|
|
||||||
component.appName = 'myApp';
|
component.appName = 'myApp';
|
||||||
@ -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