[AAE-2321] Should not be able to start a process with space as name (Process Services) (#5616)

* New regex validator for process name for checking if there is a space character as the first or the las one in the name.

* Added 2 new error messages for process name: Required and Pattern(no space in the beginning or the end). Changed the disabled start process button validation function.

* Unit test to disable the start button if the pattern validator for process name is raised.

* Added 2 new error messages for process start
This commit is contained in:
Urse Daniel 2020-04-18 01:37:49 +03:00 committed by GitHub
parent 3f69a6d3a9
commit bc2d7f16fd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 22 additions and 3 deletions

View File

@ -288,7 +288,9 @@
"ERROR": {
"LOAD_PROCESS_DEFS": "Couldn't load process definitions, check you have access.",
"START": "Couldn't start new process instance, check you have access.",
"MAXIMUM_LENGTH": "Length exceeded, {{characters}} characters max."
"MAXIMUM_LENGTH": "Length exceeded, {{characters}} characters max.",
"SPACE_VALIDATOR": "Space is not allowed in the beginning or the end of the text.",
"PROCESS_NAME_REQUIRED": "Process name is required."
}
},
"PROCESS-ATTACHMENT": {

View File

@ -43,13 +43,19 @@
<mat-error *ngIf="nameController.hasError('maxlength')">
{{ 'ADF_PROCESS_LIST.START_PROCESS.ERROR.MAXIMUM_LENGTH' | translate : { characters : maxProcessNameLength } }}
</mat-error>
<mat-error *ngIf="nameController.hasError('required')">
{{ 'ADF_PROCESS_LIST.START_PROCESS.ERROR.PROCESS_NAME_REQUIRED' | translate }}
</mat-error>
<mat-error *ngIf="nameController.hasError('pattern')">
{{ 'ADF_PROCESS_LIST.START_PROCESS.ERROR.SPACE_VALIDATOR' | translate }}
</mat-error>
</mat-form-field>
<adf-start-form
#startForm
*ngIf="hasStartForm()"
[data]="values"
[disableStartProcessButton]="!hasProcessName()"
[disableStartProcessButton]="!validateForm()"
[processDefinitionId]="selectedProcessDef.id"
(outcomeClick)="onOutcomeClick($event)"
[showRefreshButton]="false">

View File

@ -129,6 +129,17 @@ describe('StartFormComponent', () => {
expect(startBtn.disabled).toBe(true);
});
}));
it('should have start button disabled process name has a space as the first or last character.', async(() => {
component.processNameInput.setValue(' Space in the beginning');
component.processDefinitionInput.setValue(testProcessDef.name);
fixture.detectChanges();
const startBtn = fixture.nativeElement.querySelector('#button-start');
expect(startBtn.disabled).toBe(true);
component.processNameInput.setValue('Space in the end ');
fixture.detectChanges();
expect(startBtn.disabled).toBe(true);
}));
});
describe('with start form', () => {

View File

@ -117,7 +117,7 @@ export class StartProcessInstanceComponent implements OnChanges, OnInit, OnDestr
}
ngOnInit() {
this.processNameInput = new FormControl(this.name, [Validators.required, Validators.maxLength(this.maxProcessNameLength)]);
this.processNameInput = new FormControl(this.name, [Validators.required, Validators.maxLength(this.maxProcessNameLength), Validators.pattern('^[^\\s]+(\\s+[^\\s]+)*$')]);
this.processDefinitionInput = new FormControl();
this.loadStartProcess();