mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[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:
committed by
Eugenio Romano
parent
718b3e8817
commit
07fb1da8c6
@@ -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({});
|
||||
|
@@ -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 {
|
||||
|
Reference in New Issue
Block a user