[ADF-3639] Fix default selected process at Start Process Component (#3848)

* [ADF-3639] Fix default selected process at Start Process Component

* [ADF-3639] Fix default selected process at Start Process Component
fix e2e

* lint fix
This commit is contained in:
davidcanonieto
2018-10-03 17:47:32 +01:00
committed by Eugenio Romano
parent 718b3e8817
commit 07fb1da8c6
4 changed files with 28 additions and 21 deletions

View File

@@ -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;
};

View File

@@ -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();

View File

@@ -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({});

View File

@@ -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 {