diff --git a/alfa-client/libs/admin-settings/src/lib/postfach/postfach-container/postfach-form/postfach-form.component.html b/alfa-client/libs/admin-settings/src/lib/postfach/postfach-container/postfach-form/postfach-form.component.html index a249e953cf0c28c06d636583162c57166b91e011..1810d165698be792d5230c7180a462d64b3a83e6 100644 --- a/alfa-client/libs/admin-settings/src/lib/postfach/postfach-container/postfach-form/postfach-form.component.html +++ b/alfa-client/libs/admin-settings/src/lib/postfach/postfach-container/postfach-form/postfach-form.component.html @@ -4,26 +4,31 @@ <div aria-describedby="absender-desc" class="grid-col-1 mb-2 mt-2 grid w-96 gap-1"> <text-field inputId="absender-name" + data-test-id="absender-name" label="Name" [formControlName]="PostfachFormService.NAME_FIELD" ></text-field> <text-field inputId="absender-anschrift" + data-test-id="absender-anschrift" label="Anschrift" [formControlName]="PostfachFormService.ANSCHRIFT_FIELD" ></text-field> <text-field inputId="absender-dienst" + data-test-id="absender-dienst" label="Dienst" [formControlName]="PostfachFormService.DIENST_FIELD" ></text-field> <text-field inputId="absender-mandant" + data-test-id="absender-mandant" label="Mandant" [formControlName]="PostfachFormService.MANDANT_FIELD" ></text-field> <text-field inputId="absender-gemeindeschluessel" + data-test-id="absender-gemeindeschluessel" label="Gemeindeschlüssel" [formControlName]="PostfachFormService.GEMEINDESCHLUESSEL_FIELD" ></text-field> diff --git a/alfa-client/libs/admin-settings/src/lib/postfach/postfach-container/postfach-form/postfach-form.component.spec.ts b/alfa-client/libs/admin-settings/src/lib/postfach/postfach-container/postfach-form/postfach-form.component.spec.ts index 8145697c974f674f69218c846247570b0bb77b47..b71dc55347a0bd7ee88ffd09ac83f46a459ac1fa 100644 --- a/alfa-client/libs/admin-settings/src/lib/postfach/postfach-container/postfach-form/postfach-form.component.spec.ts +++ b/alfa-client/libs/admin-settings/src/lib/postfach/postfach-container/postfach-form/postfach-form.component.spec.ts @@ -38,18 +38,29 @@ describe('PostfachFormComponent', () => { }); describe('Absender section', () => { - test.each([ - [PostfachFormService.NAME_FIELD, 'Name'], - [PostfachFormService.ANSCHRIFT_FIELD, 'Anschrift'], - [PostfachFormService.DIENST_FIELD, 'Dienst'], - [PostfachFormService.MANDANT_FIELD, 'Mandant'], - [PostfachFormService.GEMEINDESCHLUESSEL_FIELD, 'Gemeindeschlüssel'], - ])('should have label for field "%s" with name "%s"', (fieldId, text) => { - const textFieldElement = getElementFromFixture( - fixture, - `text-field[inputId=absender-${fieldId}]`, - ); - expect(textFieldElement.getAttribute('label')).toBe(text); + const fields = [ + [PostfachFormService.NAME_FIELD, 'Name', 'absender-name'], + [PostfachFormService.ANSCHRIFT_FIELD, 'Anschrift', 'absender-anschrift'], + [PostfachFormService.DIENST_FIELD, 'Dienst', 'absender-dienst'], + [PostfachFormService.MANDANT_FIELD, 'Mandant', 'absender-mandant'], + [ + PostfachFormService.GEMEINDESCHLUESSEL_FIELD, + 'Gemeindeschlüssel', + 'absender-gemeindeschluessel', + ], + ]; + + test.each(fields)( + 'should have label for field "%s" with name "%s"', + (fieldName, text, inputId) => { + const textFieldElement = getElementFromFixture(fixture, getDataTestIdOf(inputId)); + expect(textFieldElement.getAttribute('label')).toBe(text); + }, + ); + + test.each(fields)('should have inputId for field "%s"', (fieldName, text, inputId) => { + const textFieldElement = getElementFromFixture(fixture, getDataTestIdOf(inputId)); + expect(textFieldElement.getAttribute('inputId')).toBe(inputId); }); });