diff --git a/src/app/shared/form/builder/ds-dynamic-form-ui/ds-dynamic-form-control-container.component.html b/src/app/shared/form/builder/ds-dynamic-form-ui/ds-dynamic-form-control-container.component.html index f844fab281f..57e71d7295b 100644 --- a/src/app/shared/form/builder/ds-dynamic-form-ui/ds-dynamic-form-control-container.component.html +++ b/src/app/shared/form/builder/ds-dynamic-form-ui/ds-dynamic-form-control-container.component.html @@ -8,9 +8,9 @@ @let showErrors = shouldShowErrorMessages(); @if (!isCheckbox && hasLabel && !isDateField) { - diff --git a/src/app/shared/form/builder/ds-dynamic-form-ui/ds-dynamic-form-control-container.component.spec.ts b/src/app/shared/form/builder/ds-dynamic-form-ui/ds-dynamic-form-control-container.component.spec.ts index 8fb617d0336..66d1a179523 100644 --- a/src/app/shared/form/builder/ds-dynamic-form-ui/ds-dynamic-form-control-container.component.spec.ts +++ b/src/app/shared/form/builder/ds-dynamic-form-ui/ds-dynamic-form-control-container.component.spec.ts @@ -494,4 +494,19 @@ describe('DsDynamicFormControlContainerComponent test suite', () => { expect(renderer.setAttribute).toHaveBeenCalledWith(inputEl, 'aria-label', 'Accessible Label'); }); + + it('should not have a for attribute on label when model type is ARRAY', () => { + const arrayModel = new DynamicFormArrayModel({ + id: 'formArray', + groupFactory: () => [], + }); + + component.model = arrayModel; + fixture.detectChanges(); + + expect(component.model.type).toBe('ARRAY'); + + const expectedFor = component.model.type === 'ARRAY' ? null : (component as any).id; + expect(expectedFor).toBeNull(); + }); }); diff --git a/src/app/shared/form/builder/ds-dynamic-form-ui/models/array-group/dynamic-form-array.component.html b/src/app/shared/form/builder/ds-dynamic-form-ui/models/array-group/dynamic-form-array.component.html index 75c4d089a7e..314f3dd9783 100644 --- a/src/app/shared/form/builder/ds-dynamic-form-ui/models/array-group/dynamic-form-array.component.html +++ b/src/app/shared/form/builder/ds-dynamic-form-ui/models/array-group/dynamic-form-array.component.html @@ -1,5 +1,6 @@
diff --git a/src/app/shared/form/builder/ds-dynamic-form-ui/models/array-group/dynamic-form-array.component.spec.ts b/src/app/shared/form/builder/ds-dynamic-form-ui/models/array-group/dynamic-form-array.component.spec.ts index 81591c44bfa..e8827124448 100644 --- a/src/app/shared/form/builder/ds-dynamic-form-ui/models/array-group/dynamic-form-array.component.spec.ts +++ b/src/app/shared/form/builder/ds-dynamic-form-ui/models/array-group/dynamic-form-array.component.spec.ts @@ -163,13 +163,17 @@ describe('DsDynamicFormArrayComponent', () => { expect(component.elementBeingSortedStartingIndex).toBeNull(); }); + it('should have aria-labelledby pointing to the label', () => { + const arrayDiv = fixture.debugElement.query(By.css(`#${component.model.id}`)); + expect(arrayDiv.nativeElement.getAttribute('aria-labelledby')).toBe('label_' + component.model.id); + }); + describe('moveFormControlToPosition', () => { it('should move form control from one position to another', () => { const formArray = component.control as any; const initialControls = formArray.controls.map((ctrl: any) => ctrl); const movedControl = initialControls[1]; - // Move control from index 1 to index 3 (component as any).moveFormControlToPosition(1, 3); expect(formArray.at(3)).toBe(movedControl); @@ -179,7 +183,6 @@ describe('DsDynamicFormArrayComponent', () => { it('should preserve form control values after move', () => { const formArray = component.control as any; - // Set actual values to the form controls formArray.at(0).patchValue({ testFormRowArrayGroupInput: 'Author 1' }); formArray.at(1).patchValue({ testFormRowArrayGroupInput: 'Author 2' }); formArray.at(2).patchValue({ testFormRowArrayGroupInput: 'Author 3' });