AAE-12139 disabled start process btn when clicked and api call in pro… (#8160)

* AAE-12139 disabled start process btn when clicked and api call in progress

* AAE-12139 improved unit tests

* AAE-12139 added return type

* AAE-12139 removed ngOnInit from unit tests
This commit is contained in:
tomasz hanaj 2023-02-08 16:55:15 +01:00 committed by GitHub
parent cd84be9712
commit b9c53e586d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 41 additions and 2 deletions

View File

@ -993,6 +993,45 @@ describe('StartProcessCloudComponent', () => {
expect(card).toBeTruthy();
});
});
describe('start button', () => {
beforeEach(() => {
component.name = 'NewProcess 1';
component.appName = 'myApp';
component.ngOnChanges({ appName: firstChange });
component.processDefinitionList = fakeProcessDefinitions;
component.processDefinitionName = fakeProcessDefinitions[0].name;
});
it('start process button should be enabled when isLoading is false', async () => {
fixture.detectChanges();
component.processForm.controls['processInstanceName'].setValue(fakeProcessDefinitions[0].id);
component.appName = 'test app name';
component.isLoading = false;
fixture.detectChanges();
await fixture.whenStable();
const startButton = fixture.debugElement.query(By.css('#button-start'));
expect(startButton).not.toBeNull();
expect(component.disableStartButton()).toBeFalse();
expect((startButton.nativeElement as HTMLButtonElement).disabled).toBeFalse();
});
it('start process button should be disabled when isLoading is true', async () => {
fixture.detectChanges();
component.processForm.controls['processInstanceName'].setValue(fakeProcessDefinitions[0].id);
component.appName = 'test app name';
component.isLoading = true;
fixture.detectChanges();
await fixture.whenStable();
const startButton = fixture.debugElement.query(By.css('#button-start'));
expect(startButton).not.toBeNull();
expect(component.disableStartButton()).toBeTrue();
expect((startButton.nativeElement as HTMLButtonElement).disabled).toBeTrue();
});
});
describe('cancel process', () => {

View File

@ -391,7 +391,7 @@ export class StartProcessCloudComponent implements OnChanges, OnInit, OnDestroy
this.onDestroy$.complete();
}
disableStartButton() {
return !this.appName || !this.processDefinition.valid;
disableStartButton(): boolean {
return !this.appName || !this.processDefinition.valid || this.isLoading;
}
}