diff --git a/e2e/pages/adf/process_services/startProcessPage.js b/e2e/pages/adf/process_services/startProcessPage.js index af8e7781a5..b5d214cfed 100644 --- a/e2e/pages/adf/process_services/startProcessPage.js +++ b/e2e/pages/adf/process_services/startProcessPage.js @@ -58,10 +58,14 @@ var StartProcessPage = function () { this.enterProcessName = function (name) { Util.waitUntilElementIsVisible(processNameInput); - processNameInput.clear(); + this.clearProcessName(); processNameInput.sendKeys(name); }; + this.clearProcessName = function () { + processNameInput.clear(); + }; + this.selectFromProcessDropdown = function (name) { this.clickProcessDropdownArrow(); return this.selectOption(name); @@ -97,6 +101,7 @@ var StartProcessPage = function () { this.typeProcessDefinition = function (name) { Util.waitUntilElementIsVisible(processDefinition); Util.waitUntilElementIsClickable(processDefinition); + processDefinition.clear(); processDefinition.sendKeys(name); return this; }; diff --git a/e2e/process-services/start_process_component.e2e.ts b/e2e/process-services/start_process_component.e2e.ts index 7817660431..ecf7ff123c 100644 --- a/e2e/process-services/start_process_component.e2e.ts +++ b/e2e/process-services/start_process_component.e2e.ts @@ -150,6 +150,7 @@ describe('Start Process Component', () => { processFiltersPage.clickCreateProcessButton(); processFiltersPage.clickNewProcessDropdown(); startProcessPage.enterProcessName(''); + browser.actions().sendKeys('v\b\b').perform(); // clear doesnt' trigger the validator startProcessPage.checkStartProcessButtonIsDisabled(); startProcessPage.clickCancelProcessButton(); processFiltersPage.checkNoContentMessage(); diff --git a/lib/process-services/process-list/components/start-process.component.spec.ts b/lib/process-services/process-list/components/start-process.component.spec.ts index dc7ecdcb4b..0f922f27a2 100644 --- a/lib/process-services/process-list/components/start-process.component.spec.ts +++ b/lib/process-services/process-list/components/start-process.component.spec.ts @@ -131,7 +131,6 @@ describe('StartFormComponent', () => { it('should initialize start form', async(() => { fixture.detectChanges(); - fixture.whenStable().then(() => { expect(component.startForm).toBeDefined(); expect(component.startForm).not.toBeNull(); @@ -203,19 +202,21 @@ describe('StartFormComponent', () => { describe('process definitions list', () => { - it('should call service to fetch process definitions with appId', () => { + beforeEach(() => { + fixture.detectChanges(); + component.name = 'My new process'; component.appId = 123; component.ngOnChanges({}); fixture.detectChanges(); + }); + + it('should call service to fetch process definitions with appId', () => { fixture.whenStable().then(() => { expect(getDefinitionsSpy).toHaveBeenCalledWith(123); }); }); it('should display the correct number of processes in the select list', () => { - component.appId = 123; - component.ngOnChanges({}); - fixture.detectChanges(); fixture.whenStable().then(() => { let selectElement = fixture.nativeElement.querySelector('mat-select'); expect(selectElement.children.length).toBe(1); @@ -223,8 +224,6 @@ describe('StartFormComponent', () => { }); it('should display the option def details', () => { - component.appId = 123; - component.ngOnChanges({}); component.processDefinitions = testMultipleProcessDefs; fixture.detectChanges(); fixture.whenStable().then(() => { @@ -265,7 +264,6 @@ describe('StartFormComponent', () => { })); it('should select processDefinition based on processDefinition input', async(() => { - fixture.detectChanges(); getDefinitionsSpy = getDefinitionsSpy.and.returnValue(of(testMultipleProcessDefs)); component.appId = 123; component.processNameInput.setValue('My Process 2'); @@ -277,7 +275,6 @@ describe('StartFormComponent', () => { })); it('should select automatically the processDefinition if the app contain only one', async(() => { - fixture.detectChanges(); getDefinitionsSpy = getDefinitionsSpy.and.returnValue(of(testProcessDefinitions)); component.appId = 123; component.ngOnChanges({}); @@ -303,6 +300,7 @@ describe('StartFormComponent', () => { })); it('should show the process dropdown button if showSelectProcessDropdown is false', async(() => { + fixture.detectChanges(); getDefinitionsSpy = getDefinitionsSpy.and.returnValue(of(testMultipleProcessDefs)); component.appId = 123; component.processDefinitionName = 'My Process 2'; @@ -316,6 +314,7 @@ describe('StartFormComponent', () => { })); it('should show the process dropdown button by default', async(() => { + fixture.detectChanges(); getDefinitionsSpy = getDefinitionsSpy.and.returnValue(of(testMultipleProcessDefs)); component.appId = 123; component.processDefinitionName = 'My Process 2'; @@ -363,6 +362,7 @@ describe('StartFormComponent', () => { describe('start process', () => { beforeEach(() => { + fixture.detectChanges(); component.name = 'My new process'; component.appId = 123; component.ngOnChanges({}); diff --git a/lib/process-services/process-list/components/start-process.component.ts b/lib/process-services/process-list/components/start-process.component.ts index 2fcc37f63e..9764e487c3 100644 --- a/lib/process-services/process-list/components/start-process.component.ts +++ b/lib/process-services/process-list/components/start-process.component.ts @@ -161,18 +161,19 @@ export class StartProcessInstanceComponent implements OnChanges, OnInit { (processDefinitionRepresentations: ProcessDefinitionRepresentation[]) => { this.processDefinitions = processDefinitionRepresentations; - if (this.hasSingleProcessDefinition()) { + if (!this.isProcessDefinitionsEmpty()) { this.selectedProcessDef = this.processDefinitions[0]; - } else { - this.selectedProcessDef = this.processDefinitions.find((currentProcessDefinition) => { - return currentProcessDefinition.name === this.processDefinitionName; - }); - } - if (this.selectedProcessDef) { - if (this.processDefinitionInput) { - this.processDefinitionInput.setValue(this.selectedProcessDef.name); + if (this.processDefinitionName) { + let selectedProcess = this.processDefinitions.find((currentProcessDefinition) => { + return currentProcessDefinition.name === this.processDefinitionName; + }); + if (selectedProcess) { + this.selectedProcessDef = selectedProcess; + } } + + this.processDefinitionInput.setValue(this.selectedProcessDef.name); } }, () => { @@ -180,8 +181,8 @@ export class StartProcessInstanceComponent implements OnChanges, OnInit { }); } - hasSingleProcessDefinition(): boolean { - return this.processDefinitions.length === 1; + isProcessDefinitionsEmpty(): boolean { + return this.processDefinitions.length === 0; } getAlfrescoRepositoryName(): string {