mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2026-09-09 18:03:21 +00:00
AAE-45774 Show error for date fields if invalid format (#11886)
* AAE-45774 Show error for date fields if invalid format * apply copilot suggestions
This commit is contained in:
+5
@@ -82,6 +82,11 @@
|
|||||||
[startAt]="valueDate"
|
[startAt]="valueDate"
|
||||||
[ngClass]="{ 'cdk-visually-hidden': !editable || isReadonlyProperty}"
|
[ngClass]="{ 'cdk-visually-hidden': !editable || isReadonlyProperty}"
|
||||||
/>
|
/>
|
||||||
|
@if (cardViewDateTimeControl.hasError('matDatepickerParse')) {
|
||||||
|
<mat-error>
|
||||||
|
{{ 'FORM.FIELD.VALIDATOR.INVALID_DATE_FORMAT' | translate: { format: property.format ?? '' } }}
|
||||||
|
</mat-error>
|
||||||
|
}
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
} @else {
|
} @else {
|
||||||
<mat-form-field class="adf-property-field adf-dateitem-editable" [floatLabel]="property.default ? 'always' : null">
|
<mat-form-field class="adf-property-field adf-dateitem-editable" [floatLabel]="property.default ? 'always' : null">
|
||||||
|
|||||||
+15
@@ -459,6 +459,21 @@ describe('CardViewDateItemComponent', () => {
|
|||||||
expect(component.cardViewDateTimeControl.value).not.toBeNull();
|
expect(component.cardViewDateTimeControl.value).not.toBeNull();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should render error message when manual input has invalid date format', async () => {
|
||||||
|
fixture.detectChanges();
|
||||||
|
|
||||||
|
const manualInput = await testingUtils.getMatInputByDataAutomationId('datepicker-manual-input-dateKey');
|
||||||
|
await manualInput.setValue('not-a-date');
|
||||||
|
await manualInput.blur();
|
||||||
|
fixture.detectChanges();
|
||||||
|
await fixture.whenStable();
|
||||||
|
fixture.detectChanges();
|
||||||
|
|
||||||
|
expect(component.cardViewDateTimeControl.invalid).toBeTrue();
|
||||||
|
const formField = await testingUtils.getMatFormFieldByCSS('.adf-dateitem-editable');
|
||||||
|
expect(await formField.getTextErrors()).toContain('FORM.FIELD.VALIDATOR.INVALID_DATE_FORMAT');
|
||||||
|
});
|
||||||
|
|
||||||
it('should clear the form control value when onDateClear is called', () => {
|
it('should clear the form control value when onDateClear is called', () => {
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user