diff --git a/alfa-client/apps/admin-e2e/src/components/benutzer/benutzer.e2e.component.ts b/alfa-client/apps/admin-e2e/src/components/benutzer/benutzer.e2e.component.ts index 0af0f39b14cfd07cdd0ad868b8c780c1bbbea19f..7b9027ffdc33f6f5cef1980aac392859a457237d 100644 --- a/alfa-client/apps/admin-e2e/src/components/benutzer/benutzer.e2e.component.ts +++ b/alfa-client/apps/admin-e2e/src/components/benutzer/benutzer.e2e.component.ts @@ -22,154 +22,128 @@ * unter der Lizenz sind dem Lizenztext zu entnehmen. */ import 'cypress-real-events'; -import { AdminUserE2E } from '../../model/util'; -import { exist } from '../../support/cypress.util'; +import { convertToDataTestId } from '../../support/tech-util'; -export class BenutzerE2EComponent { +export class BenutzerListE2EComponent { + private readonly headline: string = 'user-list-headline'; private readonly benutzerHinzufuegenButton: string = 'add-user-button'; - private readonly userEntry: string = 'user-entry-'; - private readonly userVorname: string = 'Vorname-text-input'; - private readonly userNachname: string = 'Nachname-text-input'; - private readonly userBenutzername: string = 'Benutzername-text-input'; - private readonly userMail: string = 'E-Mail-text-input'; - private readonly adminCheckbox: string = 'Admin-checkbox-editor'; - private readonly loeschenCheckbox: string = 'Loschen-checkbox-editor'; - private readonly userCheckbox: string = 'User-checkbox-editor'; - private readonly postCheckbox: string = 'Poststelle-checkbox-editor'; - private readonly saveButton: string = 'save-button'; - private readonly organisationsEinheitCheckbox: string = '-checkbox-editor'; + + public getHeadline(): Cypress.Chainable<Element> { + return cy.getTestElement(this.headline); + } public getHinzufuegenButton(): Cypress.Chainable<Element> { return cy.getTestElement(this.benutzerHinzufuegenButton); } - public hinzufuegenButtonIsVisible(): void { - exist(this.getHinzufuegenButton()); + public getItem(userName: string): BenutzerListItemE2EComponent { + return new BenutzerListItemE2EComponent(userName); } +} + +export class BenutzerListItemE2EComponent { + private root: string; - public clickAddUser(): void { - this.getHinzufuegenButton().click(); + private fullName: string = 'fullname'; + private email: string = 'email'; + private userName: string = 'username'; + + private roles: string = 'roles'; + + private organisationsEinheiten: string = 'organisations-einheiten'; + private noOrganisationsEinheitenText: string = 'no-organisations-einheit-text'; + + constructor(userName: string) { + this.root = convertToDataTestId(userName) + '-user-entry'; } - public addUser(user: AdminUserE2E): void { - this.enterVorname(user.vorname); - this.enterNachname(user.nachname); - this.enterBenutzername(user.benutzername); - this.enterMail(user.email); + public getRoot(): Cypress.Chainable<Element> { + return cy.getTestElement(this.root); + } - if (user.isAdmin) { - this.clickAdminCheckbox(); - } - if (user.isUser) { - this.clickUserCheckbox(); - } - if (user.isLoeschen) { - this.clickLoeschenCheckbox(); - } - if (user.isPoststelle) { - this.clickPostCheckbox(); - } + public getRoles(): Cypress.Chainable<Element> { + return this.getRoot().getTestElementWithClass(this.roles); + } - if (user.organisationseinheiten) { - for (const einheit of user.organisationseinheiten) { - this.clickOrganisationsEinheitCheckbox(einheit); - } - } - this.saveUser(); + public getOrganisationsEinheiten(): Cypress.Chainable<Element> { + return this.getRoot().getTestElementWithClass(this.organisationsEinheiten); } - public getUserEntry(user: string): Cypress.Chainable<Element> { - user = this.userEntry + user; - return cy.getTestElement(user); + public getNoOrganisationsEinheitText(): Cypress.Chainable<Element> { + return this.getRoot().getTestElementWithClass(this.noOrganisationsEinheitenText); } - public clickUserEntry(user: string): void { - this.getUserEntry(user).click(); + public getFullName(): Cypress.Chainable<Element> { + return this.getRoot().getTestElementWithClass(this.fullName); } - public stringExistsInUserEntry(phrase: string, user: string): void { - this.getUserEntry(user).within(() => { - exist(cy.contains(phrase)); - }); + public getEMail(): Cypress.Chainable<Element> { + return this.getRoot().getTestElementWithClass(this.email); } - public getVornameInput(): Cypress.Chainable<Element> { - return cy.getTestElement(this.userVorname); + public getUserName(): Cypress.Chainable<Element> { + return this.getRoot().getTestElementWithClass(this.userName); } +} + +export class BenutzerE2EComponent { + private readonly headline: string = 'benutzer-form-headline'; - public enterVorname(vorname: string): void { - this.getVornameInput().type(vorname); + private readonly userVorname: string = 'Vorname-text-input'; + private readonly userNachname: string = 'Nachname-text-input'; + private readonly userBenutzername: string = 'Benutzername-text-input'; + private readonly userMail: string = 'E-Mail-text-input'; + + private readonly adminCheckbox: string = 'Admin-checkbox-editor'; + private readonly loeschenCheckbox: string = 'Loschen-checkbox-editor'; + private readonly userCheckbox: string = 'User-checkbox-editor'; + private readonly postCheckbox: string = 'Poststelle-checkbox-editor'; + + private readonly organisationsEinheitCheckboxSuffix: string = '-checkbox-editor'; + + private readonly saveButton: string = 'save-button'; + + public getVornameInput(): Cypress.Chainable<Element> { + return cy.getTestElement(this.userVorname); } public getNachnameInput(): Cypress.Chainable<Element> { return cy.getTestElement(this.userNachname); } - public enterNachname(nachname: string): void { - this.getNachnameInput().type(nachname); - } - public getBenutzernameInput(): Cypress.Chainable<Element> { return cy.getTestElement(this.userBenutzername); } - public enterBenutzername(benutzername: string): void { - this.getBenutzernameInput().type(benutzername); - } - public getMailInput(): Cypress.Chainable<Element> { return cy.getTestElement(this.userMail); } - public enterMail(mail: string): void { - this.getMailInput().type(mail); - } - public getAdminCheckbox(): Cypress.Chainable<Element> { return cy.getTestElement(this.adminCheckbox); } - public clickAdminCheckbox(): void { - this.getAdminCheckbox().click(); - } - - public getLoeschenCheckbox() { + public getLoeschenCheckbox(): Cypress.Chainable<Element> { return cy.getTestElement(this.loeschenCheckbox); } - public clickLoeschenCheckbox(): void { - this.getLoeschenCheckbox().click(); - } - public getUserCheckbox(): Cypress.Chainable<Element> { return cy.getTestElement(this.userCheckbox); } - public clickUserCheckbox(): void { - this.getUserCheckbox().click(); - } - public getPostCheckbox(): Cypress.Chainable<Element> { return cy.getTestElement(this.postCheckbox); } - public clickPostCheckbox(): void { - this.getPostCheckbox().click(); - } - public getSaveButton(): Cypress.Chainable<Element> { return cy.getTestElement(this.saveButton); } - public saveUser(): void { - this.getSaveButton().click(); - } - public getOrganisationsEinheitCheckbox(einheit: string): Cypress.Chainable<Element> { - return cy.getTestElement(einheit + this.organisationsEinheitCheckbox); + return cy.getTestElement(einheit + this.organisationsEinheitCheckboxSuffix); } - public clickOrganisationsEinheitCheckbox(einheit: string): void { - this.getOrganisationsEinheitCheckbox(einheit).click(); + public getHeadline(): Cypress.Chainable<Element> { + return cy.getTestElement(this.headline); } } diff --git a/alfa-client/apps/admin-e2e/src/components/organisationseinheiten/organisationseinheiten-signatur.e2e.component.ts b/alfa-client/apps/admin-e2e/src/components/organisationseinheiten/organisationseinheiten-signatur.e2e.component.ts deleted file mode 100644 index e1f91229ad68813bbab4625854ddc2ed6f89b79d..0000000000000000000000000000000000000000 --- a/alfa-client/apps/admin-e2e/src/components/organisationseinheiten/organisationseinheiten-signatur.e2e.component.ts +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (C) 2024 Das Land Schleswig-Holstein vertreten durch den - * Ministerpräsidenten des Landes Schleswig-Holstein - * Staatskanzlei - * Abteilung Digitalisierung und zentrales IT-Management der Landesregierung - * - * Lizenziert unter der EUPL, Version 1.2 oder - sobald - * diese von der Europäischen Kommission genehmigt wurden - - * Folgeversionen der EUPL ("Lizenz"); - * Sie dürfen dieses Werk ausschließlich gemäß - * dieser Lizenz nutzen. - * Eine Kopie der Lizenz finden Sie hier: - * - * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12 - * - * Sofern nicht durch anwendbare Rechtsvorschriften - * gefordert oder in schriftlicher Form vereinbart, wird - * die unter der Lizenz verbreitete Software "so wie sie - * ist", OHNE JEGLICHE GEWÄHRLEISTUNG ODER BEDINGUNGEN - - * ausdrücklich oder stillschweigend - verbreitet. - * Die sprachspezifischen Genehmigungen und Beschränkungen - * unter der Lizenz sind dem Lizenztext zu entnehmen. - */ -import { clearText, haveValue, typeText } from '../../support/cypress.util'; - -export class OrganisationseinheitenSignaturE2EComponent { - private readonly organisationsEinheitName: string = 'organisations-form-container-headline'; - private readonly signatureText: string = 'signature-textarea'; - private readonly saveSignatureButton: string = 'save-button'; - - public getOrganisationsEinheitName(): Cypress.Chainable<Element> { - return cy.getTestElement(this.organisationsEinheitName); - } - - public getSignatureText(): Cypress.Chainable<Element> { - return cy.getTestElement(this.signatureText); - } - - public setSignature(signatur: string): void { - this.clearSignature(); - typeText(this.getSignatureText(), signatur); - } - - public clearSignature(): void { - clearText(this.getSignatureText()); - } - - public getSaveButton(): Cypress.Chainable<Element> { - return cy.getTestElement(this.saveSignatureButton); - } - - public saveSignature(): void { - this.getSaveButton().click(); - } - - public hasSignature(compare: string): void { - haveValue(this.getSignatureText(), compare); - } - - public hasScrollbar(): void { - this.getSignatureText().then((textarea) => { - const scrollHeight = textarea[0].scrollHeight; - const clientHeight = textarea[0].clientHeight; - - expect(scrollHeight).to.be.greaterThan(clientHeight); - }); - } -} diff --git a/alfa-client/apps/admin-e2e/src/components/organisationseinheiten/organisationseinheiten.e2e.component.ts b/alfa-client/apps/admin-e2e/src/components/organisationseinheiten/organisationseinheiten.e2e.component.ts index 4d38f761c34b586f7da999a6a2e46a1d74056371..bfdf6b624d856e9b1a165f8984e739deccdc4a80 100644 --- a/alfa-client/apps/admin-e2e/src/components/organisationseinheiten/organisationseinheiten.e2e.component.ts +++ b/alfa-client/apps/admin-e2e/src/components/organisationseinheiten/organisationseinheiten.e2e.component.ts @@ -21,66 +21,21 @@ * Die sprachspezifischen Genehmigungen und Beschränkungen * unter der Lizenz sind dem Lizenztext zu entnehmen. */ -import { containClass, exist, haveText, notContainClass } from '../../support/cypress.util'; export class OrganisationsEinheitenE2EComponent { private readonly organisationsEinheitenList: string = 'organisations-einheit-list'; - private readonly organisationsEinheitenName: string = 'organisations-einheit-name'; - private readonly organisationsEinheitenID: string = 'organisations-einheit-id'; private readonly organisationsEinheitHinzufuegen: string = 'add-organisationseinheit-button'; - private readonly errorColor: string = 'text-red-500'; - private readonly errorIcon: string = 'organisations-einheit-sync-error'; - - private readonly errorText: string = 'Organisationseinheit wurde nicht in den PVOG-Daten gefunden.'; + private readonly organisationsEinheitItemSuffix: string = '-organisation-item'; public getOrganisationsEinheitList(): Cypress.Chainable<Element> { return cy.getTestElement(this.organisationsEinheitenList); } - public getListItemByName(name: string): Cypress.Chainable<JQuery<HTMLElement>> { - return cy.getTestElement(this.organisationsEinheitenName).contains(name); - } - - public openOrganisationsEinheit(name: string): void { - this.getListItemByName(name).click(); - } - public getOrganisationsEinheitHinzufuegenButton(): Cypress.Chainable<Element> { return cy.getTestElement(this.organisationsEinheitHinzufuegen); } - public clickHinzufuegen(): void { - this.getOrganisationsEinheitHinzufuegenButton().click(); - } - - public organisationsEinheitContainsID(name: string, id: string): void { - this.getListItemByName(name) - .parents('a') - .within(() => { - haveText(cy.getTestElement(this.organisationsEinheitenID), id); - }); - } - - public elementIsShownAsError(name: string): void { - containClass(this.getListItemByName(name).closest('ods-list-item'), this.errorColor); - } - - public getErrorIconInElement(name: string): Cypress.Chainable<JQuery<HTMLAnchorElement>> { - return this.getListItemByName(name) - .parents('a') - .within(() => { - exist(cy.getTestElement(this.errorIcon)); - }); - } - - public getErrorTooltip(name: string): Cypress.Chainable<JQuery<HTMLElement>> { - return this.getErrorIconInElement(name) - .find('ods-exclamation-icon[mattooltip]') - .should('have.attr', 'mattooltip') - .and('include', this.errorText); - } - - public elementShowsNoError(name: string): void { - notContainClass(this.getListItemByName(name).closest('ods-list-item'), this.errorColor); + public getListItem(name: string) { + return cy.getTestElement(name + this.organisationsEinheitItemSuffix); } } diff --git a/alfa-client/apps/admin-e2e/src/components/statistik/statistik-fields-form.e2e.component.ts b/alfa-client/apps/admin-e2e/src/components/statistik/statistik-fields-form.e2e.component.ts index f3c565869006d9935a5c54de0a9fb388d73cbc3c..8936e02edbe69c765364304bc497d2be61a970da 100644 --- a/alfa-client/apps/admin-e2e/src/components/statistik/statistik-fields-form.e2e.component.ts +++ b/alfa-client/apps/admin-e2e/src/components/statistik/statistik-fields-form.e2e.component.ts @@ -1,15 +1,16 @@ import { enterWith } from '../../support/cypress.util'; export class StatistikFieldsFormE2EComponent { - private readonly locatorFormEngineInput: string = 'form-engine-input'; - private readonly locatorFormIdInput: string = 'form-id-input'; - private readonly locatorFormDataFieldInput: string = 'data-statistik-field-'; - private readonly locatorAddFieldButton: string = 'add-data-field-button'; - private readonly locatorSaveButton: string = 'save-statistik-fields-button'; - private readonly locatorCancelButton: string = 'cancel-statistik-fields-button'; + private readonly formEngineInput: string = 'form-engine-name-text-input'; + private readonly formIdInput: string = 'form-id-text-input'; + private readonly formDataFieldInput: string = 'mapping-field-'; + private readonly addDataFieldButton: string = 'add-mapping-button'; + private readonly deleteDataFieldButtonPrefix: string = 'remove-mapping-button-'; + private readonly saveButton: string = 'save-button'; + private readonly cancelButton: string = 'cancel-button'; public getFormEngineInput(): Cypress.Chainable<Element> { - return cy.getTestElement(this.locatorFormEngineInput); + return cy.getTestElement(this.formEngineInput); } public enterFormEngine(text: string): void { @@ -17,7 +18,7 @@ export class StatistikFieldsFormE2EComponent { } public getFormIdInput(): Cypress.Chainable<Element> { - return cy.getTestElement(this.locatorFormIdInput); + return cy.getTestElement(this.formIdInput); } public enterFormId(text: string): void { @@ -25,7 +26,7 @@ export class StatistikFieldsFormE2EComponent { } public getAddFieldButton(): Cypress.Chainable<Element> { - return cy.getTestElement(this.locatorAddFieldButton); + return cy.getTestElement(this.addDataFieldButton); } public addField(): void { @@ -33,15 +34,23 @@ export class StatistikFieldsFormE2EComponent { } public getDataFieldInput(index: number): Cypress.Chainable<Element> { - return cy.getTestElement(this.locatorFormDataFieldInput + index); + return cy.getTestElement(this.formDataFieldInput + index + '-text-input'); } public enterDataFieldPath(text: string, index: number): void { enterWith(this.getDataFieldInput(index), text); } + public getDataFieldDeleteButton(index: number): Cypress.Chainable<Element> { + return cy.getTestElement(this.deleteDataFieldButtonPrefix + index); + } + + public deleteDataField(index: number): void { + this.getDataFieldDeleteButton(index).click(); + } + public getSaveButton(): Cypress.Chainable<Element> { - return cy.getTestElement(this.locatorSaveButton); + return cy.getTestElement(this.saveButton); } public save(): void { @@ -49,7 +58,7 @@ export class StatistikFieldsFormE2EComponent { } public getCancelButton(): Cypress.Chainable<Element> { - return cy.getTestElement(this.locatorCancelButton); + return cy.getTestElement(this.cancelButton); } public cancel(): void { diff --git a/alfa-client/apps/admin-e2e/src/components/statistik/statistik.e2e.component.ts b/alfa-client/apps/admin-e2e/src/components/statistik/statistik.e2e.component.ts index 8748a5bad339ca0bc381d88d51c3fbe3747d0d16..b7467232f5d596a2984bc109e84180810c5e8dc3 100644 --- a/alfa-client/apps/admin-e2e/src/components/statistik/statistik.e2e.component.ts +++ b/alfa-client/apps/admin-e2e/src/components/statistik/statistik.e2e.component.ts @@ -1,14 +1,12 @@ -import { exist } from '../../support/cypress.util'; - export class StatistikE2EComponent { private readonly locatorHeaderText: string = 'statistik-header-text'; private readonly locatorWeitereFelderAuswertenButton = 'weitere-felder-auswerten-button'; - public isHeaderTextVisible(): void { - exist(cy.getTestElement(this.locatorHeaderText)); + public getHeaderText(): Cypress.Chainable<Element> { + return cy.getTestElement(this.locatorHeaderText); } - public getWeiterFelderAuswertenButton(): Cypress.Chainable<Element> { + public getWeitereFelderAuswertenButton(): Cypress.Chainable<Element> { return cy.getTestElement(this.locatorWeitereFelderAuswertenButton); } } diff --git a/alfa-client/apps/admin-e2e/src/e2e/main-tests/benutzer_rollen/benutzer-anlegen.cy.ts b/alfa-client/apps/admin-e2e/src/e2e/main-tests/benutzer_rollen/benutzer-anlegen.cy.ts index 0b9aad6ab869bad69f47e7c59cbf0b85e39abe61..0d4a3c538f90b3621783a7f8ccc750429823434f 100644 --- a/alfa-client/apps/admin-e2e/src/e2e/main-tests/benutzer_rollen/benutzer-anlegen.cy.ts +++ b/alfa-client/apps/admin-e2e/src/e2e/main-tests/benutzer_rollen/benutzer-anlegen.cy.ts @@ -1,69 +1,60 @@ - -import { MainPage } from 'apps/admin-e2e/src/page-objects/main.po'; -import { BenutzerE2EComponent } from '../../../components/benutzer/benutzer.e2e.component'; -import { beChecked, beEnabled, contains, exist, notBeChecked, notBeEnabled } from '../../../support/cypress.util'; -import { AlfaRollen, AlfaUsers, loginAsAriane } from '../../../support/user-util'; +import { E2EBenutzerHelper } from 'apps/admin-e2e/src/helper/benutzer/benutzer.helper'; +import { E2EBenutzerVerifier } from 'apps/admin-e2e/src/helper/benutzer/benutzer.verifier'; +import { getCypressEnv, interceptWithResponse, waitOfInterceptor } from 'apps/admin-e2e/src/support/cypress-helper'; import { SnackBarE2EComponent } from '../../../components/ui/snackbar.e2e.component'; -import { SnackbarMessagesE2E } from '../../../model/util'; -import { getCypressEnv, interceptWithResponse, wait, waitOfInterceptor } from 'apps/admin-e2e/src/support/cypress-helper'; -import { AdminUserE2E, HttpMethodE2E } from '../../../model/util'; +import { AdminUserE2E, HttpMethodE2E, SnackbarMessagesE2E } from '../../../model/util'; +import { contains, notExist } from '../../../support/cypress.util'; +import { loginAsAriane } from '../../../support/user-util'; -const mainPage: MainPage = new MainPage(); -const benutzerPage: BenutzerE2EComponent = new BenutzerE2EComponent(); -const snackBar: SnackBarE2EComponent = new SnackBarE2EComponent(); +describe('Benutzer anlegen', () => { + const benutzerHelper: E2EBenutzerHelper = new E2EBenutzerHelper(); + const benutzerVerifier: E2EBenutzerVerifier = new E2EBenutzerVerifier(); -const vorname: string = 'Theo'; -const nachname: string = 'Testuser'; -const benutzername: string = 'testtheo'; -const emailAddress: string = 'theo.test@ozg-sh.de'; + const snackBar: SnackBarE2EComponent = new SnackBarE2EComponent(); -const newUser: AdminUserE2E = { - vorname: 'Theo', - nachname: 'Testuser', - benutzername: 'testtheo', - email: 'theo.test@ozg-sh.de', - isAdmin: true, - isUser: true, -} + const newUser: AdminUserE2E = { + vorname: 'Theo', + nachname: 'Testuser', + username: 'testtheo', + email: 'theo.test@ozg-sh.de', + isAdmin: true, + isUser: true, + organisationseinheiten: [], + }; -describe('Benutzer anlegen', () => { before(() => { loginAsAriane(); }); - it('should open Benutzer tab and show Hinzufuegen button', () => { - mainPage.clickBenutzerNavigationItem(); - - exist(benutzerPage.getHinzufuegenButton()); - }); - - it('should show snackbar message on error', () => { + it('should show error snackbar after save and receiving error response', () => { const interceptor: string = 'postUser'; - const url: string = getCypressEnv('keycloakUrl') + '/admin/realms/' + getCypressEnv('keycloakRealm') + '/users' + const url: string = getCypressEnv('keycloakUrl') + '/admin/realms/' + getCypressEnv('keycloakRealm') + '/users'; const errorCode: number = 500; const errorBody: string = 'Internal Server Error'; - interceptWithResponse(HttpMethodE2E.POST, url, { errorCode, errorBody }).as(interceptor); + benutzerHelper.openNewBenutzerPage(); - benutzerPage.clickAddUser(); - benutzerPage.addUser(newUser); + benutzerHelper.addBenutzer(newUser); + benutzerHelper.saveBenutzer(); waitOfInterceptor(interceptor).then(() => { contains(snackBar.getMessage(), SnackbarMessagesE2E.NUTZER_FEHLGESCHLAGEN); + snackBar.getCloseButton().click(); + notExist(snackBar.getMessage()); }); }); - it('should show snackbar message on saving user', () => { - snackBar.getCloseButton().click(); + it('should show snackbar after save', () => { + benutzerHelper.openNewBenutzerPage(); + + benutzerHelper.addBenutzer(newUser); + benutzerHelper.saveBenutzer(); - benutzerPage.saveUser(); contains(snackBar.getMessage(), SnackbarMessagesE2E.NUTZER_ANGELEGT); + snackBar.getCloseButton().click(); }); - it('should display new user in users table', () => { - benutzerPage.stringExistsInUserEntry(AlfaRollen.USER, benutzername); - benutzerPage.stringExistsInUserEntry(vorname, benutzername); - benutzerPage.stringExistsInUserEntry(nachname, benutzername); - // FEHLT NOCH: benutzerPage.stringExistsInUserEntry(AlfaRollen.ADMIN, benutzername); + it('should show created user in list', () => { + benutzerVerifier.verifyUserInList(newUser); }); }); diff --git a/alfa-client/apps/admin-e2e/src/e2e/main-tests/benutzer_rollen/benutzer-zu-oe-hinzufuegen.cy.ts b/alfa-client/apps/admin-e2e/src/e2e/main-tests/benutzer_rollen/benutzer-zu-oe-hinzufuegen.cy.ts index 9095c63279a17ffe2cbada1f4de9f956593c0638..2a6fc233600a14024c3d62d7056afb41effa8750 100644 --- a/alfa-client/apps/admin-e2e/src/e2e/main-tests/benutzer_rollen/benutzer-zu-oe-hinzufuegen.cy.ts +++ b/alfa-client/apps/admin-e2e/src/e2e/main-tests/benutzer_rollen/benutzer-zu-oe-hinzufuegen.cy.ts @@ -1,110 +1,84 @@ -import { OrganisationsEinheitenE2EComponent } from 'apps/admin-e2e/src/components/organisationseinheiten/organisationseinheiten.e2e.component'; -import { ZustaendigeStelleDialogE2EComponent } from 'apps/admin-e2e/src/components/zustaendige-stelle/zustaendige-stelle-dialog.e2e.component'; +import { E2EBenutzerHelper } from 'apps/admin-e2e/src/helper/benutzer/benutzer.helper'; +import { E2EBenutzerVerifier } from 'apps/admin-e2e/src/helper/benutzer/benutzer.verifier'; +import { OrganisationsEinheitE2E } from 'apps/admin-e2e/src/model/organisations-einheit'; import { AdminUserE2E } from 'apps/admin-e2e/src/model/util'; -import { MainPage } from 'apps/admin-e2e/src/page-objects/main.po'; -import { BenutzerE2EComponent } from '../../../components/benutzer/benutzer.e2e.component'; -import { beChecked, exist, notBeChecked } from '../../../support/cypress.util'; import { loginAsAriane } from '../../../support/user-util'; describe('Organisationseinheit zu Benutzer hinzufügen', () => { - const mainPage: MainPage = new MainPage(); - const benutzerPage: BenutzerE2EComponent = new BenutzerE2EComponent(); - const organisationsEinheitenComponent: OrganisationsEinheitenE2EComponent = new OrganisationsEinheitenE2EComponent(); - const zustaendigeStelleSearchComponent: ZustaendigeStelleDialogE2EComponent = new ZustaendigeStelleDialogE2EComponent(); - const organistationsEinheitOrdnungsamt: string = 'Ordnungsamt'; - const organisationsEinheitDenkmalpflege: string = 'Denkmalpflege'; - const organisationsEinheitLiegenschaften: string = 'Liegenschaften'; - const organisationsEinheitNone: string = 'keine zuständige Stelle zugewiesen'; + const benutzerVerifier: E2EBenutzerVerifier = new E2EBenutzerVerifier(); + const benutzerHelper: E2EBenutzerHelper = new E2EBenutzerHelper(); + const vorname: string = 'Theo'; const nachname: string = 'Testuser'; + const now1 = new Date(); - const benutzername1: string = 'testtheo' + now1.getSeconds().toString() + now1.getMilliseconds().toString(); + const userName1: string = 'testtheo' + now1.getSeconds().toString() + now1.getMilliseconds().toString(); const emailAddress1: string = 'theo' + now1.getSeconds().toString() + now1.getMilliseconds().toString() + '@ozg-sh.de'; + const now2 = new Date(now1.getTime() + 1000); - const benutzername2: string = 'testtheo' + now2.getSeconds().toString() + now2.getMilliseconds().toString(); + const userName2: string = 'testtheo' + now2.getSeconds().toString() + now2.getMilliseconds().toString(); const emailAddress2: string = 'theo' + now2.getSeconds().toString() + now2.getMilliseconds().toString() + '@ozg-sh.de'; - const newUser1: AdminUserE2E = { + const userWithoutOrganisationsEinheiten: AdminUserE2E = { vorname: vorname, nachname: nachname, - benutzername: benutzername1, + username: userName1, email: emailAddress1, isUser: true, + organisationseinheiten: [], }; - const newUser2: AdminUserE2E = { + const userWithOrganisationsEinheiten: AdminUserE2E = { vorname: vorname, nachname: nachname, - benutzername: benutzername2, + username: userName2, email: emailAddress2, isUser: true, - organisationseinheiten: ['Denkmalpflege'], + organisationseinheiten: [OrganisationsEinheitE2E.DENKMALPFLEGE], }; before(() => { loginAsAriane(); }); - it('should click Hinzufügen button and show Organisationseinheiten in Benutzer page', () => { - mainPage.benutzerNavigationItemIsVisible(); - mainPage.clickBenutzerNavigationItem(); - benutzerPage.hinzufuegenButtonIsVisible(); + it('should show organisationseinheiten in formular', () => { + benutzerHelper.openNewBenutzerPage(); - benutzerPage.clickAddUser(); - exist(benutzerPage.getOrganisationsEinheitCheckbox(organisationsEinheitDenkmalpflege)); - exist(benutzerPage.getOrganisationsEinheitCheckbox(organistationsEinheitOrdnungsamt)); + benutzerVerifier.verifyOrganisationsEinheitenInFormular([ + OrganisationsEinheitE2E.DENKMALPFLEGE, + OrganisationsEinheitE2E.ORDNUNGSAMT, + ]); }); - it('should add no Organisationseinheit to new user without selection and saving', () => { - benutzerPage.addUser(newUser1); + it('should add new user without organisationseinheiten', () => { + benutzerHelper.openNewBenutzerPage(); - benutzerPage.stringExistsInUserEntry(organisationsEinheitNone, benutzername1); - }); + benutzerHelper.addBenutzerAndSave(userWithoutOrganisationsEinheiten); - it('should add Organisationseinheit to new user after selection and saving', () => { - benutzerPage.clickAddUser(); - benutzerPage.addUser(newUser2); - - benutzerPage.stringExistsInUserEntry(organisationsEinheitDenkmalpflege, benutzername2); + benutzerVerifier.verifyNoOrganisationsEinheitInBenutzerList(userName1); }); - it('should remove Organisationseinheit from existing user on deselection and save', () => { - benutzerPage.clickUserEntry(benutzername2); - beChecked(benutzerPage.getOrganisationsEinheitCheckbox(organisationsEinheitDenkmalpflege)); + it('should add new user with organisationseinheiten', () => { + benutzerHelper.openNewBenutzerPage(); - benutzerPage.clickOrganisationsEinheitCheckbox(organisationsEinheitDenkmalpflege); - benutzerPage.saveUser(); + benutzerHelper.addBenutzerAndSave(userWithOrganisationsEinheiten); - benutzerPage.stringExistsInUserEntry(organisationsEinheitNone, benutzername2); + benutzerVerifier.verfiyOrganisationsEinheitInBenutzerList(OrganisationsEinheitE2E.DENKMALPFLEGE, userName2); }); - it('should add Organisationseinheit to existing user on selection and save', () => { - benutzerPage.clickUserEntry(benutzername2); - notBeChecked(benutzerPage.getOrganisationsEinheitCheckbox(organistationsEinheitOrdnungsamt)); + it('should remove organisationseinheit from existing user', () => { + benutzerHelper.openBenutzerPage(userName2); - benutzerPage.clickOrganisationsEinheitCheckbox(organistationsEinheitOrdnungsamt); - benutzerPage.saveUser(); + benutzerHelper.editOrganisationsEinheitenAndSave([OrganisationsEinheitE2E.DENKMALPFLEGE]); - benutzerPage.stringExistsInUserEntry(organistationsEinheitOrdnungsamt, benutzername2); + benutzerVerifier.verifyNoOrganisationsEinheitInBenutzerList(userName2); }); - it('should enable new Organisationseinheit for users after adding it', () => { - mainPage.clickOrganisationsEinheitenNavigationItem(); - organisationsEinheitenComponent.clickHinzufuegen(); - zustaendigeStelleSearchComponent.enterSearchTerm(organisationsEinheitLiegenschaften); - zustaendigeStelleSearchComponent.getZustaendigeStelleTitle(0).then((title: string) => { - zustaendigeStelleSearchComponent.clickFoundItem(0); - }); - - mainPage.clickBenutzerNavigationItem(); - benutzerPage.clickUserEntry(benutzername2); + it('should add organisationseinheit to existing user', () => { + benutzerHelper.openBenutzerPage(userName2); - exist(benutzerPage.getOrganisationsEinheitCheckbox(organisationsEinheitLiegenschaften)); - }); + benutzerHelper.editOrganisationsEinheitenAndSave([OrganisationsEinheitE2E.ORDNUNGSAMT]); - it('should add new Organisationseinheit to existing user', () => { - benutzerPage.clickOrganisationsEinheitCheckbox(organisationsEinheitLiegenschaften); - benutzerPage.saveUser(); - benutzerPage.stringExistsInUserEntry(organisationsEinheitLiegenschaften, benutzername2); + benutzerVerifier.verfiyOrganisationsEinheitInBenutzerList(OrganisationsEinheitE2E.ORDNUNGSAMT, userName2); }); }); diff --git a/alfa-client/apps/admin-e2e/src/e2e/main-tests/benutzer_rollen/benutzer_rollen.cy.ts b/alfa-client/apps/admin-e2e/src/e2e/main-tests/benutzer_rollen/benutzer_rollen.cy.ts index 9514df893c043a400aa61ec1e517a6007846eb68..6f2aeed20740461f3dc978afdc2b974fec471f00 100644 --- a/alfa-client/apps/admin-e2e/src/e2e/main-tests/benutzer_rollen/benutzer_rollen.cy.ts +++ b/alfa-client/apps/admin-e2e/src/e2e/main-tests/benutzer_rollen/benutzer_rollen.cy.ts @@ -21,45 +21,63 @@ * Die sprachspezifischen Genehmigungen und Beschränkungen * unter der Lizenz sind dem Lizenztext zu entnehmen. */ -import { MainPage } from 'apps/admin-e2e/src/page-objects/main.po'; -import { BenutzerE2EComponent } from '../../../components/benutzer/benutzer.e2e.component'; -import { beChecked, beEnabled, exist, notBeChecked, notBeEnabled } from '../../../support/cypress.util'; +import { E2EBenutzerHelper } from 'apps/admin-e2e/src/helper/benutzer/benutzer.helper'; +import { OrganisationsEinheitE2E } from 'apps/admin-e2e/src/model/organisations-einheit'; +import { + BenutzerE2EComponent, + BenutzerListE2EComponent, + BenutzerListItemE2EComponent, +} from '../../../components/benutzer/benutzer.e2e.component'; +import { beChecked, beEnabled, contains, exist, notBeChecked, notBeEnabled } from '../../../support/cypress.util'; import { AlfaRollen, AlfaUsers, loginAsAriane } from '../../../support/user-util'; -const mainPage: MainPage = new MainPage(); -const benutzerPage: BenutzerE2EComponent = new BenutzerE2EComponent(); -const organisationsEinheitOrdnungsamt: string = 'Ordnungsamt'; -const organisationsEinheitDenkmalpflege: string = 'Denkmalpflege'; -const organisationsEinheitWirtschaftsfoerderung: string = 'Wirtschaftsförderung'; -const organisationsEinheitNone: string = 'keine zuständige Stelle zugewiesen'; -const emailAddress: string = 'peter.von.der.post@ozg-sh.de'; - describe('Benutzer und Rollen', () => { + const benutzerPage: BenutzerE2EComponent = new BenutzerE2EComponent(); + const benutzerListPage: BenutzerListE2EComponent = new BenutzerListE2EComponent(); + + //TODO In der entsprechenden json hinterlegen und darauf zugreifen + const emailAddress: string = 'peter.von.der.post@ozg-sh.de'; + + const helper: E2EBenutzerHelper = new E2EBenutzerHelper(); + before(() => { loginAsAriane(); }); - it('should open Benutzer tab and show Hinzufuegen button', () => { - mainPage.clickBenutzerNavigationItem(); + it('should show users and attributes in list', () => { + helper.openBenutzerListPage(); - exist(benutzerPage.getHinzufuegenButton()); - }); + const ariane: BenutzerListItemE2EComponent = benutzerListPage.getItem(AlfaUsers.ARAINE); + exist(ariane.getRoot()); + contains(ariane.getRoles(), AlfaRollen.USER); + + const dorothea: BenutzerListItemE2EComponent = benutzerListPage.getItem(AlfaUsers.DOROTHEA); + exist(dorothea.getRoot()); + contains(dorothea.getRoles(), AlfaRollen.USER); + + const ludwig: BenutzerListItemE2EComponent = benutzerListPage.getItem(AlfaUsers.LUDWIG); + exist(ludwig.getRoot()); + contains(ludwig.getRoles(), AlfaRollen.LOESCHEN); + contains(ludwig.getOrganisationsEinheiten(), OrganisationsEinheitE2E.ORDNUNGSAMT); + + const zelda: BenutzerListItemE2EComponent = benutzerListPage.getItem(AlfaUsers.ZELDA); + exist(zelda.getRoot()); + contains(zelda.getRoles(), AlfaRollen.USER); + contains(zelda.getOrganisationsEinheiten(), OrganisationsEinheitE2E.DENKMALPFLEGE); + contains(zelda.getOrganisationsEinheiten(), OrganisationsEinheitE2E.WIRTSCHAFTSFOERDERUNG); + + const peter: BenutzerListItemE2EComponent = benutzerListPage.getItem(AlfaUsers.PETER); + exist(peter.getRoot()); + contains(peter.getRoles(), AlfaRollen.POSTSTELLE); + contains(peter.getEMail(), emailAddress); - it('should show users and attributes in table', () => { - exist(benutzerPage.getUserEntry('ariane')); - benutzerPage.stringExistsInUserEntry(AlfaRollen.USER, AlfaUsers.DOROTHEA); - benutzerPage.stringExistsInUserEntry(organisationsEinheitOrdnungsamt, AlfaUsers.LUDWIG); - benutzerPage.stringExistsInUserEntry(AlfaRollen.USER, AlfaUsers.ZELDA); - benutzerPage.stringExistsInUserEntry(AlfaRollen.LOESCHEN, AlfaUsers.LUDWIG); - benutzerPage.stringExistsInUserEntry(organisationsEinheitDenkmalpflege, AlfaUsers.ZELDA); - benutzerPage.stringExistsInUserEntry(organisationsEinheitWirtschaftsfoerderung, AlfaUsers.ZELDA); - benutzerPage.stringExistsInUserEntry(organisationsEinheitNone, AlfaUsers.RICHARD); - benutzerPage.stringExistsInUserEntry(emailAddress, AlfaUsers.PETER); - benutzerPage.stringExistsInUserEntry(AlfaRollen.POSTSTELLE, AlfaUsers.PETER); + const richard: BenutzerListItemE2EComponent = benutzerListPage.getItem(AlfaUsers.RICHARD); + exist(richard.getRoot()); + exist(richard.getNoOrganisationsEinheitText()); }); it('should show single user screen on click', () => { - benutzerPage.clickAddUser(); + helper.openNewBenutzerPage(); exist(benutzerPage.getVornameInput()); exist(benutzerPage.getNachnameInput()); @@ -73,47 +91,47 @@ describe('Benutzer und Rollen', () => { }); it('should activate loeschen checkbox and deactivate the other two checkboxes', () => { - benutzerPage.clickLoeschenCheckbox(); + benutzerPage.getLoeschenCheckbox().click(); beChecked(benutzerPage.getLoeschenCheckbox()); notBeEnabled(benutzerPage.getUserCheckbox()); notBeEnabled(benutzerPage.getPostCheckbox()); - benutzerPage.clickLoeschenCheckbox(); + benutzerPage.getLoeschenCheckbox().click(); notBeChecked(benutzerPage.getLoeschenCheckbox()); beEnabled(benutzerPage.getUserCheckbox()); beEnabled(benutzerPage.getPostCheckbox()); }); it('should additionally activate and deactivate admin checkbox', () => { - benutzerPage.clickLoeschenCheckbox(); - benutzerPage.clickAdminCheckbox(); + benutzerPage.getLoeschenCheckbox().click(); + benutzerPage.getAdminCheckbox().click(); beChecked(benutzerPage.getLoeschenCheckbox()); beChecked(benutzerPage.getAdminCheckbox()); - benutzerPage.clickAdminCheckbox(); + benutzerPage.getAdminCheckbox().click(); notBeChecked(benutzerPage.getAdminCheckbox()); }); it('should activate user checkbox and deactivate the other two checkboxes', () => { - benutzerPage.clickLoeschenCheckbox(); - benutzerPage.clickUserCheckbox(); + benutzerPage.getLoeschenCheckbox().click(); + benutzerPage.getUserCheckbox().click(); beChecked(benutzerPage.getUserCheckbox()); notBeEnabled(benutzerPage.getLoeschenCheckbox()); notBeEnabled(benutzerPage.getPostCheckbox()); - benutzerPage.clickUserCheckbox(); + benutzerPage.getUserCheckbox().click(); notBeChecked(benutzerPage.getUserCheckbox()); beEnabled(benutzerPage.getLoeschenCheckbox()); beEnabled(benutzerPage.getPostCheckbox()); }); it('should activate post checkbox and deactivate the other two checkboxes', () => { - benutzerPage.clickPostCheckbox(); + benutzerPage.getPostCheckbox().click(); beChecked(benutzerPage.getPostCheckbox()); notBeEnabled(benutzerPage.getLoeschenCheckbox()); notBeEnabled(benutzerPage.getUserCheckbox()); - benutzerPage.clickPostCheckbox(); + benutzerPage.getPostCheckbox().click(); notBeChecked(benutzerPage.getPostCheckbox()); beEnabled(benutzerPage.getLoeschenCheckbox()); beEnabled(benutzerPage.getUserCheckbox()); diff --git a/alfa-client/apps/admin-e2e/src/e2e/main-tests/navigation/daria.cy.ts b/alfa-client/apps/admin-e2e/src/e2e/main-tests/navigation/daria.cy.ts index 57867568976e5deb0675a0ccd3fc52f9e5e19d79..33a06a73b83c3a839b0490f96aa17ddb42106994 100644 --- a/alfa-client/apps/admin-e2e/src/e2e/main-tests/navigation/daria.cy.ts +++ b/alfa-client/apps/admin-e2e/src/e2e/main-tests/navigation/daria.cy.ts @@ -1,5 +1,5 @@ import { MainPage, waitForSpinnerToDisappear } from 'apps/admin-e2e/src/page-objects/main.po'; -import { exist, notExist } from 'apps/admin-e2e/src/support/cypress.util'; +import { exist, notExist, visible } from 'apps/admin-e2e/src/support/cypress.util'; import { loginAsDaria } from 'apps/admin-e2e/src/support/user-util'; import { StatistikE2EComponent } from '../../../components/statistik/statistik.e2e.component'; @@ -37,7 +37,7 @@ describe('Navigation', () => { }); it('should show header text', () => { - statistikPage.isHeaderTextVisible(); + visible(statistikPage.getHeaderText()); }); }); }); diff --git a/alfa-client/apps/admin-e2e/src/e2e/main-tests/navigation/safira.cy.ts b/alfa-client/apps/admin-e2e/src/e2e/main-tests/navigation/safira.cy.ts index 6f76dafdfc3161646383b34465056c2e751fa33c..005da2e5a576948787fdeb1f26165bd250b22138 100644 --- a/alfa-client/apps/admin-e2e/src/e2e/main-tests/navigation/safira.cy.ts +++ b/alfa-client/apps/admin-e2e/src/e2e/main-tests/navigation/safira.cy.ts @@ -1,5 +1,5 @@ import { MainPage, waitForSpinnerToDisappear } from 'apps/admin-e2e/src/page-objects/main.po'; -import { exist } from 'apps/admin-e2e/src/support/cypress.util'; +import { exist, visible } from 'apps/admin-e2e/src/support/cypress.util'; import { loginAsSafira } from 'apps/admin-e2e/src/support/user-util'; import { StatistikE2EComponent } from '../../../components/statistik/statistik.e2e.component'; @@ -38,7 +38,7 @@ describe('Navigation', () => { }); it('should show page on selection', () => { - statistikPage.isHeaderTextVisible(); + visible(statistikPage.getHeaderText()); }); it('should mark navigation item as selected', () => { diff --git a/alfa-client/apps/admin-e2e/src/e2e/main-tests/organisationseinheiten/organisationseinheiten-hinzufuegen.cy.ts b/alfa-client/apps/admin-e2e/src/e2e/main-tests/organisationseinheiten/organisationseinheiten-hinzufuegen.cy.ts index ecdc072a69ee0a81f41aa786ccb0a23eacc4f450..c88d54bf3dac14f0f0a7b5f124a66e7d1e26d60f 100644 --- a/alfa-client/apps/admin-e2e/src/e2e/main-tests/organisationseinheiten/organisationseinheiten-hinzufuegen.cy.ts +++ b/alfa-client/apps/admin-e2e/src/e2e/main-tests/organisationseinheiten/organisationseinheiten-hinzufuegen.cy.ts @@ -1,3 +1,4 @@ +import { convertToDataTestId } from 'apps/admin-e2e/src/support/tech-util'; import { OrganisationsEinheitenE2EComponent } from '../../../components/organisationseinheiten/organisationseinheiten.e2e.component'; import { ZustaendigeStelleDialogE2EComponent } from '../../../components/zustaendige-stelle/zustaendige-stelle-dialog.e2e.component'; import { MainPage, waitForSpinnerToDisappear } from '../../../page-objects/main.po'; @@ -27,7 +28,7 @@ describe('Organisationseinheiten', () => { }); it('should show search Organisationseinheit dialog', () => { - organisationsEinheitenComponent.clickHinzufuegen(); + organisationsEinheitenComponent.getOrganisationsEinheitHinzufuegenButton().click(); exist(zustaendigeStelleSearchComponent.getZustaendigeStelleForm()); }); @@ -39,9 +40,9 @@ describe('Organisationseinheiten', () => { }); it('should add first Organisationseinheit', () => { - zustaendigeStelleSearchComponent.getZustaendigeStelleTitle(0).then((title: string) => { + zustaendigeStelleSearchComponent.getZustaendigeStelleTitle(0).then((name: string) => { zustaendigeStelleSearchComponent.clickFoundItem(0); - exist(organisationsEinheitenComponent.getListItemByName(title)); + exist(organisationsEinheitenComponent.getListItem(convertToDataTestId(name))); }); }); }); diff --git a/alfa-client/apps/admin-e2e/src/e2e/main-tests/organisationseinheiten/organisationseinheiten-laden.cy.ts b/alfa-client/apps/admin-e2e/src/e2e/main-tests/organisationseinheiten/organisationseinheiten-laden.cy.ts index 91a1673e96e41b8dbdae4e4338e864a0527f816e..2b8eaeb70ab47d7845d24f973bac43f7645c25b2 100644 --- a/alfa-client/apps/admin-e2e/src/e2e/main-tests/organisationseinheiten/organisationseinheiten-laden.cy.ts +++ b/alfa-client/apps/admin-e2e/src/e2e/main-tests/organisationseinheiten/organisationseinheiten-laden.cy.ts @@ -24,52 +24,33 @@ import { OrganisationsEinheitenE2EComponent } from '../../../components/organisationseinheiten/organisationseinheiten.e2e.component'; import { MainPage, waitForSpinnerToDisappear } from '../../../page-objects/main.po'; import { exist } from '../../../support/cypress.util'; -import { OrganisationsEinheitSyncResultE2E } from '../../../support/organisationseinheit'; -import { - createBauamtOrganisationsEinheit, - createDenkmalpflegeOrganisationsEinheit, - createFundstelleOrganisationsEinheit, - initOrganisationsEinheiten, -} from '../../../support/organisationseinheit-util'; import { loginAsAriane } from '../../../support/user-util'; -describe.skip('TODO: activate after fix for OZG-7391: show Organisationsheiten', () => { +describe('Organisationsheiten list', () => { const mainPage: MainPage = new MainPage(); const organisationsEinheitenTab: OrganisationsEinheitenE2EComponent = new OrganisationsEinheitenE2EComponent(); before(() => { loginAsAriane(); - initOrganisationsEinheiten([ - createBauamtOrganisationsEinheit(), - { ...createDenkmalpflegeOrganisationsEinheit(), syncResult: OrganisationsEinheitSyncResultE2E.NAME_MISMATCH }, - { ...createFundstelleOrganisationsEinheit(), syncResult: OrganisationsEinheitSyncResultE2E.NOT_FOUND_IN_PVOG }, - ]); }); - it('should show table of Organisationseinheiten', () => { + it('should show Organisationseinheiten list', () => { waitForSpinnerToDisappear(); mainPage.clickOrganisationsEinheitenNavigationItem(); + waitForSpinnerToDisappear(); exist(organisationsEinheitenTab.getOrganisationsEinheitList()); }); - it('should show identical data in Keycloak and PVOG without error', () => { - organisationsEinheitenTab.getListItemByName('Bauamt'); - organisationsEinheitenTab.organisationsEinheitContainsID('Bauamt', '248240886'); - organisationsEinheitenTab.elementShowsNoError('Bauamt'); + it('should show entry for Bauamt', () => { + exist(organisationsEinheitenTab.getListItem('Bauamt')); }); - it('should show data not found in PVOG in red color and with error icon and tooltip message', () => { - const organisationsEinheitName: string = 'Fundstelle'; - - organisationsEinheitenTab.organisationsEinheitContainsID(organisationsEinheitName, '10363455'); - organisationsEinheitenTab.elementIsShownAsError(organisationsEinheitName); - organisationsEinheitenTab.getErrorIconInElement(organisationsEinheitName); - organisationsEinheitenTab.getErrorTooltip(organisationsEinheitName); + it('should show entry for Fundstelle', () => { + exist(organisationsEinheitenTab.getListItem('Fundstelle')); }); - it('should get name for OE from PVOG, if mismatch with Keycloak, but without error', () => { - organisationsEinheitenTab.organisationsEinheitContainsID('Landesamt für Denkmalpflege', '9093371'); - organisationsEinheitenTab.elementShowsNoError('Landesamt für Denkmalpflege'); + it('should show entry for Denkmalpflege', () => { + exist(organisationsEinheitenTab.getListItem('Denkmalpflege')); }); }); diff --git a/alfa-client/apps/admin-e2e/src/e2e/main-tests/organisationseinheiten/organisationseinheiten-signaturen.cy.ts b/alfa-client/apps/admin-e2e/src/e2e/main-tests/organisationseinheiten/organisationseinheiten-signaturen.cy.ts deleted file mode 100644 index 1e5a19499a0ad62ca94e6cbf43aff7c18856f6d8..0000000000000000000000000000000000000000 --- a/alfa-client/apps/admin-e2e/src/e2e/main-tests/organisationseinheiten/organisationseinheiten-signaturen.cy.ts +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (C) 2024 Das Land Schleswig-Holstein vertreten durch den - * Ministerpräsidenten des Landes Schleswig-Holstein - * Staatskanzlei - * Abteilung Digitalisierung und zentrales IT-Management der Landesregierung - * - * Lizenziert unter der EUPL, Version 1.2 oder - sobald - * diese von der Europäischen Kommission genehmigt wurden - - * Folgeversionen der EUPL ("Lizenz"); - * Sie dürfen dieses Werk ausschließlich gemäß - * dieser Lizenz nutzen. - * Eine Kopie der Lizenz finden Sie hier: - * - * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12 - * - * Sofern nicht durch anwendbare Rechtsvorschriften - * gefordert oder in schriftlicher Form vereinbart, wird - * die unter der Lizenz verbreitete Software "so wie sie - * ist", OHNE JEGLICHE GEWÄHRLEISTUNG ODER BEDINGUNGEN - - * ausdrücklich oder stillschweigend - verbreitet. - * Die sprachspezifischen Genehmigungen und Beschränkungen - * unter der Lizenz sind dem Lizenztext zu entnehmen. - */ -import { OrganisationseinheitenSignaturE2EComponent } from '../../../components/organisationseinheiten/organisationseinheiten-signatur.e2e.component'; -import { OrganisationsEinheitenE2EComponent } from '../../../components/organisationseinheiten/organisationseinheiten.e2e.component'; -import { MainPage, waitForSpinnerToDisappear } from '../../../page-objects/main.po'; -import { haveText } from '../../../support/cypress.util'; -import { loginAsAriane } from '../../../support/user-util'; - -describe.skip('TODO: activate after fix for OZG-7391: Signatur', () => { - const mainPage: MainPage = new MainPage(); - const signaturePage: OrganisationseinheitenSignaturE2EComponent = new OrganisationseinheitenSignaturE2EComponent(); - const organisationsEinheitenTab: OrganisationsEinheitenE2EComponent = new OrganisationsEinheitenE2EComponent(); - - const signatureText: string = 'Signatur\nmit\n\n\n\nZeilenumbruch\n\n'; - - before(() => { - loginAsAriane(); - }); - - it('should open signature page for Bauamt on click', () => { - waitForSpinnerToDisappear(); - mainPage.openOrganisationsEinheiten(); - organisationsEinheitenTab.openOrganisationsEinheit('Bauamt'); - - haveText(signaturePage.getOrganisationsEinheitName(), 'Bauamt'); - }); - - it('should show signature input with scrollbar', () => { - signaturePage.setSignature(signatureText); - signaturePage.saveSignature(); - - signaturePage.hasSignature(signatureText); - signaturePage.hasScrollbar(); - }); - - it.skip('should enter and save empty signature', () => { - signaturePage.clearSignature(); - signaturePage.saveSignature(); - - signaturePage.hasSignature(''); - }); -}); diff --git a/alfa-client/apps/admin-e2e/src/e2e/main-tests/statistik/statistik-fields.cy.ts b/alfa-client/apps/admin-e2e/src/e2e/main-tests/statistik/statistik-fields.cy.ts index dae58525a8d2522f3c0a241f5f24423cba928f4b..d877ae4b900417af37328322176ce8070c6d0844 100644 --- a/alfa-client/apps/admin-e2e/src/e2e/main-tests/statistik/statistik-fields.cy.ts +++ b/alfa-client/apps/admin-e2e/src/e2e/main-tests/statistik/statistik-fields.cy.ts @@ -1,40 +1,30 @@ -import { ROUTES } from '@admin-client/shared'; +import { StatistikE2EComponent } from 'apps/admin-e2e/src/components/statistik/statistik.e2e.component'; import { StatistikFieldsFormE2EComponent } from '../../../components/statistik/statistik-fields-form.e2e.component'; -import { StatistikE2EComponent } from '../../../components/statistik/statistik.e2e.component'; -import { urlShouldEndsWith } from '../../../support/cypress-helper'; -import { exist } from '../../../support/cypress.util'; +import { exist, haveText, haveValue } from '../../../support/cypress.util'; import { loginAsDaria } from '../../../support/user-util'; describe('Felder in Statistik hinzufügen', () => { const component: StatistikE2EComponent = new StatistikE2EComponent(); const fieldsFormComponent: StatistikFieldsFormE2EComponent = new StatistikFieldsFormE2EComponent(); + const dataText1: string = 'Eingabe A'; + const dataText2: string = 'Eingabe B'; + before(() => { loginAsDaria(); }); - it('should be on statistik page', () => { - urlShouldEndsWith(ROUTES.STATISTIK); - }); - - it('should show statistik header', () => { - component.isHeaderTextVisible(); + it('should show "Weitere Felder auswerten" button', () => { + exist(component.getWeitereFelderAuswertenButton()); }); - it('should show "Weiter Felder auswerten" button', () => { - exist(component.getWeiterFelderAuswertenButton()); - }); - - it('should navigate to route', () => { - component.getWeiterFelderAuswertenButton().click(); - - urlShouldEndsWith(ROUTES.STATISTIK_NEU); - }); + it('should have all form elements after button click', () => { + component.getWeitereFelderAuswertenButton().click(); - it('should have all form elements', () => { exist(fieldsFormComponent.getFormEngineInput()); exist(fieldsFormComponent.getFormIdInput()); exist(fieldsFormComponent.getDataFieldInput(0)); + exist(fieldsFormComponent.getDataFieldDeleteButton(0)); exist(fieldsFormComponent.getAddFieldButton()); exist(fieldsFormComponent.getSaveButton()); exist(fieldsFormComponent.getCancelButton()); @@ -46,9 +36,22 @@ describe('Felder in Statistik hinzufügen', () => { exist(fieldsFormComponent.getDataFieldInput(1)); }); + it('should enter text in both data fields', () => { + fieldsFormComponent.enterDataFieldPath(dataText1, 0); + fieldsFormComponent.enterDataFieldPath(dataText2, 1); + + haveValue(fieldsFormComponent.getDataFieldInput(0), dataText1); + haveValue(fieldsFormComponent.getDataFieldInput(1), dataText2); + }); + + it('should delete data fields', () => { + fieldsFormComponent.deleteDataField(0); + haveValue(fieldsFormComponent.getDataFieldInput(0), dataText2); + }); + it('should navigate to statistik on cancel', () => { fieldsFormComponent.cancel(); - urlShouldEndsWith(ROUTES.STATISTIK); + exist(component.getWeitereFelderAuswertenButton()); }); }); diff --git a/alfa-client/apps/admin-e2e/src/helper/benutzer/benutzer.executor.ts b/alfa-client/apps/admin-e2e/src/helper/benutzer/benutzer.executor.ts new file mode 100644 index 0000000000000000000000000000000000000000..9c8898bc0fcddef20b538919cc20bde8bc6e1993 --- /dev/null +++ b/alfa-client/apps/admin-e2e/src/helper/benutzer/benutzer.executor.ts @@ -0,0 +1,47 @@ +import { BenutzerE2EComponent } from '../../components/benutzer/benutzer.e2e.component'; +import { SnackBarE2EComponent } from '../../components/ui/snackbar.e2e.component'; +import { OrganisationsEinheitE2E } from '../../model/organisations-einheit'; +import { AdminUserE2E } from '../../model/util'; +import { exist, notExist } from '../../support/cypress.util'; + +export class E2EBenutzerExecutor { + private benutzerPage: BenutzerE2EComponent = new BenutzerE2EComponent(); + private snackBar: SnackBarE2EComponent = new SnackBarE2EComponent(); + + public modifyBenutzer(user: AdminUserE2E): void { + this.benutzerPage.getVornameInput().type(user.vorname); + this.benutzerPage.getNachnameInput().type(user.nachname); + this.benutzerPage.getBenutzernameInput().type(user.username); + this.benutzerPage.getMailInput().type(user.email); + + if (user.isAdmin) { + this.benutzerPage.getAdminCheckbox().click(); + } + if (user.isUser) { + this.benutzerPage.getUserCheckbox().click(); + } + if (user.isLoeschen) { + this.benutzerPage.getLoeschenCheckbox().click(); + } + if (user.isPoststelle) { + this.benutzerPage.getPostCheckbox().click(); + } + + this.modifyOrganisationsEinheiten(user.organisationseinheiten); + } + + public modifyOrganisationsEinheiten(organisationseinheiten: OrganisationsEinheitE2E[]): void { + organisationseinheiten.forEach((name: string) => this.benutzerPage.getOrganisationsEinheitCheckbox(name).click()); + } + + public saveAndCloseSnackbar(): void { + this.saveBenutzer(); + exist(this.snackBar.getMessage()); + this.snackBar.getCloseButton().click(); + notExist(this.snackBar.getMessage()); + } + + public saveBenutzer(): void { + this.benutzerPage.getSaveButton().click(); + } +} diff --git a/alfa-client/apps/admin-e2e/src/helper/benutzer/benutzer.helper.ts b/alfa-client/apps/admin-e2e/src/helper/benutzer/benutzer.helper.ts new file mode 100644 index 0000000000000000000000000000000000000000..3f2b6be7847116296225a8c28d81fb86e37f9cf9 --- /dev/null +++ b/alfa-client/apps/admin-e2e/src/helper/benutzer/benutzer.helper.ts @@ -0,0 +1,48 @@ +import { OrganisationsEinheitE2E } from '../../model/organisations-einheit'; +import { AdminUserE2E } from '../../model/util'; +import { E2EBenutzerExecutor } from './benutzer.executor'; +import { E2EBenutzerNavigator } from './benutzer.navigator'; + +export class E2EBenutzerHelper { + private navigator: E2EBenutzerNavigator = new E2EBenutzerNavigator(); + private executer: E2EBenutzerExecutor = new E2EBenutzerExecutor(); + + public openBenutzerListPage(): void { + this.navigator.openBenutzerListPage(); + } + + public openNewBenutzerPage(): void { + this.navigator.openNewBenutzerPage(); + } + + public addBenutzerAndSave(user: AdminUserE2E): void { + this.addBenutzer(user); + this.executer.saveAndCloseSnackbar(); + } + + public addBenutzer(user: AdminUserE2E): void { + this.executer.modifyBenutzer(user); + } + + public openBenutzerPage(userName: string): void { + this.navigator.openBenutzerPage(userName); + } + + public editBenutzerAndSave(user: AdminUserE2E): void { + this.editBenutzer(user); + this.executer.saveAndCloseSnackbar(); + } + + public editBenutzer(user: AdminUserE2E): void { + this.executer.modifyBenutzer(user); + } + + public editOrganisationsEinheitenAndSave(organisationsEinheiten: OrganisationsEinheitE2E[]): void { + this.executer.modifyOrganisationsEinheiten(organisationsEinheiten); + this.executer.saveAndCloseSnackbar(); + } + + public saveBenutzer(): void { + this.executer.saveBenutzer(); + } +} diff --git a/alfa-client/apps/admin-e2e/src/helper/benutzer/benutzer.navigator.ts b/alfa-client/apps/admin-e2e/src/helper/benutzer/benutzer.navigator.ts new file mode 100644 index 0000000000000000000000000000000000000000..fc5eee020b1931cd7dfa074c9ae070e7c6fe5121 --- /dev/null +++ b/alfa-client/apps/admin-e2e/src/helper/benutzer/benutzer.navigator.ts @@ -0,0 +1,32 @@ +import { BenutzerE2EComponent, BenutzerListE2EComponent } from '../../components/benutzer/benutzer.e2e.component'; +import { MainPage } from '../../page-objects/main.po'; +import { exist } from '../../support/cypress.util'; + +export class E2EBenutzerNavigator { + private mainPage: MainPage = new MainPage(); + private benutzerListPage: BenutzerListE2EComponent = new BenutzerListE2EComponent(); + private benutzerPage: BenutzerE2EComponent = new BenutzerE2EComponent(); + + public openNewBenutzerPage(): void { + this.openBenutzerListPage(); + + this.benutzerListPage.getHinzufuegenButton().click(); + exist(this.benutzerPage.getHeadline()); + } + + public openBenutzerPage(userName: string) { + this.openBenutzerListPage(); + this.benutzerListPage.getItem(userName).getRoot().click(); + exist(this.benutzerPage.getHeadline()); + } + + public openBenutzerListPage(): void { + this.navigateToDomain(); + this.mainPage.getBenutzerNavigationItem().click(); + exist(this.benutzerListPage.getHeadline()); + } + + private navigateToDomain(): void { + this.mainPage.getHeader().getLogo().click(); + } +} diff --git a/alfa-client/apps/admin-e2e/src/helper/benutzer/benutzer.verifier.ts b/alfa-client/apps/admin-e2e/src/helper/benutzer/benutzer.verifier.ts new file mode 100644 index 0000000000000000000000000000000000000000..d0c33452341f51de81cefee2d0f7f0e610532c7b --- /dev/null +++ b/alfa-client/apps/admin-e2e/src/helper/benutzer/benutzer.verifier.ts @@ -0,0 +1,47 @@ +import { + BenutzerE2EComponent, + BenutzerListE2EComponent, + BenutzerListItemE2EComponent, +} from '../../components/benutzer/benutzer.e2e.component'; +import { AdminUserE2E } from '../../model/util'; +import { contains, exist } from '../../support/cypress.util'; +import { AlfaRollen } from '../../support/user-util'; + +export class E2EBenutzerVerifier { + private noOrganisationsEinheitAssignedText: string = 'keine zuständige Stelle zugewiesen'; + + private benutzerListPage: BenutzerListE2EComponent = new BenutzerListE2EComponent(); + private benutzerPage: BenutzerE2EComponent = new BenutzerE2EComponent(); + + public verfiyOrganisationsEinheitInBenutzerList(organisationsEinheit: string, userName: string): void { + const benutzerItem: BenutzerListItemE2EComponent = this.getBenutzerItem(userName); + contains(benutzerItem.getOrganisationsEinheiten(), organisationsEinheit); + } + + public verifyNoOrganisationsEinheitInBenutzerList(userName: string): void { + const benutzerItem: BenutzerListItemE2EComponent = this.getBenutzerItem(userName); + contains(benutzerItem.getNoOrganisationsEinheitText(), this.noOrganisationsEinheitAssignedText); + } + + public verifyOrganisationsEinheitenInFormular(organisationsEinheiten: string[]): void { + organisationsEinheiten.forEach((organisationsEinheit) => { + exist(this.benutzerPage.getOrganisationsEinheitCheckbox(organisationsEinheit)); + }); + } + + public verifyUserInList(user: AdminUserE2E): void { + const benutzer: BenutzerListItemE2EComponent = this.getBenutzerItem(user.username); + contains(benutzer.getUserName(), user.username); + contains(benutzer.getFullName(), user.vorname); + contains(benutzer.getFullName(), user.nachname); + + if (user.isUser) contains(benutzer.getRoles(), AlfaRollen.USER); + if (user.isLoeschen) contains(benutzer.getRoles(), AlfaRollen.LOESCHEN); + if (user.isPoststelle) contains(benutzer.getRoles(), AlfaRollen.POSTSTELLE); + if (user.isAdmin) contains(benutzer.getRoles(), AlfaRollen.ADMIN); + } + + private getBenutzerItem(userName: string): BenutzerListItemE2EComponent { + return this.benutzerListPage.getItem(userName); + } +} diff --git a/alfa-client/apps/admin-e2e/src/model/organisations-einheit.ts b/alfa-client/apps/admin-e2e/src/model/organisations-einheit.ts new file mode 100644 index 0000000000000000000000000000000000000000..9870f7e3f1292df175cd154c88c59fbd60a94f26 --- /dev/null +++ b/alfa-client/apps/admin-e2e/src/model/organisations-einheit.ts @@ -0,0 +1,5 @@ +export enum OrganisationsEinheitE2E { + ORDNUNGSAMT = 'Ordnungsamt', + DENKMALPFLEGE = 'Denkmalpflege', + WIRTSCHAFTSFOERDERUNG = 'Wirtschaftsförderung', +} diff --git a/alfa-client/apps/admin-e2e/src/model/util.ts b/alfa-client/apps/admin-e2e/src/model/util.ts index a6e185610f221306000e326517a8906ecb1c1f6f..03041ea28be5dae394e7df97d6bf38ae72d2a182 100644 --- a/alfa-client/apps/admin-e2e/src/model/util.ts +++ b/alfa-client/apps/admin-e2e/src/model/util.ts @@ -1,3 +1,5 @@ +import { OrganisationsEinheitE2E } from './organisations-einheit'; + /* * Copyright (C) 2024 Das Land Schleswig-Holstein vertreten durch den * Ministerpräsidenten des Landes Schleswig-Holstein @@ -41,11 +43,11 @@ export enum HttpMethodE2E { export interface AdminUserE2E { vorname: string; nachname: string; - benutzername: string; + username: string; email: string; isAdmin?: boolean; isUser?: boolean; isLoeschen?: boolean; isPoststelle?: boolean; - organisationseinheiten?: string[]; + organisationseinheiten: OrganisationsEinheitE2E[]; } diff --git a/alfa-client/apps/admin-e2e/src/support/cypress.util.ts b/alfa-client/apps/admin-e2e/src/support/cypress.util.ts index 505762fe8f5193921ee7b5bffb76234f5b21393b..637963609081aa8cddbd24bbf5f56369b80cf0ef 100644 --- a/alfa-client/apps/admin-e2e/src/support/cypress.util.ts +++ b/alfa-client/apps/admin-e2e/src/support/cypress.util.ts @@ -122,13 +122,13 @@ export function enter(element: Cypress.Chainable<Element>): void { element.clear().type(CypressKeyboardActions.ENTER); } -export function enterWith(element: Cypress.Chainable<JQuery<HTMLElement>>, value: string, delayBeforeEnter: number = 200): void { +export function enterWith(element: Cypress.Chainable<Element>, value: string, delayBeforeEnter: number = 200): void { element.clear().type(value); wait(delayBeforeEnter); element.type(CypressKeyboardActions.ENTER); } -export function typeText(element: Cypress.Chainable<JQuery<HTMLElement>>, value: string): void { +export function typeText(element: Cypress.Chainable<Element>, value: string): void { element.type(value); } diff --git a/alfa-client/apps/admin-e2e/src/support/tech-util.ts b/alfa-client/apps/admin-e2e/src/support/tech-util.ts new file mode 100644 index 0000000000000000000000000000000000000000..a1bbcb74ae2b53c9fc3fc05bbcab81896c4e183e --- /dev/null +++ b/alfa-client/apps/admin-e2e/src/support/tech-util.ts @@ -0,0 +1,15 @@ +export function convertToDataTestId(value: string): string { + if (value == null || value == undefined) { + return ''; + } + value = replaceAllWhitespaces(value, '_'); + return simpleTransliteration(value); +} + +export function replaceAllWhitespaces(value: string, replaceWith: string): string { + return value.replace(/ /g, replaceWith); +} + +export function simpleTransliteration(value: string) { + return value.normalize('NFKD').replace(/[^-A-Za-z0-9_]/g, ''); +} diff --git a/alfa-client/apps/admin-e2e/src/support/user-util.ts b/alfa-client/apps/admin-e2e/src/support/user-util.ts index 46f07823c27eee9c7872cc8f72a39a33a5326548..d5e7462638087a82b1e4d365e0a59e11932962e5 100644 --- a/alfa-client/apps/admin-e2e/src/support/user-util.ts +++ b/alfa-client/apps/admin-e2e/src/support/user-util.ts @@ -23,7 +23,8 @@ */ import { UserE2E } from '../model/user'; import { HeaderE2EComponent } from '../page-objects/header.po'; -import { MainPage } from '../page-objects/main.po'; +import { MainPage, waitForSpinnerToDisappear } from '../page-objects/main.po'; +import { wait } from './cypress-helper'; export function loginAsAriane(): void { login(UserJsonPath.ARIANE); @@ -43,6 +44,8 @@ export function loginAsSafira(): void { function login(userJson: string): void { cy.fixture(userJson).then((user) => loginByUi(user)); + waitForSpinnerToDisappear(); + wait(3000, 'Wait for initial navigation is done'); } // Hinweis: cacheAcrossSpecs: true lässt Tests umfallen @@ -85,10 +88,11 @@ export enum AlfaRollen { USER = 'VERWALTUNG_USER', LOESCHEN = 'VERWALTUNG_LOESCHEN', POSTSTELLE = 'VERWALTUNG_POSTSTELLE', - ADMIN = 'ADMIN_ADMIN' + ADMIN = 'ADMIN_ADMIN', } export enum AlfaUsers { + ARAINE = 'ariane', DOROTHEA = 'dorothea', LUDWIG = 'ludwig', PETER = 'peter', diff --git a/alfa-client/libs/admin/shared/src/lib/admin-delete-open-dialog-button/admin-delete-open-dialog-button.component.html b/alfa-client/libs/admin/shared/src/lib/admin-delete-open-dialog-button/admin-delete-open-dialog-button.component.html index 3577b2352dcfb4450a36e0726ae4d47b34d80ed4..c006d95c841f7f9686e98a762901b99511a7e101 100644 --- a/alfa-client/libs/admin/shared/src/lib/admin-delete-open-dialog-button/admin-delete-open-dialog-button.component.html +++ b/alfa-client/libs/admin/shared/src/lib/admin-delete-open-dialog-button/admin-delete-open-dialog-button.component.html @@ -1,3 +1,3 @@ -<ods-open-dialog-button variant='outline_error' label="Löschen" dataTestId="delete-button" > +<ods-open-dialog-button variant="outline_error" label="Löschen" dataTestId="delete-button"> <ods-delete-icon icon /> -</ods-open-dialog-button> \ No newline at end of file +</ods-open-dialog-button> diff --git a/alfa-client/libs/admin/shared/src/lib/admin-save-button/admin-save-button.component.html b/alfa-client/libs/admin/shared/src/lib/admin-save-button/admin-save-button.component.html index 8bd6a5f92932e22006b3b8e2cb353a9c3fa93eb1..ccd9cc7ea4c19f667ba950072f96795375c8cbd9 100644 --- a/alfa-client/libs/admin/shared/src/lib/admin-save-button/admin-save-button.component.html +++ b/alfa-client/libs/admin/shared/src/lib/admin-save-button/admin-save-button.component.html @@ -2,5 +2,6 @@ (clickEmitter)="submit()" text="Speichern" dataTestId="save-button" + data-test-id="save" [stateResource]="stateResource$ | async" /> diff --git a/alfa-client/libs/admin/shared/src/lib/admin-save-button/admin-save-button.component.spec.ts b/alfa-client/libs/admin/shared/src/lib/admin-save-button/admin-save-button.component.spec.ts index 52a303f378e824677dd6518126ae838ebd416e3a..baee873bfd7c0db07a9295de75844d638edaead5 100644 --- a/alfa-client/libs/admin/shared/src/lib/admin-save-button/admin-save-button.component.spec.ts +++ b/alfa-client/libs/admin/shared/src/lib/admin-save-button/admin-save-button.component.spec.ts @@ -4,7 +4,7 @@ import { dispatchEventFromFixture, getMockComponent, Mock, MockEvent } from '@al import { ComponentFixture, TestBed } from '@angular/core/testing'; import { Resource } from '@ngxp/rest'; import { ButtonWithSpinnerComponent } from '@ods/component'; -import { getDataTestIdAttributeOf } from 'libs/tech-shared/test/data-test'; +import { getDataTestIdOf } from 'libs/tech-shared/test/data-test'; import { singleCold } from 'libs/tech-shared/test/marbles'; import { createDummyResource } from 'libs/tech-shared/test/resource'; import { MockComponent } from 'ng-mocks'; @@ -17,7 +17,7 @@ describe('AdminSaveButtonComponent', () => { let formService: Mock<AbstractFormService<Resource>>; - const saveButton: string = getDataTestIdAttributeOf('save-button'); + const saveButton: string = getDataTestIdOf('save'); const stateResource: StateResource<Resource> = createStateResource(createDummyResource()); diff --git a/alfa-client/libs/admin/statistik/src/lib/statistik-container/statistik-container.component.spec.ts b/alfa-client/libs/admin/statistik/src/lib/statistik-container/statistik-container.component.spec.ts index a2bc7e4bfe5efdec1af21b9ad1da7deaccf1a21f..3abca44e4a1aa07b3bceb119a0caf010014c02ed 100644 --- a/alfa-client/libs/admin/statistik/src/lib/statistik-container/statistik-container.component.spec.ts +++ b/alfa-client/libs/admin/statistik/src/lib/statistik-container/statistik-container.component.spec.ts @@ -23,12 +23,11 @@ */ import { AggregationMappingListResource, AggregationMappingService } from '@admin-client/reporting-shared'; import { createStateResource, StateResource } from '@alfa-client/tech-shared'; -import { existsAsHtmlElement, mock, Mock } from '@alfa-client/test-utils'; +import { mock, Mock } from '@alfa-client/test-utils'; import { ComponentFixture, TestBed } from '@angular/core/testing'; import { RoutingButtonComponent } from '@ods/component'; import { singleCold } from 'libs/tech-shared/test/marbles'; import { MockComponent } from 'ng-mocks'; -import { getDataTestIdAttributeOf } from '../../../../../tech-shared/test/data-test'; import { createAggregationMappingListResource } from '../../../../reporting-shared/test/aggregation-mapping'; import { StatistikContainerComponent } from './statistik-container.component'; @@ -36,8 +35,6 @@ describe('StatistikContainerComponent', () => { let component: StatistikContainerComponent; let fixture: ComponentFixture<StatistikContainerComponent>; - const evaluateAdditionalFieldsTestId: string = getDataTestIdAttributeOf('weitere-felder-auswerten-button'); - let aggregationMappingService: Mock<AggregationMappingService>; beforeEach(async () => { @@ -68,16 +65,6 @@ describe('StatistikContainerComponent', () => { expect(component).toBeTruthy(); }); - describe('template', () => { - describe('weiter felder auswerten button', () => { - it('should exists', () => { - fixture.detectChanges(); - - existsAsHtmlElement(fixture, evaluateAdditionalFieldsTestId); - }); - }); - }); - describe('on init', () => { const stateResource: StateResource<AggregationMappingListResource> = createStateResource( createAggregationMappingListResource(), diff --git a/alfa-client/libs/admin/statistik/src/lib/statistik-fields-form/admin-statistik-fields-form.component.html b/alfa-client/libs/admin/statistik/src/lib/statistik-fields-form/admin-statistik-fields-form.component.html index 27805c87fe074bae41311083bc1aed20d5aaeaef..ce24e7184c9f832dec08b205237303ce3cd25af7 100644 --- a/alfa-client/libs/admin/statistik/src/lib/statistik-fields-form/admin-statistik-fields-form.component.html +++ b/alfa-client/libs/admin/statistik/src/lib/statistik-fields-form/admin-statistik-fields-form.component.html @@ -7,18 +7,25 @@ [formControlName]="StatistikFieldsFormService.FIELD_FORM_ENGINE_NAME" label="Formengine" placeholder="Tragen Sie hier die Formengine des Formulars ein." - data-test-id="form-engine-name-input" + data-test-id="form-engine-name" + dataTestId="form-engine-name" ></ods-text-editor> <ods-text-editor [formControlName]="StatistikFieldsFormService.FIELD_FORM_ID" label="FormID" placeholder="Tragen Sie hier die FormID des Formulars ein." - data-test-id="form-id-input" + data-test-id="form-id" + dataTestId="form-id" ></ods-text-editor> </div> <statistik-fields-form-mapping /> </form> - <ods-button text="Datenfeld hinzufügen" dataTestId="add-mapping-button" (clickEmitter)="formService.addMapping()"> + <ods-button + text="Datenfeld hinzufügen" + dataTestId="add-mapping-button" + data-test-id="add-mapping" + (clickEmitter)="formService.addMapping()" + > <ods-plus-icon icon class="fill-whitetext" /> </ods-button> diff --git a/alfa-client/libs/admin/statistik/src/lib/statistik-fields-form/admin-statistik-fields-form.component.spec.ts b/alfa-client/libs/admin/statistik/src/lib/statistik-fields-form/admin-statistik-fields-form.component.spec.ts index a0154fd3137315cfbfd12187d70f0ffb43635df5..e124d07cf71b81b1c0ee692d87cd25ed8e8b59cd 100644 --- a/alfa-client/libs/admin/statistik/src/lib/statistik-fields-form/admin-statistik-fields-form.component.spec.ts +++ b/alfa-client/libs/admin/statistik/src/lib/statistik-fields-form/admin-statistik-fields-form.component.spec.ts @@ -6,7 +6,7 @@ import { FormBuilder, FormControl, FormGroup, ReactiveFormsModule } from '@angul import { TextEditorComponent } from '@ods/component'; import { ButtonComponent, PlusIconComponent } from '@ods/system'; import { MockComponent } from 'ng-mocks'; -import { getDataTestIdAttributeOf, getDataTestIdOf } from '../../../../../tech-shared/test/data-test'; +import { getDataTestIdOf } from '../../../../../tech-shared/test/data-test'; import { AdminCancelButtonComponent } from '../../../../shared/src/lib/admin-cancel-button/admin-cancel-button.component'; import { AdminSaveButtonComponent } from '../../../../shared/src/lib/admin-save-button/admin-save-button.component'; import { AdminStatistikFieldsFormComponent } from './admin-statistik-fields-form.component'; @@ -17,9 +17,9 @@ describe('AdminStatistikFieldsFormComponent', () => { let component: AdminStatistikFieldsFormComponent; let fixture: ComponentFixture<AdminStatistikFieldsFormComponent>; - const formEngineNameInputTestId: string = getDataTestIdOf('form-engine-name-input'); - const formIdInputTestId: string = getDataTestIdOf('form-id-input'); - const addMappingButton: string = getDataTestIdAttributeOf('add-mapping-button'); + const formEngineNameInputTestId: string = getDataTestIdOf('form-engine-name'); + const formIdInputTestId: string = getDataTestIdOf('form-id'); + const addMappingButton: string = getDataTestIdOf('add-mapping'); const formBuilder: FormBuilder = new FormBuilder(); diff --git a/alfa-client/libs/admin/statistik/src/lib/statistik-fields-form/statistik-fields-form-mapping/statistik-fields-form-mapping.component.html b/alfa-client/libs/admin/statistik/src/lib/statistik-fields-form/statistik-fields-form-mapping/statistik-fields-form-mapping.component.html index 2ce86b545b1039b795911cf172f154b9e2b97871..569fc993f66170c76ad2cad6c28679b36e86e210 100644 --- a/alfa-client/libs/admin/statistik/src/lib/statistik-fields-form/statistik-fields-form-mapping/statistik-fields-form-mapping.component.html +++ b/alfa-client/libs/admin/statistik/src/lib/statistik-fields-form/statistik-fields-form-mapping/statistik-fields-form-mapping.component.html @@ -10,6 +10,7 @@ formControlName="sourcePath" label="Pfad des Datenfeldes" placeholder="Tragen Sie hier den gesamten Pfad des Datenfeldes ein, das Sie auswerten möchten." + [dataTestId]="'mapping-field-' + i" [attr.data-test-id]="'mapping-field-' + i" ></ods-text-editor> <ods-button @@ -19,6 +20,7 @@ destructive="true" (clickEmitter)="formService.removeMapping(i)" [dataTestId]="'remove-mapping-button-' + i" + [attr.data-test-id]="'remove-mapping-' + i" > <ods-delete-icon icon /> </ods-button> diff --git a/alfa-client/libs/admin/statistik/src/lib/statistik-fields-form/statistik-fields-form-mapping/statistik-fields-form-mapping.component.spec.ts b/alfa-client/libs/admin/statistik/src/lib/statistik-fields-form/statistik-fields-form-mapping/statistik-fields-form-mapping.component.spec.ts index 61cd006e429951cde3657be7688b30063cc2e6eb..d06746e48f9660298e3c4e2d305a1404cd0e8605 100644 --- a/alfa-client/libs/admin/statistik/src/lib/statistik-fields-form/statistik-fields-form-mapping/statistik-fields-form-mapping.component.spec.ts +++ b/alfa-client/libs/admin/statistik/src/lib/statistik-fields-form/statistik-fields-form-mapping/statistik-fields-form-mapping.component.spec.ts @@ -5,7 +5,7 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; import { FormBuilder, FormControl, FormGroup, ReactiveFormsModule } from '@angular/forms'; import { TextEditorComponent } from '@ods/component'; import { ButtonComponent, DeleteIconComponent } from '@ods/system'; -import { getDataTestIdOf, getDynamicDataTestIdAttributOf } from 'libs/tech-shared/test/data-test'; +import { getDataTestIdOf } from 'libs/tech-shared/test/data-test'; import { MockComponent } from 'ng-mocks'; import { StatistikFieldsFormService } from '../statistik-fields.formservice'; import { AdminStatistikFieldsFormMappingComponent } from './statistik-fields-form-mapping.component'; @@ -15,7 +15,7 @@ describe('AdminStatistikFieldsFormMappingComponent', () => { let fixture: ComponentFixture<AdminStatistikFieldsFormMappingComponent>; const mappingField: string = getDataTestIdOf('mapping-field-0'); - const removeMappingButton: string = getDynamicDataTestIdAttributOf('remove-mapping-button-0'); + const removeMappingButton: string = getDataTestIdOf('remove-mapping-0'); const formBuilder: FormBuilder = new FormBuilder(); diff --git a/alfa-client/libs/admin/user/src/lib/user-form/user-form-headline/user-form-headline.component.html b/alfa-client/libs/admin/user/src/lib/user-form/user-form-headline/user-form-headline.component.html index 56c74fd10047e5dece25229b0888dbbe70f9ed12..c352d3863a3f95b25eabe0b448501702592f2db1 100644 --- a/alfa-client/libs/admin/user/src/lib/user-form/user-form-headline/user-form-headline.component.html +++ b/alfa-client/libs/admin/user/src/lib/user-form/user-form-headline/user-form-headline.component.html @@ -1,7 +1,7 @@ -<h1 class="heading-1 mb-4"> - @if(isPatch){ +<h1 class="heading-1 mb-4" data-test-id="benutzer-form-headline"> + @if (isPatch) { Benutzer bearbeiten } @else { Benutzer anlegen } -</h1> \ No newline at end of file +</h1> diff --git a/alfa-client/libs/admin/user/src/lib/user-form/user-form-save-button/user-form-save-button.component.html b/alfa-client/libs/admin/user/src/lib/user-form/user-form-save-button/user-form-save-button.component.html index 0277da75dbb4169dd33e4927d89702b1105ce9d9..064289aa47b5e6ff3e9e37656407d30cd0d52c8d 100644 --- a/alfa-client/libs/admin/user/src/lib/user-form/user-form-save-button/user-form-save-button.component.html +++ b/alfa-client/libs/admin/user/src/lib/user-form/user-form-save-button/user-form-save-button.component.html @@ -3,4 +3,4 @@ (clickEmitter)="submit()" text="Speichern" dataTestId="save-button" -/> \ No newline at end of file +/> diff --git a/alfa-client/libs/admin/user/src/lib/user-list-container/user-list/user-list.component.html b/alfa-client/libs/admin/user/src/lib/user-list-container/user-list/user-list.component.html index 153e3e19deecd0653b83ae9fc7e516f85b6a8716..c131614ac1e604fb3afc63765f97d57ad73e9c17 100644 --- a/alfa-client/libs/admin/user/src/lib/user-list-container/user-list/user-list.component.html +++ b/alfa-client/libs/admin/user/src/lib/user-list-container/user-list/user-list.component.html @@ -23,7 +23,7 @@ unter der Lizenz sind dem Lizenztext zu entnehmen. --> -<h1 class="heading-1 mb-4">Benutzer & Rollen</h1> +<h1 class="heading-1 mb-4" data-test-id="user-list-headline">Benutzer & Rollen</h1> <ods-routing-button [linkPath]="ROUTES.BENUTZER_NEU" text="Benutzer hinzufügen" class="mb-4 w-fit" dataTestId="add-user-button" /> <ods-list> @for (user of usersStateResource.resource; track $index) { diff --git a/alfa-client/libs/admin/user/src/lib/user-list-container/user-list/user/user-data/user-data.component.html b/alfa-client/libs/admin/user/src/lib/user-list-container/user-list/user/user-data/user-data.component.html index 7d455acd981b3767f809810878baea7ebedd5cf1..a09af6b607a48ed6e0bf6bddec4dedae9a1ebd46 100644 --- a/alfa-client/libs/admin/user/src/lib/user-list-container/user-list/user/user-data/user-data.component.html +++ b/alfa-client/libs/admin/user/src/lib/user-list-container/user-list/user/user-data/user-data.component.html @@ -4,13 +4,13 @@ <span class="sr-only">E-Mail:</span> <ods-mailbox-icon size="small" class="stroke-gray-600" /> </dt> - <dd>{{ user.email }}</dd> + <dd data-test-class="email">{{ user.email }}</dd> </div> <div class="flex items-center gap-2"> <dt> <span class="sr-only">Benutzername:</span> <ods-person-icon /> </dt> - <dd>{{ user.username }}</dd> + <dd data-test-class="username">{{ user.username }}</dd> </div> -</dl> \ No newline at end of file +</dl> diff --git a/alfa-client/libs/admin/user/src/lib/user-list-container/user-list/user/user-organisations-einheiten/user-organisations-einheiten.component.html b/alfa-client/libs/admin/user/src/lib/user-list-container/user-list/user/user-organisations-einheiten/user-organisations-einheiten.component.html index 550037d391c229139ce5248398ff7715a6e730d4..2836ffd0b61913f495192bfa344d376fb79b6584 100644 --- a/alfa-client/libs/admin/user/src/lib/user-list-container/user-list/user/user-organisations-einheiten/user-organisations-einheiten.component.html +++ b/alfa-client/libs/admin/user/src/lib/user-list-container/user-list/user/user-organisations-einheiten/user-organisations-einheiten.component.html @@ -1,18 +1,18 @@ <h4 class="sr-only">Zuständige Stellen</h4> @if (organisationsEinheiten.length > 0) { - <ul class="list-outside list-disc pl-4"> - @for(group of organisationsEinheiten | slice: 0 : MAX_GROUPS_TO_DISPLAY; track $index) { + <ul class="list-outside list-disc pl-4" data-test-class="organisations-einheiten"> + @for (group of organisationsEinheiten | slice: 0 : MAX_GROUPS_TO_DISPLAY; track $index) { <li>{{ group }}</li> } </ul> @if (organisationsEinheiten.length > MAX_GROUPS_TO_DISPLAY) { - @if(organisationsEinheiten.length - MAX_GROUPS_TO_DISPLAY === 1 ){ + @if (organisationsEinheiten.length - MAX_GROUPS_TO_DISPLAY === 1) { <p class="pl-4 text-gray-500">und 1 weiterer</p> } @else { <p class="pl-4 text-gray-500">und {{ organisationsEinheiten.length - MAX_GROUPS_TO_DISPLAY }} weitere</p> } } } @else { - <p> keine zuständige Stelle zugewiesen </p> -} \ No newline at end of file + <p data-test-class="no-organisations-einheit-text">keine zuständige Stelle zugewiesen</p> +} diff --git a/alfa-client/libs/admin/user/src/lib/user-list-container/user-list/user/user-roles/user-roles.component.html b/alfa-client/libs/admin/user/src/lib/user-list-container/user-list/user/user-roles/user-roles.component.html index 26b29dd6d1082879467997191335242a734aac76..f9f7e74372668a5ecf0a74c01808bc675c20327c 100644 --- a/alfa-client/libs/admin/user/src/lib/user-list-container/user-list/user/user-roles/user-roles.component.html +++ b/alfa-client/libs/admin/user/src/lib/user-list-container/user-list/user/user-roles/user-roles.component.html @@ -1,4 +1,4 @@ -<dl class="flex flex-wrap gap-2"> +<dl class="flex flex-wrap gap-2" data-test-class="roles"> <dt class="sr-only">Rollen:</dt> @for (role of roles; track $index) { <dd diff --git a/alfa-client/libs/admin/user/src/lib/user-list-container/user-list/user/user.component.html b/alfa-client/libs/admin/user/src/lib/user-list-container/user-list/user/user.component.html index b19df22eb0537d270a9485c8a03b39bf04108939..cda8fb80181aea98d263a1928f683852722a18d7 100644 --- a/alfa-client/libs/admin/user/src/lib/user-list-container/user-list/user/user.component.html +++ b/alfa-client/libs/admin/user/src/lib/user-list-container/user-list/user/user.component.html @@ -1,7 +1,7 @@ -<ods-list-item [path]="user.id" [attr.data-test-id]="'user-entry-' + user.username"> +<ods-list-item [path]="user.id" [attr.data-test-id]="(user.username | convertForDataTest) + '-user-entry'"> <div class="flex-1 basis-1/2"> <div class="mb-2 flex flex-wrap items-center gap-3"> - <h3 class="text-md font-semibold">{{ user | toUserName }}</h3> + <h3 class="text-md font-semibold" data-test-class="fullname">{{ user | toUserName }}</h3> <admin-user-roles [roles]="user | toUserRoles" /> </div> diff --git a/alfa-client/libs/admin/user/src/lib/user-list-container/user-list/user/user.component.spec.ts b/alfa-client/libs/admin/user/src/lib/user-list-container/user-list/user/user.component.spec.ts index afd371e8c6812b03a5b6b671545b4e4344c18ac3..42da5233cedfd9c1dd176fb8973f1b7ea388dc48 100644 --- a/alfa-client/libs/admin/user/src/lib/user-list-container/user-list/user/user.component.spec.ts +++ b/alfa-client/libs/admin/user/src/lib/user-list-container/user-list/user/user.component.spec.ts @@ -1,3 +1,4 @@ +import { ConvertForDataTestPipe } from '@alfa-client/tech-shared'; import { getMockComponent } from '@alfa-client/test-utils'; import { ComponentFixture, TestBed } from '@angular/core/testing'; import { ListItemComponent } from '@ods/system'; @@ -17,6 +18,7 @@ describe('UserComponent', () => { await TestBed.configureTestingModule({ imports: [ UserComponent, + ConvertForDataTestPipe, MockComponent(ListItemComponent), MockComponent(UserRolesComponent), MockComponent(UserDataComponent), diff --git a/alfa-client/libs/admin/user/src/lib/user-list-container/user-list/user/user.component.ts b/alfa-client/libs/admin/user/src/lib/user-list-container/user-list/user/user.component.ts index f46a2dc2950c2f651dc2e313a4831cbf10ca6ba8..49a54feaafe1f7b2444813699b7eeb2a15fc9487 100644 --- a/alfa-client/libs/admin/user/src/lib/user-list-container/user-list/user/user.component.ts +++ b/alfa-client/libs/admin/user/src/lib/user-list-container/user-list/user/user.component.ts @@ -1,4 +1,5 @@ import { ToUserNamePipe, ToUserRolesPipe, User } from '@admin-client/user-shared'; +import { ConvertForDataTestPipe } from '@alfa-client/tech-shared'; import { NgForOf } from '@angular/common'; import { Component, Input } from '@angular/core'; import { ListItemComponent } from '@ods/system'; @@ -17,6 +18,7 @@ import { UserRolesComponent } from './user-roles/user-roles.component'; UserDataComponent, UserRolesComponent, ToUserRolesPipe, + ConvertForDataTestPipe, ], templateUrl: './user.component.html', }) diff --git a/alfa-client/libs/design-component/src/lib/form/text-editor/text-editor.component.html b/alfa-client/libs/design-component/src/lib/form/text-editor/text-editor.component.html index c4901be8608a9e1162963472472090a19fad3a5a..c4c009107436b4b7a8837c0fa9c31c4add1008d6 100644 --- a/alfa-client/libs/design-component/src/lib/form/text-editor/text-editor.component.html +++ b/alfa-client/libs/design-component/src/lib/form/text-editor/text-editor.component.html @@ -29,7 +29,8 @@ [placeholder]="placeholder" [autocomplete]="autocomplete" [variant]="variant" - [attr.data-test-id]="(label | convertForDataTest) + '-text-editor'" + [attr.data-test-id]="dataTestId + '-text-editor'" + [dataTestId]="dataTestId" [required]="isRequired" [focus]="focus" [showLabel]="showLabel" @@ -38,6 +39,6 @@ error [invalidParams]="invalidParams" [label]="label" - [attr.data-test-id]="(label | convertForDataTest) + '-text-editor-error'" + [attr.data-test-id]="dataTestId + '-text-editor-error'" ></ods-validation-error> </ods-text-input> diff --git a/alfa-client/libs/design-component/src/lib/form/text-editor/text-editor.component.spec.ts b/alfa-client/libs/design-component/src/lib/form/text-editor/text-editor.component.spec.ts index 7774ab8ddcebff345d1d62853e8ced4e0773adae..e6dce44b7e467a5d99d3e45667f05c716e29fc68 100644 --- a/alfa-client/libs/design-component/src/lib/form/text-editor/text-editor.component.spec.ts +++ b/alfa-client/libs/design-component/src/lib/form/text-editor/text-editor.component.spec.ts @@ -35,8 +35,9 @@ describe('TextEditorComponent', () => { let fixture: ComponentFixture<TextEditorComponent>; const labelText: string = faker.word.noun(); - const inputTestId: string = getDataTestIdOf(labelText + '-text-editor'); - const errorId: string = getDataTestIdOf(labelText + '-text-editor-error'); + const dataTestId: string = faker.string.alphanumeric(10); + const inputTestId: string = getDataTestIdOf(dataTestId + '-text-editor'); + const errorId: string = getDataTestIdOf(dataTestId + '-text-editor-error'); beforeEach(async () => { await TestBed.configureTestingModule({ @@ -47,6 +48,7 @@ describe('TextEditorComponent', () => { fixture = TestBed.createComponent(TextEditorComponent); component = fixture.componentInstance; component.label = labelText; + component.dataTestId = dataTestId; fixture.detectChanges(); }); diff --git a/alfa-client/libs/design-component/src/lib/form/text-editor/text-editor.component.ts b/alfa-client/libs/design-component/src/lib/form/text-editor/text-editor.component.ts index cfdd66512de073b74f0dbfd2bbed633573f9651f..45f7c42c8f3f609567e89d3075411ac652eb8882 100644 --- a/alfa-client/libs/design-component/src/lib/form/text-editor/text-editor.component.ts +++ b/alfa-client/libs/design-component/src/lib/form/text-editor/text-editor.component.ts @@ -42,6 +42,7 @@ export class TextEditorComponent extends FormControlEditorAbstractComponent { @Input() isRequired: boolean = false; @Input() focus: boolean = false; @Input() showLabel: boolean = true; + @Input() dataTestId: string; get variant(): string { return this.invalidParams.length > 0 ? 'error' : 'default'; diff --git a/alfa-client/libs/design-system/src/lib/form/text-input/text-input.component.ts b/alfa-client/libs/design-system/src/lib/form/text-input/text-input.component.ts index ca6a007c19e49ebb481ff0655b407cc3076a9c08..1b8bf5fdf47948bbc9374b01086238c3e41c0ac3 100644 --- a/alfa-client/libs/design-system/src/lib/form/text-input/text-input.component.ts +++ b/alfa-client/libs/design-system/src/lib/form/text-input/text-input.component.ts @@ -21,7 +21,7 @@ * Die sprachspezifischen Genehmigungen und Beschränkungen * unter der Lizenz sind dem Lizenztext zu entnehmen. */ -import { convertForDataTest, ConvertForDataTestPipe, EMPTY_STRING } from '@alfa-client/tech-shared'; +import { convertForDataTest, ConvertForDataTestPipe, EMPTY_STRING, isNotUndefined } from '@alfa-client/tech-shared'; import { CommonModule } from '@angular/common'; import { Component, ElementRef, EventEmitter, Input, Output, ViewChild } from '@angular/core'; import { FormControl, ReactiveFormsModule } from '@angular/forms'; @@ -70,7 +70,7 @@ type TextInputVariants = VariantProps<typeof textInputVariants>; [autocomplete]="autocomplete" [attr.aria-required]="required" [attr.aria-invalid]="variant === 'error'" - [attr.data-test-id]="(inputLabel | convertForDataTest) + '-text-input'" + [attr.data-test-id]="_dataTestId + '-text-input'" (click)="clickEmitter.emit()" #inputElement /> @@ -88,6 +88,7 @@ export class TextInputComponent { @Input({ required: true }) set label(label: string) { this.inputLabel = label; this.id = `${convertForDataTest(label)}-${uniqueId()}`; + this._dataTestId = convertForDataTest(this.inputLabel); } @Input() placeholder: string = ''; @Input() autocomplete: string = 'off'; @@ -97,6 +98,9 @@ export class TextInputComponent { @Input() withPrefix: boolean = false; @Input() withSuffix: boolean = false; @Input() showLabel: boolean = true; + @Input() set dataTestId(value: string) { + if (isNotUndefined(value)) this._dataTestId = value; + } @Input() set focus(value: boolean) { if (value && this.inputElement) { @@ -108,5 +112,6 @@ export class TextInputComponent { inputLabel: string; id: string; + _dataTestId: string; textInputVariants = textInputVariants; }