[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) { this.enterProcessName = function (name) {
Util.waitUntilElementIsVisible(processNameInput); Util.waitUntilElementIsVisible(processNameInput);
processNameInput.clear(); this.clearProcessName();
processNameInput.sendKeys(name); processNameInput.sendKeys(name);
}; };
this.clearProcessName = function () {
processNameInput.clear();
};
this.selectFromProcessDropdown = function (name) { this.selectFromProcessDropdown = function (name) {
this.clickProcessDropdownArrow(); this.clickProcessDropdownArrow();
return this.selectOption(name); return this.selectOption(name);
@@ -97,6 +101,7 @@ var StartProcessPage = function () {
this.typeProcessDefinition = function (name) { this.typeProcessDefinition = function (name) {
Util.waitUntilElementIsVisible(processDefinition); Util.waitUntilElementIsVisible(processDefinition);
Util.waitUntilElementIsClickable(processDefinition); Util.waitUntilElementIsClickable(processDefinition);
processDefinition.clear();
processDefinition.sendKeys(name); processDefinition.sendKeys(name);
return this; return this;
}; };

View File

@@ -150,6 +150,7 @@ describe('Start Process Component', () => {
processFiltersPage.clickCreateProcessButton(); processFiltersPage.clickCreateProcessButton();
processFiltersPage.clickNewProcessDropdown(); processFiltersPage.clickNewProcessDropdown();
startProcessPage.enterProcessName(''); startProcessPage.enterProcessName('');
browser.actions().sendKeys('v\b\b').perform(); // clear doesnt' trigger the validator
startProcessPage.checkStartProcessButtonIsDisabled(); startProcessPage.checkStartProcessButtonIsDisabled();
startProcessPage.clickCancelProcessButton(); startProcessPage.clickCancelProcessButton();
processFiltersPage.checkNoContentMessage(); processFiltersPage.checkNoContentMessage();

View File

@@ -131,7 +131,6 @@ describe('StartFormComponent', () => {
it('should initialize start form', async(() => { it('should initialize start form', async(() => {
fixture.detectChanges(); fixture.detectChanges();
fixture.whenStable().then(() => { fixture.whenStable().then(() => {
expect(component.startForm).toBeDefined(); expect(component.startForm).toBeDefined();
expect(component.startForm).not.toBeNull(); expect(component.startForm).not.toBeNull();
@@ -203,19 +202,21 @@ describe('StartFormComponent', () => {
describe('process definitions list', () => { 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.appId = 123;
component.ngOnChanges({}); component.ngOnChanges({});
fixture.detectChanges(); fixture.detectChanges();
});
it('should call service to fetch process definitions with appId', () => {
fixture.whenStable().then(() => { fixture.whenStable().then(() => {
expect(getDefinitionsSpy).toHaveBeenCalledWith(123); expect(getDefinitionsSpy).toHaveBeenCalledWith(123);
}); });
}); });
it('should display the correct number of processes in the select list', () => { it('should display the correct number of processes in the select list', () => {
component.appId = 123;
component.ngOnChanges({});
fixture.detectChanges();
fixture.whenStable().then(() => { fixture.whenStable().then(() => {
let selectElement = fixture.nativeElement.querySelector('mat-select'); let selectElement = fixture.nativeElement.querySelector('mat-select');
expect(selectElement.children.length).toBe(1); expect(selectElement.children.length).toBe(1);
@@ -223,8 +224,6 @@ describe('StartFormComponent', () => {
}); });
it('should display the option def details', () => { it('should display the option def details', () => {
component.appId = 123;
component.ngOnChanges({});
component.processDefinitions = testMultipleProcessDefs; component.processDefinitions = testMultipleProcessDefs;
fixture.detectChanges(); fixture.detectChanges();
fixture.whenStable().then(() => { fixture.whenStable().then(() => {
@@ -265,7 +264,6 @@ describe('StartFormComponent', () => {
})); }));
it('should select processDefinition based on processDefinition input', async(() => { it('should select processDefinition based on processDefinition input', async(() => {
fixture.detectChanges();
getDefinitionsSpy = getDefinitionsSpy.and.returnValue(of(testMultipleProcessDefs)); getDefinitionsSpy = getDefinitionsSpy.and.returnValue(of(testMultipleProcessDefs));
component.appId = 123; component.appId = 123;
component.processNameInput.setValue('My Process 2'); 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(() => { it('should select automatically the processDefinition if the app contain only one', async(() => {
fixture.detectChanges();
getDefinitionsSpy = getDefinitionsSpy.and.returnValue(of(testProcessDefinitions)); getDefinitionsSpy = getDefinitionsSpy.and.returnValue(of(testProcessDefinitions));
component.appId = 123; component.appId = 123;
component.ngOnChanges({}); component.ngOnChanges({});
@@ -303,6 +300,7 @@ describe('StartFormComponent', () => {
})); }));
it('should show the process dropdown button if showSelectProcessDropdown is false', async(() => { it('should show the process dropdown button if showSelectProcessDropdown is false', async(() => {
fixture.detectChanges();
getDefinitionsSpy = getDefinitionsSpy.and.returnValue(of(testMultipleProcessDefs)); getDefinitionsSpy = getDefinitionsSpy.and.returnValue(of(testMultipleProcessDefs));
component.appId = 123; component.appId = 123;
component.processDefinitionName = 'My Process 2'; component.processDefinitionName = 'My Process 2';
@@ -316,6 +314,7 @@ describe('StartFormComponent', () => {
})); }));
it('should show the process dropdown button by default', async(() => { it('should show the process dropdown button by default', async(() => {
fixture.detectChanges();
getDefinitionsSpy = getDefinitionsSpy.and.returnValue(of(testMultipleProcessDefs)); getDefinitionsSpy = getDefinitionsSpy.and.returnValue(of(testMultipleProcessDefs));
component.appId = 123; component.appId = 123;
component.processDefinitionName = 'My Process 2'; component.processDefinitionName = 'My Process 2';
@@ -363,6 +362,7 @@ describe('StartFormComponent', () => {
describe('start process', () => { describe('start process', () => {
beforeEach(() => { beforeEach(() => {
fixture.detectChanges();
component.name = 'My new process'; component.name = 'My new process';
component.appId = 123; component.appId = 123;
component.ngOnChanges({}); component.ngOnChanges({});

View File

@@ -161,18 +161,19 @@ export class StartProcessInstanceComponent implements OnChanges, OnInit {
(processDefinitionRepresentations: ProcessDefinitionRepresentation[]) => { (processDefinitionRepresentations: ProcessDefinitionRepresentation[]) => {
this.processDefinitions = processDefinitionRepresentations; this.processDefinitions = processDefinitionRepresentations;
if (this.hasSingleProcessDefinition()) { if (!this.isProcessDefinitionsEmpty()) {
this.selectedProcessDef = this.processDefinitions[0]; this.selectedProcessDef = this.processDefinitions[0];
} else {
this.selectedProcessDef = this.processDefinitions.find((currentProcessDefinition) => {
return currentProcessDefinition.name === this.processDefinitionName;
});
}
if (this.selectedProcessDef) { if (this.processDefinitionName) {
if (this.processDefinitionInput) { let selectedProcess = this.processDefinitions.find((currentProcessDefinition) => {
this.processDefinitionInput.setValue(this.selectedProcessDef.name); 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 { isProcessDefinitionsEmpty(): boolean {
return this.processDefinitions.length === 1; return this.processDefinitions.length === 0;
} }
getAlfrescoRepositoryName(): string { getAlfrescoRepositoryName(): string {