mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-05-26 17:24:56 +00:00
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:
parent
cd84be9712
commit
b9c53e586d
@ -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', () => {
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user