Add additional tests for start button state

Refs #1066
This commit is contained in:
Will Abson
2016-11-18 14:00:33 +00:00
committed by Mario Romano
parent ac4c31a1d0
commit 7013918d35
2 changed files with 19 additions and 10 deletions

View File

@@ -212,6 +212,8 @@ describe('ActivitiStartProcessButton', () => {
describe('start forms', () => {
let startBtn;
describe('without start form', () => {
beforeEach(async(() => {
@@ -220,15 +222,23 @@ describe('ActivitiStartProcessButton', () => {
fixture.detectChanges();
component.onProcessDefChange('my:process1');
fixture.whenStable();
startBtn = debugElement.query(By.css('[data-automation-id="btn-start"]'));
}));
it('should indicate start form is missing', async(() => {
expect(component.isStartFormMissingOrValid()).toBe(true);
it('should have start button disabled when name not filled out', async(() => {
component.name = '';
fixture.detectChanges();
expect(startBtn.properties['disabled']).toBe(true);
}));
it('should have start button disabled when name not filled out', async(() => {
component.onProcessDefChange('');
fixture.detectChanges();
expect(startBtn.properties['disabled']).toBe(true);
}));
it('should enable start button when name and process filled out', async(() => {
fixture.detectChanges();
let startBtn = debugElement.query(By.css('[data-automation-id="btn-start"]'));
expect(startBtn.properties['disabled']).toBe(false);
}));
@@ -243,6 +253,7 @@ describe('ActivitiStartProcessButton', () => {
component.onProcessDefChange('my:process1');
fixture.detectChanges();
fixture.whenStable();
startBtn = debugElement.query(By.css('[data-automation-id="btn-start"]'));
});
it('should initialize start form', () => {
@@ -254,14 +265,9 @@ describe('ActivitiStartProcessButton', () => {
expect(getStartFormDefinitionSpy).toHaveBeenCalled();
});
it('should indicate start form is invalid', async(() => {
expect(component.isStartFormMissingOrValid()).toBe(false);
}));
it('should leave start button disabled when mandatory fields not filled out', async(() => {
component.name = 'My new process';
fixture.detectChanges();
let startBtn = debugElement.query(By.css('[data-automation-id="btn-start"]'));
expect(startBtn.properties['disabled']).toBe(true);
}));

View File

@@ -120,8 +120,11 @@ export class ActivitiStartProcessButton implements OnInit, OnChanges {
let processDef = this.processDefinitions.find((processDefinition) => {
return processDefinition.id === processDefinitionId;
});
let clone = JSON.parse(JSON.stringify(processDef));
this.currentProcessDef = clone;
if (processDef) {
this.currentProcessDef = JSON.parse(JSON.stringify(processDef));
} else {
this.resetSelectedProcessDefinition();
}
}
hasStartForm() {