[AAE-6310] Fix for attaching files (#7457)

* [AAE-6310] Fix for attaching files

* [AAE-6310] Update

* [AAE-6310] Revert indentions changes

* [AAE-6310] Fix tests
This commit is contained in:
Bartosz Sekuła
2022-01-24 12:36:35 +01:00
committed by GitHub
parent 4de725e559
commit bf77663d6a
2 changed files with 30 additions and 14 deletions

View File

@@ -44,6 +44,7 @@ import { TranslateModule } from '@ngx-translate/core';
import { ProcessNameCloudPipe } from '../../../pipes/process-name-cloud.pipe';
import { ProcessInstanceCloud } from '../models/process-instance-cloud.model';
import { ESCAPE } from '@angular/cdk/keycodes';
import { ProcessDefinitionCloud } from 'process-services-cloud';
describe('StartProcessCloudComponent', () => {
@@ -827,17 +828,32 @@ describe('StartProcessCloudComponent', () => {
expect(component.processInstanceName.value).toEqual('fake-transformed-name');
});
it('should set the process name on init when a process definition name is present', () => {
it('should set the process name on when a process definition name is present', (done) => {
const definitions: ProcessDefinitionCloud[] = [{
appName: 'app',
appVersion: 1,
category: '',
description: '',
id: 'id',
key: 'key',
name: 'fake-name',
version: 1
}];
component.processInstanceName.valueChanges.subscribe((value) => {
expect(value).toBe(fakeTransformedName);
done();
});
getDefinitionsSpy.and.returnValue(of(definitions));
const processNameCloudPipe = TestBed.inject(ProcessNameCloudPipe);
const fakeTransformedName = 'fake-transformed-name';
spyOn(processNameCloudPipe, 'transform').and.returnValue(fakeTransformedName);
component.processDefinitionName = 'fake-name';
component.ngOnInit();
expect(component.processInstanceName.dirty).toBe(true);
expect(component.processInstanceName.touched).toBe(true);
expect(component.processInstanceName.value).toEqual(fakeTransformedName);
const change = new SimpleChange(null, 'MyApp', true);
component.ngOnChanges({ 'appName': change });
});
it('should cancel bubbling a keydown event ()', () => {

View File

@@ -139,14 +139,6 @@ export class StartProcessCloudComponent implements OnChanges, OnInit, OnDestroy
this.currentCreatedProcess = res;
this.disableStartButton = false;
});
if (this.processDefinitionName) {
this.processDefinition.setValue(this.processDefinitionName);
this.processDefinition.markAsDirty();
this.processDefinition.markAsTouched();
this.setDefaultProcessName(this.processDefinitionName);
}
}
ngOnChanges(changes: SimpleChanges) {
@@ -197,6 +189,7 @@ export class StartProcessCloudComponent implements OnChanges, OnInit, OnDestroy
private selectProcessDefinitionByProcesDefinitionName(processDefinitionName: string): void {
this.filteredProcesses = this.getProcessDefinitionListByNameOrKey(processDefinitionName);
if (this.isProcessFormValid() &&
this.filteredProcesses && this.filteredProcesses.length === 1) {
this.setProcessDefinitionOnForm(this.filteredProcesses[0].name);
@@ -252,6 +245,13 @@ export class StartProcessCloudComponent implements OnChanges, OnInit, OnDestroy
this.selectDefaultProcessDefinition();
} else if (this.processDefinitionName) {
this.processDefinition.setValue(this.processDefinitionName);
const processDefinition = this.processDefinitionList.find(process => process.name === this.processDefinitionName);
if (processDefinition) {
this.filteredProcesses = this.getProcessDefinitionListByNameOrKey(processDefinition.name);
this.setProcessDefinitionOnForm(processDefinition.name);
this.processDefinitionSelectionChanged(processDefinition);
}
}
},
() => {