AAE-40741 Form rule Validate form doesn't do anything (#11788)

This commit is contained in:
David Olson
2026-04-06 09:44:23 -05:00
committed by GitHub
parent 74252797b7
commit 70a6f42649
14 changed files with 227 additions and 1 deletions
@@ -510,4 +510,38 @@ describe('DateCloudWidgetComponent', () => {
expect(widget.field.validationSummary.message).toBe('FORM.FIELD.REQUIRED');
});
});
describe('showAllValidationErrors', () => {
it('should mark dateInputControl as touched when showAllValidationErrors is true', () => {
widget.field = new FormFieldModel(form, {
id: 'date-field-id',
name: 'date-name',
type: 'date',
required: true
});
fixture.detectChanges();
expect(widget.dateInputControl.touched).toBe(false);
form.showAllValidationErrors = true;
widget.updateReactiveFormControl();
expect(widget.dateInputControl.touched).toBe(true);
});
it('should not mark dateInputControl as touched when showAllValidationErrors is false', () => {
widget.field = new FormFieldModel(form, {
id: 'date-field-id',
name: 'date-name',
type: 'date',
required: true
});
fixture.detectChanges();
form.showAllValidationErrors = false;
widget.updateReactiveFormControl();
expect(widget.dateInputControl.touched).toBe(false);
});
});
});
@@ -88,6 +88,9 @@ export class DateCloudWidgetComponent extends WidgetComponent implements OnInit,
updateReactiveFormControl(): void {
this.setFormControlValue();
this.updateFormControlState();
if (this.field?.form?.showAllValidationErrors) {
this.dateInputControl.markAsTouched();
}
this.validateField();
}
@@ -1410,6 +1410,44 @@ describe('DropdownCloudWidgetComponent', () => {
expect(allOptions.length).toEqual(1);
});
});
describe('showAllValidationErrors', () => {
it('should mark dropdownControl as touched when showAllValidationErrors is true', () => {
const form = new FormModel();
widget.field = new FormFieldModel(form, {
id: 'dropdown-id',
name: 'dropdown-name',
type: FormFieldTypes.DROPDOWN,
required: true,
options: fakeOptionList
});
fixture.detectChanges();
expect(widget.dropdownControl.touched).toBe(false);
form.showAllValidationErrors = true;
widget.updateReactiveFormControl();
expect(widget.dropdownControl.touched).toBe(true);
});
it('should not mark dropdownControl as touched when showAllValidationErrors is false', () => {
const form = new FormModel();
widget.field = new FormFieldModel(form, {
id: 'dropdown-id',
name: 'dropdown-name',
type: FormFieldTypes.DROPDOWN,
required: true,
options: fakeOptionList
});
fixture.detectChanges();
form.showAllValidationErrors = false;
widget.updateReactiveFormControl();
expect(widget.dropdownControl.touched).toBe(false);
});
});
});
describe('DropdownCloudWidgetComponent instantiated by FormFieldComponent wrapper', () => {
@@ -165,6 +165,9 @@ export class DropdownCloudWidgetComponent extends WidgetComponent implements OnI
this.setFormControlValue();
this.updateFormControlState();
if (this.field?.form?.showAllValidationErrors) {
this.dropdownControl.markAsTouched();
}
this.handleErrors();
}