diff --git a/alfa-client/apps/admin-e2e/cypress.config.json b/alfa-client/apps/admin-e2e/cypress.config.json index 7bab4470a97551fc92eee55d557dfd983d382fe3..5909e20614abeabc8173d107cf7b3dd8fa35330e 100644 --- a/alfa-client/apps/admin-e2e/cypress.config.json +++ b/alfa-client/apps/admin-e2e/cypress.config.json @@ -3,7 +3,9 @@ "env": { "keycloakRealm": "by-e2e-tests-local-dev", "keycloakUrl": "https://sso.dev.by.ozg-cloud.de", - "keycloakClient": "admin" + "keycloakClient": "admin", + "dbUrl": "mongodb://localhost:27017", + "database": "config-db" }, "fileServerFolder": ".", "fixturesFolder": "./src/fixtures", @@ -23,4 +25,4 @@ "reportFilename": "report", "overwrite": true } -} \ No newline at end of file +} 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 0e8e8e7f9acc081d300bfb18acb04c4292e7ab17..5a67a4226ff7d7d4eda4f7d57a69fdca18bd4d72 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 @@ -13,16 +13,11 @@ export class BenutzerE2EComponent { private readonly loeschenCheckbox: string = 'Loschen-checkbox-editor'; private readonly userCheckbox: string = 'User-checkbox-editor'; private readonly postCheckbox: string = 'Poststelle-checkbox-editor'; - private readonly userRolesTable: string = 'User-roles-table'; public getHinzufuegenButton(): Cypress.Chainable<Element> { return cy.getTestElement(this.benutzerHinzufuegenButton); } - public getUserRolesTable(): Cypress.Chainable<Element> { - return cy.getTestElement(this.userRolesTable); - } - public addUser(): void { this.getHinzufuegenButton().click(); } 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 new file mode 100644 index 0000000000000000000000000000000000000000..041bf093208cf29e77862ebab47324e04691eb14 --- /dev/null +++ b/alfa-client/apps/admin-e2e/src/components/organisationseinheiten/organisationseinheiten-signatur.e2e.component.ts @@ -0,0 +1,45 @@ +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 new file mode 100644 index 0000000000000000000000000000000000000000..f2c4e6ad137d219cc60a2055192098136270ec3f --- /dev/null +++ b/alfa-client/apps/admin-e2e/src/components/organisationseinheiten/organisationseinheiten.e2e.component.ts @@ -0,0 +1,54 @@ +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 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.'; + + 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 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); + } +} diff --git a/alfa-client/apps/admin-e2e/src/components/postfach/postfach.e2e.component.ts b/alfa-client/apps/admin-e2e/src/components/postfach/postfach.e2e.component.ts index c0b20783ba77f5247d66f50e4c1b21cab2c4271e..e450fde45239755baeda4f07c060d48ce5d845a1 100644 --- a/alfa-client/apps/admin-e2e/src/components/postfach/postfach.e2e.component.ts +++ b/alfa-client/apps/admin-e2e/src/components/postfach/postfach.e2e.component.ts @@ -9,6 +9,7 @@ export class PostfachE2EComponent { } public setSignatur(signatur: string): void { + this.clearSignatur(); typeText(this.getSignaturText(), signatur); } 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 c1d04589ac61fa4b53ac9781ac7f8cb6ca18a130..3df2287d6b55969a56f58c66568347813b3e1f3f 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 @@ -1,18 +1,15 @@ 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 { loginAsAriane } from '../../../support/user-util'; +import { AlfaRollen, AlfaUsers, loginAsAriane } from '../../../support/user-util'; const mainPage: MainPage = new MainPage(); const benutzerPage: BenutzerE2EComponent = new BenutzerE2EComponent(); -const role1: string = 'VERWALTUNG_USER'; -const role2: string = 'VERWALTUNG_LOESCHEN'; -const role3: string = 'VERWALTUNG_POSTSTELLE'; -const orga1: string = 'Ordnungsamt'; -const orga2: string = 'Denkmalpflege'; -const orga3: string = 'Wirtschaftsförderung'; -const orga_none: string = 'keine zuständige Stelle zugewiesen'; -const mail1: string = 'peter.von.der.post@ozg-sh.de'; +const organistationsEinheitOrdnungsamt: 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', () => { before(() => { @@ -25,21 +22,17 @@ describe('Benutzer und Rollen', () => { exist(benutzerPage.getHinzufuegenButton()); }); - it('should show table with users and roles', () => { - exist(benutzerPage.getUserRolesTable()); - }); - it('should show users and attributes in table', () => { exist(benutzerPage.getUserEntry('ariane')); - benutzerPage.stringExistsInUserEntry(role1, 'dorothea'); - benutzerPage.stringExistsInUserEntry(orga1, 'ludwig'); - benutzerPage.stringExistsInUserEntry(role1, 'zelda'); - benutzerPage.stringExistsInUserEntry(role2, 'zelda'); - benutzerPage.stringExistsInUserEntry(orga2, 'zelda'); - benutzerPage.stringExistsInUserEntry(orga3, 'zelda'); - benutzerPage.stringExistsInUserEntry(orga_none, 'adelheit'); - benutzerPage.stringExistsInUserEntry(mail1, 'peter'); - benutzerPage.stringExistsInUserEntry(role3, 'peter'); + benutzerPage.stringExistsInUserEntry(AlfaRollen.USER, AlfaUsers.DOROTHEA); + benutzerPage.stringExistsInUserEntry(organistationsEinheitOrdnungsamt, 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); }); it('should show single user screen on click', () => { diff --git a/alfa-client/apps/admin-e2e/src/e2e/main-tests/postfach/postfach-signatur.cy.ts b/alfa-client/apps/admin-e2e/src/e2e/main-tests/postfach/postfach-signatur.cy.ts new file mode 100644 index 0000000000000000000000000000000000000000..93efa8d8ba0639d999fbcdaf9f2387426ed61291 --- /dev/null +++ b/alfa-client/apps/admin-e2e/src/e2e/main-tests/postfach/postfach-signatur.cy.ts @@ -0,0 +1,34 @@ +import { PostfachE2EComponent } from '../../../components/postfach/postfach.e2e.component'; +import { waitForSpinnerToDisappear } from '../../../page-objects/main.po'; +import { exist } from '../../../support/cypress.util'; +import { loginAsAriane } from '../../../support/user-util'; + +describe('Signatur', () => { + const postfach: PostfachE2EComponent = new PostfachE2EComponent(); + + const signaturText: string = 'Signatur\nmit\n\n\n\nZeilenumbruch\n\n'; + + before(() => { + loginAsAriane(); + }); + + it('should show Postfach page', () => { + waitForSpinnerToDisappear(); + exist(postfach.getSignaturText()); + }); + + it('should show signature input with scrollbar', () => { + postfach.setSignatur(signaturText); + postfach.saveSignatur(); + + postfach.signatureIs(signaturText); + postfach.scrollbarIsPresent(); + }); + + it('should enter an save empty signature', () => { + postfach.clearSignatur(); + postfach.saveSignatur(); + + postfach.signatureIs(''); + }); +}); diff --git a/alfa-client/apps/admin-e2e/src/e2e/main-tests/postfach/signatur.cy.ts b/alfa-client/apps/admin-e2e/src/e2e/main-tests/postfach/signatur.cy.ts deleted file mode 100644 index 32323b02826811f53d7c617bf4558f870a1d29b4..0000000000000000000000000000000000000000 --- a/alfa-client/apps/admin-e2e/src/e2e/main-tests/postfach/signatur.cy.ts +++ /dev/null @@ -1,35 +0,0 @@ -import { PostfachE2EComponent } from '../../../components/postfach/postfach.e2e.component'; -import { HeaderE2EComponent } from '../../../page-objects/header.po'; -import { MainPage, waitForSpinnerToDisappear } from '../../../page-objects/main.po'; -import { exist } from '../../../support/cypress.util'; -import { loginAsAriane } from '../../../support/user-util'; - -describe('Signatur', () => { - const mainPage: MainPage = new MainPage(); - const header: HeaderE2EComponent = mainPage.getHeader(); - const postfachTab: PostfachE2EComponent = new PostfachE2EComponent(); - - const signaturText: string = 'Signatur\nmit\n\n\n\nZeilenumbruch\n\n'; - - before(() => { - loginAsAriane(); - }); - - it('should clear current signature', () => { - waitForSpinnerToDisappear(); - exist(postfachTab.getSignaturText()); - - postfachTab.clearSignatur(); - postfachTab.signatureIs(''); - - postfachTab.saveSignatur(); - }); - - it('should show Signatur input', () => { - postfachTab.setSignatur(signaturText); - postfachTab.saveSignatur(); - - postfachTab.signatureIs(signaturText); - postfachTab.scrollbarIsPresent(); - }); -}); diff --git a/alfa-client/apps/admin-e2e/src/e2e/organisationseinheiten/organisationseinheiten-laden.cy.ts b/alfa-client/apps/admin-e2e/src/e2e/organisationseinheiten/organisationseinheiten-laden.cy.ts new file mode 100644 index 0000000000000000000000000000000000000000..024419213edd7e67280c2fc9893d6864fd2469df --- /dev/null +++ b/alfa-client/apps/admin-e2e/src/e2e/organisationseinheiten/organisationseinheiten-laden.cy.ts @@ -0,0 +1,52 @@ +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('show Organisationsheiten', () => { + 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', () => { + waitForSpinnerToDisappear(); + mainPage.openOrganisationsEinheiten(); + + 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 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 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'); + }); +}); diff --git a/alfa-client/apps/admin-e2e/src/e2e/organisationseinheiten/organisationseinheiten-signaturen.cy.ts b/alfa-client/apps/admin-e2e/src/e2e/organisationseinheiten/organisationseinheiten-signaturen.cy.ts new file mode 100644 index 0000000000000000000000000000000000000000..cd484bd20a56578cd03f599cbe2757c000b471ed --- /dev/null +++ b/alfa-client/apps/admin-e2e/src/e2e/organisationseinheiten/organisationseinheiten-signaturen.cy.ts @@ -0,0 +1,40 @@ +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('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/fixtures/organisationseinheit/bauamt.json b/alfa-client/apps/admin-e2e/src/fixtures/organisationseinheit/bauamt.json new file mode 100644 index 0000000000000000000000000000000000000000..6a598ee189c3f6319de061ea7c5945abe568afec --- /dev/null +++ b/alfa-client/apps/admin-e2e/src/fixtures/organisationseinheit/bauamt.json @@ -0,0 +1,8 @@ +{ + "_id": { + "$oid": "602566a807bb665df9a86101" + }, + "name": "Bauamt", + "organisationsEinheitId": "248240886", + "syncResult": "OK" +} diff --git a/alfa-client/apps/admin-e2e/src/fixtures/organisationseinheit/denkmalpflege.json b/alfa-client/apps/admin-e2e/src/fixtures/organisationseinheit/denkmalpflege.json new file mode 100644 index 0000000000000000000000000000000000000000..b4043a822ffc01a60d8332584a99b37b6eade7cc --- /dev/null +++ b/alfa-client/apps/admin-e2e/src/fixtures/organisationseinheit/denkmalpflege.json @@ -0,0 +1,8 @@ +{ + "_id": { + "$oid": "602566a807bb665df9a86100" + }, + "name": "Landesamt für Denkmalpflege", + "organisationsEinheitId": "9093371", + "syncResult": "OK" +} diff --git a/alfa-client/apps/admin-e2e/src/fixtures/organisationseinheit/fundstelle.json b/alfa-client/apps/admin-e2e/src/fixtures/organisationseinheit/fundstelle.json new file mode 100644 index 0000000000000000000000000000000000000000..dfe93cb8fb0571e572b54285c3f764520e0f0501 --- /dev/null +++ b/alfa-client/apps/admin-e2e/src/fixtures/organisationseinheit/fundstelle.json @@ -0,0 +1,8 @@ +{ + "_id": { + "$oid": "602566a807bb665df9a86102" + }, + "name": "Fundstelle", + "organisationsEinheitId": "10363455", + "syncResult": "OK" +} diff --git a/alfa-client/apps/admin-e2e/src/model/util.ts b/alfa-client/apps/admin-e2e/src/model/util.ts new file mode 100644 index 0000000000000000000000000000000000000000..db337f7b99563e7bca14e7bc556249e0c86262b7 --- /dev/null +++ b/alfa-client/apps/admin-e2e/src/model/util.ts @@ -0,0 +1,3 @@ +export class ObjectIdE2E { + $oid: string; +} diff --git a/alfa-client/apps/admin-e2e/src/page-objects/main.po.ts b/alfa-client/apps/admin-e2e/src/page-objects/main.po.ts index 0d49928d6e5f08c470ff6489717098322ef970ef..90dde9a2818eb8e3d0ea43e55aa80c768262adbb 100644 --- a/alfa-client/apps/admin-e2e/src/page-objects/main.po.ts +++ b/alfa-client/apps/admin-e2e/src/page-objects/main.po.ts @@ -6,7 +6,7 @@ export class MainPage { private readonly header: HeaderE2EComponent = new HeaderE2EComponent(); private readonly benutzerTab: string = 'caption-Benutzer__Rollen'; private readonly postfachTab: string = 'caption-Postfach'; - private readonly organisationseinheitenTab: string = 'caption-Organisationseinheiten'; + private readonly organisationsEinheitenTab: string = 'caption-Organisationseinheiten'; public getBuildInfo(): BuildInfoE2EComponent { return this.buildInfo; @@ -24,12 +24,12 @@ export class MainPage { this.getBenutzerTab().click(); } - public getOrganisationseinheitenTab(): Cypress.Chainable<Element> { - return cy.getTestElement(this.organisationseinheitenTab); + public getOrganisationsEinheitenMenu(): Cypress.Chainable<Element> { + return cy.getTestElement(this.organisationsEinheitenTab); } - public clickOrganisationseinheitenTab(): void { - this.getOrganisationseinheitenTab().click(); + public openOrganisationsEinheiten(): void { + this.getOrganisationsEinheitenMenu().click(); } } diff --git a/alfa-client/apps/admin-e2e/src/support/cypress-helper.ts b/alfa-client/apps/admin-e2e/src/support/cypress-helper.ts index e9e5e65b43ffeba7ed077751880a2d4f8a634d1f..e288336c7d16d3fd66b645772cc1571c49b44de1 100644 --- a/alfa-client/apps/admin-e2e/src/support/cypress-helper.ts +++ b/alfa-client/apps/admin-e2e/src/support/cypress-helper.ts @@ -1,4 +1,14 @@ import { Interception, RouteHandler, RouteMatcher } from 'cypress/types/net-stubbing'; +import { OrganisationsEinheitE2E } from './organisationseinheit'; + +enum CypressTasks { + DROP_COLLECTIONS = 'dropCollections', + INIT_ORGANISATIONS_EINHEIT_DATA = 'initOrganisationsEinheitData', +} + +enum MongoCollections { + ORGANISATIONS_EINHEIT = 'organisationsEinheit', +} const DOWNLOAD_FOLDER: string = 'cypress/downloads'; @@ -14,11 +24,7 @@ export function intercept(method: string, url: string): Cypress.Chainable<null> return cy.intercept(method, url); } -export function interceptWithResponse( - method, - url: RouteMatcher, - response: RouteHandler, -): Cypress.Chainable<null> { +export function interceptWithResponse(method, url: RouteMatcher, response: RouteHandler): Cypress.Chainable<null> { return cy.intercept(method, url, response); } @@ -45,6 +51,7 @@ export function wait(ms: number, reason = ''): void { console.log(`Had to wait ${ms}ms because of: ${reason}`); } } + // export function reload(): void { @@ -68,3 +75,12 @@ export function getBaseUrl(): string { export function getCypressEnv(value: string) { return Cypress.env(value); } + +export function initOrganisationsEinheitenData(data: OrganisationsEinheitE2E[]): void { + cy.task(CypressTasks.DROP_COLLECTIONS, [MongoCollections.ORGANISATIONS_EINHEIT]); + cy.task(CypressTasks.INIT_ORGANISATIONS_EINHEIT_DATA, { collection: MongoCollections.ORGANISATIONS_EINHEIT, data }); +} + +export function dropCollections() { + cy.task(CypressTasks.DROP_COLLECTIONS, [MongoCollections.ORGANISATIONS_EINHEIT]); +} diff --git a/alfa-client/apps/admin-e2e/src/support/cypress-tasks.ts b/alfa-client/apps/admin-e2e/src/support/cypress-tasks.ts index 136431484e48612c068e8f2c5981bb6adc02f1e2..3d4769f1095fa7cf54b1fe0992618b7458f9b173 100644 --- a/alfa-client/apps/admin-e2e/src/support/cypress-tasks.ts +++ b/alfa-client/apps/admin-e2e/src/support/cypress-tasks.ts @@ -1,4 +1,5 @@ -import { MongoClient } from 'mongodb'; +import { Db, MongoClient, ObjectId } from 'mongodb'; + const fs = require('fs'); module.exports = (on: any, config: any) => { @@ -52,8 +53,12 @@ module.exports = (on: any, config: any) => { dropCollectionsFromDatabase(config, collections); return 0; }, + initOrganisationsEinheitData({ collection, data }) { + console.log('initOrganisationsEinheitData'); + insertIntoDatabase(config, collection, parseOrganisationsEinheitData(data)); + return 0; + }, }); - return config; // Ende - Workaround für Angular 13 und Cypress mit Webpack 4 }; @@ -89,3 +94,58 @@ function dropCollections(databaseUrl, databaseName, collections) { } }); } + +function insertIntoDatabase(config, collection, data) { + insert(getDatabaseUrl(config), getDatabase(config), collection, data); +} + +function insert(databaseUrl, databaseName, collection, data) { + MongoClient.connect(databaseUrl, (error, connection) => { + console.log(`connect to ${databaseName} database with ${databaseUrl}`); + if (!error) { + console.log('success'); + const db: Db = connection.db(databaseName); + + db.collection(collection).drop(() => { + db.createCollection(collection, (error) => handleCreateCollection(db, connection, collection, data, error)); + }); + } else { + console.error('Error: ', error); + } + }); +} + +function handleCreateCollection(db, connection, collection, data, error) { + if (error) { + console.error(`Fehler beim Erstellen der Collection "${collection}": `, error); + } else { + console.log(`Collection ${collection} erfolgreich erstellt`); + insertManyToDatabase(db, connection, collection, data); + } +} + +function insertManyToDatabase(db, connection, collection, data) { + db.collection(collection).insertMany(data, (error) => handleInsertMany(connection, error)); +} + +function handleInsertMany(connection, error) { + if (error) { + console.error('Fehler beim Einlesen der Daten: ', error); + } else { + console.log('Die Daten wurden erfolgreich eingelesen.'); + } + connection.close(); +} + +function parseOrganisationsEinheit(organisationsEinheit) { + organisationsEinheit._id = createObjectId(organisationsEinheit); +} + +function createObjectId(field) { + return new ObjectId(field._id.$oid); +} + +function parseOrganisationsEinheitData(data) { + data.forEach((organisationsEinheit) => parseOrganisationsEinheit(organisationsEinheit)); + return data; +} 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 4b45f922abb7e64be5329d03112af9769196c9fa..8eb3e6c0db0ea806a58eb30239dae08e51f382f4 100644 --- a/alfa-client/apps/admin-e2e/src/support/cypress.util.ts +++ b/alfa-client/apps/admin-e2e/src/support/cypress.util.ts @@ -113,6 +113,10 @@ export function backspaceOn(element: Cypress.Chainable<Element>): void { element.type(CypressKeyboardActions.BACKSPACE); } +export function clearText(element: Cypress.Chainable<Element>): void { + element.type('{selectAll}{del}'); +} + enum CypressKeyboardActions { ENTER = '{enter}', BACKSPACE = '{backspace}', diff --git a/alfa-client/apps/admin-e2e/src/support/organisationseinheit-util.ts b/alfa-client/apps/admin-e2e/src/support/organisationseinheit-util.ts new file mode 100644 index 0000000000000000000000000000000000000000..35e8ed50f915b1a8c58961f05c0c6e951831ca43 --- /dev/null +++ b/alfa-client/apps/admin-e2e/src/support/organisationseinheit-util.ts @@ -0,0 +1,26 @@ +import { initOrganisationsEinheitenData } from './cypress-helper'; +import { OrganisationsEinheitE2E } from './organisationseinheit'; + +const denkmalpflegeOrganisationseinheitFixture = require('../fixtures/organisationseinheit/denkmalpflege.json'); +const bauamtOrganisationseinheitFixture = require('../fixtures/organisationseinheit/bauamt.json'); +const fundstelleOrganisationseinheitFixture = require('../fixtures/organisationseinheit/fundstelle.json'); + +export function initOrganisationsEinheit(organisationsEinheiten: OrganisationsEinheitE2E): void { + initOrganisationsEinheitenData([organisationsEinheiten]); +} + +export function initOrganisationsEinheiten(organisationsEinheiten: OrganisationsEinheitE2E[]): void { + initOrganisationsEinheitenData(organisationsEinheiten); +} + +export function createBauamtOrganisationsEinheit(): OrganisationsEinheitE2E { + return bauamtOrganisationseinheitFixture; +} + +export function createFundstelleOrganisationsEinheit(): OrganisationsEinheitE2E { + return fundstelleOrganisationseinheitFixture; +} + +export function createDenkmalpflegeOrganisationsEinheit(): OrganisationsEinheitE2E { + return denkmalpflegeOrganisationseinheitFixture; +} diff --git a/alfa-client/apps/admin-e2e/src/support/organisationseinheit.ts b/alfa-client/apps/admin-e2e/src/support/organisationseinheit.ts new file mode 100644 index 0000000000000000000000000000000000000000..2a2850ca1ec05e4c53c0014df5fa689d98f6d1c1 --- /dev/null +++ b/alfa-client/apps/admin-e2e/src/support/organisationseinheit.ts @@ -0,0 +1,21 @@ +import { ObjectIdE2E } from '../model/util'; + +export class OrganisationsEinheitE2E { + _id: ObjectIdE2E; + name: string; + organisationsEinheitId: string; + syncResult: OrganisationsEinheitSyncResultE2E; + settings: OrganisationsEinheitSettingsE2E; +} + +export enum OrganisationsEinheitSyncResultE2E { + OK = 'OK', + NOT_FOUND_IN_PVOG = 'NOT_FOUND_IN_PVOG', + NAME_MISMATCH = 'NAME_MISMATCH', + ORGANISATIONSEINHEIT_ID_NOT_UNIQUE = 'ORGANISATIONSEINHEIT_ID_NOT_UNIQUE', + DELETED = 'DELETED', +} + +export class OrganisationsEinheitSettingsE2E { + signatur: string; +} 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 e8b54e6500b91758a66ebee2f02fd09e4b75aa54..1e4709eb69c5d2022f6f2659b3e1a383b4dbaf8e 100644 --- a/alfa-client/apps/admin-e2e/src/support/user-util.ts +++ b/alfa-client/apps/admin-e2e/src/support/user-util.ts @@ -42,3 +42,17 @@ export function logout(): void { const header: HeaderE2EComponent = mainPage.getHeader(); header.getCurrentUserProfile().logout(); } + +export enum AlfaRollen { + USER = 'VERWALTUNG_USER', + LOESCHEN = 'VERWALTUNG_LOESCHEN', + POSTSTELLE = 'VERWALTUNG_POSTSTELLE', +} + +export enum AlfaUsers { + DOROTHEA = 'dorothea', + LUDWIG = 'ludwig', + PETER = 'peter', + RICHARD = 'richard', + ZELDA = 'zelda', +} diff --git a/alfa-client/libs/admin/settings/src/lib/organisationseinheit/organisationseinheit-container/organisationseinheit-list/organisationseinheit-list.component.html b/alfa-client/libs/admin/settings/src/lib/organisationseinheit/organisationseinheit-container/organisationseinheit-list/organisationseinheit-list.component.html index 4d7bb88c347ce810280f41d2202077cccf4e9062..53a9c8fba9f1bbbc2b17d8c4a78a004330b4b18a 100644 --- a/alfa-client/libs/admin/settings/src/lib/organisationseinheit/organisationseinheit-container/organisationseinheit-list/organisationseinheit-list.component.html +++ b/alfa-client/libs/admin/settings/src/lib/organisationseinheit/organisationseinheit-container/organisationseinheit-list/organisationseinheit-list.component.html @@ -20,7 +20,7 @@ <dl class="flex-1 basis-1/12"> <dt class="sr-only">Synchronisationsergebnis</dt> - <dd class="mt-1"> + <dd class="mt-1" data-test-id="organisations-einheit-sync-error"> <ods-exclamation-icon *ngIf="organisationsEinheitResource.syncResult === AdminOrganisationsEinheitSyncResult.NOT_FOUND_IN_PVOG" matTooltip="Organisationseinheit wurde nicht in den PVOG-Daten gefunden."