From ddbb5b3d654c679458d009fb22ef51c781961097 Mon Sep 17 00:00:00 2001 From: Eugenio Romano Date: Mon, 22 Oct 2018 17:39:58 +0100 Subject: [PATCH] [ADF-3684] not autoselect first process in start process when multi process are present in an app fix failing unit test --- .../content-metadata-card.component.spec.ts | 4 ++-- .../components/start-process.component.spec.ts | 10 ++++++++++ .../components/start-process.component.ts | 17 +++++++++++------ 3 files changed, 23 insertions(+), 8 deletions(-) diff --git a/lib/content-services/content-metadata/components/content-metadata-card/content-metadata-card.component.spec.ts b/lib/content-services/content-metadata/components/content-metadata-card/content-metadata-card.component.spec.ts index fb7b03bb7b..41ce3f5647 100644 --- a/lib/content-services/content-metadata/components/content-metadata-card/content-metadata-card.component.spec.ts +++ b/lib/content-services/content-metadata/components/content-metadata-card/content-metadata-card.component.spec.ts @@ -152,7 +152,7 @@ describe('ContentMetadataCardComponent', () => { const buttonLabel = fixture.debugElement.query(By.css('[data-automation-id="meta-data-card-toggle-expand-label"]')); - expect(buttonLabel.nativeElement.innerText.trim()).toBe('ADF_VIEWER.SIDEBAR.METADATA.MORE_INFORMATION'); + expect(buttonLabel.nativeElement.innerText.trim()).toBe('ADF_VIEWER.SIDEBAR.METADATA.LESS_INFORMATION'); }); it('should have the proper text on button while collapsed', () => { @@ -161,7 +161,7 @@ describe('ContentMetadataCardComponent', () => { const buttonLabel = fixture.debugElement.query(By.css('[data-automation-id="meta-data-card-toggle-expand-label"]')); - expect(buttonLabel.nativeElement.innerText.trim()).toBe('ADF_VIEWER.SIDEBAR.METADATA.LESS_INFORMATION'); + expect(buttonLabel.nativeElement.innerText.trim()).toBe('ADF_VIEWER.SIDEBAR.METADATA.MORE_INFORMATION'); }); it('should hide the edit button in readOnly is true', () => { 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 0f922f27a2..1fec2dd0f3 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 @@ -284,6 +284,16 @@ describe('StartFormComponent', () => { }); })); + it('should not select automatically any processDefinition if the app contain multiple process and does not have any processDefinition as input', async(() => { + getDefinitionsSpy = getDefinitionsSpy.and.returnValue(of(testMultipleProcessDefs)); + component.appId = 123; + component.ngOnChanges({}); + fixture.detectChanges(); + fixture.whenStable().then(() => { + expect(component.selectedProcessDef.name).toBeNull(); + }); + })); + describe('dropdown', () => { it('should hide the process dropdown button if showSelectProcessDropdown is false', async(() => { 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 9764e487c3..0027f5bdda 100644 --- a/lib/process-services/process-list/components/start-process.component.ts +++ b/lib/process-services/process-list/components/start-process.component.ts @@ -135,13 +135,15 @@ export class StartProcessInstanceComponent implements OnChanges, OnInit { } private _filter(value: string): ProcessDefinitionRepresentation[] { - const filterValue = value.toLowerCase(); - let filteredProcess = this.processDefinitions.filter(option => option.name.toLowerCase().includes(filterValue)); + if (value !== null && value !== undefined) { + const filterValue = value.toLowerCase(); + let filteredProcess = this.processDefinitions.filter(option => option.name.toLowerCase().includes(filterValue)); - if (this.processFilterSelector) { - this.selectedProcessDef = this.getSelectedProcess(filterValue); + if (this.processFilterSelector) { + this.selectedProcessDef = this.getSelectedProcess(filterValue); + } + return filteredProcess; } - return filteredProcess; } getSelectedProcess(selectedProcess) { @@ -162,7 +164,10 @@ export class StartProcessInstanceComponent implements OnChanges, OnInit { this.processDefinitions = processDefinitionRepresentations; if (!this.isProcessDefinitionsEmpty()) { - this.selectedProcessDef = this.processDefinitions[0]; + + if (this.processDefinitions.length == 1) { + this.selectedProcessDef = this.processDefinitions[0]; + } if (this.processDefinitionName) { let selectedProcess = this.processDefinitions.find((currentProcessDefinition) => {