Skip to content
Snippets Groups Projects
Commit c71f87b1 authored by Martin's avatar Martin
Browse files

Merge remote-tracking branch 'origin/main' into OZG-5977-E2E

parents 55cd332f d9a388fe
No related branches found
No related tags found
1 merge request!89Ozg 5977 e2 e
Showing
with 338 additions and 264 deletions
......@@ -100,11 +100,11 @@ export class BenutzerE2EComponent {
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 datenbeauftragungCheckbox: string = 'Datenbeauftragung-checkbox-editor';
private readonly adminCheckboxLabel: string = 'Admin';
private readonly loeschenCheckboxLabel: string = 'Löschen';
private readonly userCheckboxLabel: string = 'User';
private readonly postCheckboxLabel: string = 'Poststelle';
private readonly datenbeauftragungLabel: string = 'Datenbeauftragung';
private readonly organisationsEinheitCheckboxSuffix: string = '-checkbox-editor';
......@@ -115,6 +115,10 @@ export class BenutzerE2EComponent {
return cy.getTestElement(this.headline);
}
public getHeadline(): Cypress.Chainable<Element> {
return cy.getTestElement(this.headline);
}
public getVornameInput(): Cypress.Chainable<Element> {
return cy.getTestElement(this.userVorname);
}
......@@ -131,24 +135,24 @@ export class BenutzerE2EComponent {
return cy.getTestElement(this.userMail);
}
public getAdminCheckbox(): Cypress.Chainable<Element> {
return cy.getTestElement(this.adminCheckbox);
public getAdminCheckbox(): BenutzerCheckboxE2EComponent {
return new BenutzerCheckboxE2EComponent(this.adminCheckboxLabel);
}
public getLoeschenCheckbox(): Cypress.Chainable<Element> {
return cy.getTestElement(this.loeschenCheckbox);
public getLoeschenCheckbox(): BenutzerCheckboxE2EComponent {
return new BenutzerCheckboxE2EComponent(this.loeschenCheckboxLabel);
}
public getUserCheckbox(): Cypress.Chainable<Element> {
return cy.getTestElement(this.userCheckbox);
public getUserCheckbox(): BenutzerCheckboxE2EComponent {
return new BenutzerCheckboxE2EComponent(this.userCheckboxLabel);
}
public getPostCheckbox(): Cypress.Chainable<Element> {
return cy.getTestElement(this.postCheckbox);
public getPostCheckbox(): BenutzerCheckboxE2EComponent {
return new BenutzerCheckboxE2EComponent(this.postCheckboxLabel);
}
public getDatenbeauftragungCheckbox(): Cypress.Chainable<Element> {
return cy.getTestElement(this.datenbeauftragungCheckbox);
public getDatenbeauftragungCheckbox(): BenutzerCheckboxE2EComponent {
return new BenutzerCheckboxE2EComponent(this.datenbeauftragungLabel);
}
public getOrganisationsEinheitCheckbox(einheit: string): Cypress.Chainable<Element> {
......@@ -176,3 +180,29 @@ export class BenutzerDeleteDialogE2EComponent {
return cy.getTestElement(this.deleteButton);
}
}
export class BenutzerCheckboxE2EComponent {
private rootPrefix: string;
private prefix: string;
private readonly adminCheckbox: string = '-checkbox-editor';
private readonly adminInfoButtonSuffix: string = '-role-info-button';
private readonly adminInfoButtonTooltipSuffix: string = '-role-info-button-tooltip';
constructor(label: string) {
this.rootPrefix = convertToDataTestId(label);
this.prefix = convertToDataTestId(label.toLocaleLowerCase());
}
public getRoot(): Cypress.Chainable<Element> {
return cy.getTestElement(`${this.rootPrefix}${this.adminCheckbox}`);
}
public getInfoButton(): Cypress.Chainable<Element> {
return cy.getTestElement(`${this.prefix}${this.adminInfoButtonSuffix}`);
}
public getInfoButtonTooltip(): Cypress.Chainable<Element> {
return cy.getTestElement(`${this.prefix}${this.adminInfoButtonTooltipSuffix}`);
}
}
......@@ -21,19 +21,24 @@
* Die sprachspezifischen Genehmigungen und Beschränkungen
* unter der Lizenz sind dem Lizenztext zu entnehmen.
*/
import { haveValue, typeText } from '../../support/cypress.util';
import { haveValue } from '../../support/cypress.util';
export class PostfachE2EComponent {
private readonly headline: string = 'headline';
private readonly signaturText: string = 'signature-textarea';
private readonly saveSignaturButton: string = 'save-button';
public getHeadline(): any {
return cy.getTestElement(this.headline);
}
public getSignaturText(): any {
return cy.getTestElement(this.signaturText);
}
public setSignatur(signatur: string): void {
this.clearSignatur();
typeText(this.getSignaturText(), signatur);
this.getSignaturText().type(signatur);
}
public clearSignatur(): void {
......
import { typeText } from '../../support/cypress.util';
export class ZustaendigeStelleDialogE2EComponent {
private readonly locatorZustaendigeStelleForm: string = 'search-organisations-einheit';
private readonly locatorSearchInput: string = 'instant_search-text-input';
......@@ -15,7 +13,7 @@ export class ZustaendigeStelleDialogE2EComponent {
}
public enterSearchTerm(searchTerm: string): void {
typeText(this.getSearchInput(), searchTerm);
this.getSearchInput().type(searchTerm);
}
public countSearchEntries(): Cypress.Chainable<number> {
......
......@@ -57,4 +57,9 @@ describe('Benutzer anlegen', () => {
it('should show created user in list', () => {
benutzerVerifier.verifyUserInList(newUser);
});
it('should remove benutzer', () => {
benutzerHelper.deleteBenutzer(newUser.username);
benutzerVerifier.verifyUserNotInList(newUser.username);
});
});
......@@ -21,15 +21,11 @@
* Die sprachspezifischen Genehmigungen und Beschränkungen
* unter der Lizenz sind dem Lizenztext zu entnehmen.
*/
import { BenutzerE2EComponent, BenutzerListE2EComponent, BenutzerListItemE2EComponent, } from 'apps/admin-e2e/src/components/benutzer/benutzer.e2e.component';
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';
import { beChecked, beEnabled, contains, exist, mouseEnter, notBeChecked, notBeEnabled, visible, } from 'apps/admin-e2e/src/support/cypress.util';
import { AlfaRollen, AlfaUsers, loginAsAriane } from 'apps/admin-e2e/src/support/user-util';
describe('Benutzer und Rollen', () => {
const benutzerPage: BenutzerE2EComponent = new BenutzerE2EComponent();
......@@ -47,7 +43,7 @@ describe('Benutzer und Rollen', () => {
it('should show users and attributes in list', () => {
helper.openBenutzerListPage();
const ariane: BenutzerListItemE2EComponent = benutzerListPage.getItem(AlfaUsers.ARAINE);
const ariane: BenutzerListItemE2EComponent = benutzerListPage.getItem(AlfaUsers.ARIANE);
exist(ariane.getRoot());
contains(ariane.getRoles(), AlfaRollen.USER);
......@@ -76,64 +72,93 @@ describe('Benutzer und Rollen', () => {
exist(richard.getNoOrganisationsEinheitText());
});
it('should show single user screen on click', () => {
it('should show checkbox for each role', () => {
helper.openNewBenutzerPage();
exist(benutzerPage.getVornameInput());
exist(benutzerPage.getNachnameInput());
exist(benutzerPage.getBenutzernameInput());
exist(benutzerPage.getMailInput());
notBeChecked(benutzerPage.getAdminCheckbox().getRoot());
notBeChecked(benutzerPage.getDatenbeauftragungCheckbox().getRoot());
notBeChecked(benutzerPage.getLoeschenCheckbox().getRoot());
notBeChecked(benutzerPage.getUserCheckbox().getRoot());
notBeChecked(benutzerPage.getPostCheckbox().getRoot());
});
it('should deactivate other alfa roles if "loeschen" role is selected', () => {
benutzerPage.getLoeschenCheckbox().getRoot().click();
beChecked(benutzerPage.getLoeschenCheckbox().getRoot());
notBeEnabled(benutzerPage.getUserCheckbox().getRoot());
notBeEnabled(benutzerPage.getPostCheckbox().getRoot());
benutzerPage.getLoeschenCheckbox().getRoot().click();
notBeChecked(benutzerPage.getLoeschenCheckbox().getRoot());
beEnabled(benutzerPage.getUserCheckbox().getRoot());
beEnabled(benutzerPage.getPostCheckbox().getRoot());
});
it('should deactivate other alfa roles if "user" role is selected', () => {
benutzerPage.getUserCheckbox().getRoot().click();
beChecked(benutzerPage.getUserCheckbox().getRoot());
notBeEnabled(benutzerPage.getLoeschenCheckbox().getRoot());
notBeEnabled(benutzerPage.getPostCheckbox().getRoot());
benutzerPage.getUserCheckbox().getRoot().click();
notBeChecked(benutzerPage.getUserCheckbox().getRoot());
beEnabled(benutzerPage.getLoeschenCheckbox().getRoot());
beEnabled(benutzerPage.getPostCheckbox().getRoot());
});
it('should deactivate other alfa roles if "poststelle" role is selected', () => {
benutzerPage.getPostCheckbox().getRoot().click();
beChecked(benutzerPage.getPostCheckbox().getRoot());
notBeEnabled(benutzerPage.getLoeschenCheckbox().getRoot());
notBeEnabled(benutzerPage.getUserCheckbox().getRoot());
notBeChecked(benutzerPage.getAdminCheckbox());
notBeChecked(benutzerPage.getLoeschenCheckbox());
notBeChecked(benutzerPage.getUserCheckbox());
notBeChecked(benutzerPage.getPostCheckbox());
benutzerPage.getPostCheckbox().getRoot().click();
notBeChecked(benutzerPage.getPostCheckbox().getRoot());
beEnabled(benutzerPage.getLoeschenCheckbox().getRoot());
beEnabled(benutzerPage.getUserCheckbox().getRoot());
});
it('should activate loeschen checkbox and deactivate the other two checkboxes', () => {
benutzerPage.getLoeschenCheckbox().click();
beChecked(benutzerPage.getLoeschenCheckbox());
notBeEnabled(benutzerPage.getUserCheckbox());
notBeEnabled(benutzerPage.getPostCheckbox());
it('should activate and deactivate admin roles', () => {
benutzerPage.getAdminCheckbox().getRoot().click();
benutzerPage.getDatenbeauftragungCheckbox().getRoot().click();
beChecked(benutzerPage.getAdminCheckbox().getRoot());
beChecked(benutzerPage.getDatenbeauftragungCheckbox().getRoot());
benutzerPage.getLoeschenCheckbox().click();
notBeChecked(benutzerPage.getLoeschenCheckbox());
beEnabled(benutzerPage.getUserCheckbox());
beEnabled(benutzerPage.getPostCheckbox());
benutzerPage.getAdminCheckbox().getRoot().click();
benutzerPage.getDatenbeauftragungCheckbox().getRoot().click();
notBeChecked(benutzerPage.getAdminCheckbox().getRoot());
notBeChecked(benutzerPage.getDatenbeauftragungCheckbox().getRoot());
});
it('should additionally activate and deactivate admin checkbox', () => {
benutzerPage.getLoeschenCheckbox().click();
benutzerPage.getAdminCheckbox().click();
beChecked(benutzerPage.getLoeschenCheckbox());
beChecked(benutzerPage.getAdminCheckbox());
describe('hint text', () => {
it('should be visible on admin role mouse hover', () => {
mouseEnter(benutzerPage.getAdminCheckbox().getInfoButton());
benutzerPage.getAdminCheckbox().click();
notBeChecked(benutzerPage.getAdminCheckbox());
visible(benutzerPage.getAdminCheckbox().getInfoButtonTooltip());
});
it('should activate user checkbox and deactivate the other two checkboxes', () => {
benutzerPage.getLoeschenCheckbox().click();
benutzerPage.getUserCheckbox().click();
beChecked(benutzerPage.getUserCheckbox());
notBeEnabled(benutzerPage.getLoeschenCheckbox());
notBeEnabled(benutzerPage.getPostCheckbox());
benutzerPage.getUserCheckbox().click();
notBeChecked(benutzerPage.getUserCheckbox());
beEnabled(benutzerPage.getLoeschenCheckbox());
beEnabled(benutzerPage.getPostCheckbox());
it('should be visible on loeschen role mouse hover', () => {
mouseEnter(benutzerPage.getLoeschenCheckbox().getInfoButton());
visible(benutzerPage.getLoeschenCheckbox().getInfoButtonTooltip());
});
it('should be visible on user role mouse hover', () => {
mouseEnter(benutzerPage.getUserCheckbox().getInfoButton());
visible(benutzerPage.getUserCheckbox().getInfoButtonTooltip());
});
it('should activate post checkbox and deactivate the other two checkboxes', () => {
benutzerPage.getPostCheckbox().click();
beChecked(benutzerPage.getPostCheckbox());
notBeEnabled(benutzerPage.getLoeschenCheckbox());
notBeEnabled(benutzerPage.getUserCheckbox());
it('should be visible on poststellt role mouse hover', () => {
mouseEnter(benutzerPage.getPostCheckbox().getInfoButton());
benutzerPage.getPostCheckbox().click();
notBeChecked(benutzerPage.getPostCheckbox());
beEnabled(benutzerPage.getLoeschenCheckbox());
beEnabled(benutzerPage.getUserCheckbox());
visible(benutzerPage.getPostCheckbox().getInfoButtonTooltip());
});
it('should be visible on datenbeauftragung role mouse hover', () => {
mouseEnter(benutzerPage.getDatenbeauftragungCheckbox().getInfoButton());
visible(benutzerPage.getDatenbeauftragungCheckbox().getInfoButtonTooltip());
});
});
});
import { MainPage, waitForSpinnerToDisappear } from 'apps/admin-e2e/src/page-objects/main.po';
import { exist, notExist } from 'apps/admin-e2e/src/support/cypress.util';
import { MainPage } from 'apps/admin-e2e/src/page-objects/main.po';
import { containClass, exist, notExist } from 'apps/admin-e2e/src/support/cypress.util';
import { loginAsAriane } from 'apps/admin-e2e/src/support/user-util';
describe('Navigation', () => {
describe('Ariane Navigation', () => {
const mainPage: MainPage = new MainPage();
describe('with user ariane', () => {
before(() => {
loginAsAriane();
waitForSpinnerToDisappear();
});
it('should show benutzer navigation item', () => {
exist(mainPage.getBenutzerNavigationItem());
});
it('should show postfach navigation item', () => {
it('should show organisationseinheiten navigation item', () => {
exist(mainPage.getOrganisationEinheitNavigationItem());
});
describe('postfach navigation item', () => {
it('should be visible', () => {
exist(mainPage.getPostfachNavigationItem());
});
it('should show organisationseinheiten navigation item', () => {
exist(mainPage.getOrganisationEinheitNavigationItem());
it('should be selected initial', () => {
containClass(mainPage.getPostfachNavigationItem(), 'border-selected');
});
});
it('should hide statistik navigation item', () => {
......
import { MainPage, waitForSpinnerToDisappear } from 'apps/admin-e2e/src/page-objects/main.po';
import { exist, notExist, visible } from 'apps/admin-e2e/src/support/cypress.util';
import { MainPage } from 'apps/admin-e2e/src/page-objects/main.po';
import { containClass, exist, notExist } 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';
describe('Navigation', () => {
describe('Daria Navigation', () => {
const mainPage: MainPage = new MainPage();
const statistikPage: StatistikE2EComponent = new StatistikE2EComponent();
describe('with user daria', () => {
before(() => {
loginAsDaria();
waitForSpinnerToDisappear();
});
it('should hide other navigation item', () => {
it('should hide benutzer navigation item', () => {
notExist(mainPage.getBenutzerNavigationItem());
});
it('should hide postfach navigation item', () => {
notExist(mainPage.getPostfachNavigationItem());
});
it('should hide organisationseinheiten navigation item', () => {
notExist(mainPage.getOrganisationEinheitNavigationItem());
});
describe('statistik', () => {
it('should hide postfach navigation item', () => {
notExist(mainPage.getPostfachNavigationItem());
});
describe('statistik navigation item', () => {
it('should be visible', () => {
exist(mainPage.getStatistikNavigationItem());
});
it('should be initial selected', () => {
mainPage.isStatistikNavigationItemSelected();
});
it('should show header text', () => {
visible(statistikPage.getHeaderText());
containClass(mainPage.getStatistikNavigationItem(), 'border-selected');
});
});
});
......
import { MainPage, waitForSpinnerToDisappear } from 'apps/admin-e2e/src/page-objects/main.po';
import { exist, visible } from 'apps/admin-e2e/src/support/cypress.util';
import { MainPage } from 'apps/admin-e2e/src/page-objects/main.po';
import { containClass, exist } 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';
describe('Navigation', () => {
describe('Safira Navigation', () => {
const mainPage: MainPage = new MainPage();
const statistikPage: StatistikE2EComponent = new StatistikE2EComponent();
describe('with user safira', () => {
before(() => {
loginAsSafira();
waitForSpinnerToDisappear();
});
it('should show benutzer navigation item', () => {
exist(mainPage.getBenutzerNavigationItem());
});
it('should show postfach navigation item', () => {
exist(mainPage.getPostfachNavigationItem());
});
it('should show organisationseinheiten navigation item', () => {
exist(mainPage.getOrganisationEinheitNavigationItem());
});
describe('statistik', () => {
describe('postfach navigation item', () => {
it('should be visible', () => {
exist(mainPage.getStatistikNavigationItem());
exist(mainPage.getPostfachNavigationItem());
});
describe('on selection', () => {
before(() => {
mainPage.clickStatistikNavigationItem();
it('should be selected initial', () => {
containClass(mainPage.getPostfachNavigationItem(), 'border-selected');
});
it('should show page on selection', () => {
visible(statistikPage.getHeaderText());
});
it('should mark navigation item as selected', () => {
mainPage.isStatistikNavigationItemSelected();
});
});
it('should show statistik navigation item', () => {
exist(mainPage.getStatistikNavigationItem());
});
});
});
......@@ -21,12 +21,12 @@
* Die sprachspezifischen Genehmigungen und Beschränkungen
* unter der Lizenz sind dem Lizenztext zu entnehmen.
*/
import { E2EPostfachHelper } from 'apps/admin-e2e/src/helper/postfach/postfach.helper';
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', () => {
describe('(TODO: Ist noch wackelig in Bezug auf die Eingabe in das Feld) Postfach Signatur', () => {
const postfachHelper: E2EPostfachHelper = new E2EPostfachHelper();
const postfach: PostfachE2EComponent = new PostfachE2EComponent();
const signaturText: string = 'Signatur\nmit\n\n\n\nZeilenumbruch\n\n';
......@@ -35,12 +35,9 @@ describe('Signatur', () => {
loginAsAriane();
});
it('should show Postfach page', () => {
waitForSpinnerToDisappear();
exist(postfach.getSignaturText());
});
it('should show signature input with scrollbar', () => {
postfachHelper.openPostfachPage();
postfach.setSignatur(signaturText);
postfach.saveSignatur();
......
......@@ -21,16 +21,16 @@ export class E2EBenutzerExecutor {
this.benutzerPage.getMailInput().type(user.email);
if (user.isAdmin) {
this.benutzerPage.getAdminCheckbox().click();
this.benutzerPage.getAdminCheckbox().getRoot().click();
}
if (user.isUser) {
this.benutzerPage.getUserCheckbox().click();
this.benutzerPage.getUserCheckbox().getRoot().click();
}
if (user.isLoeschen) {
this.benutzerPage.getLoeschenCheckbox().click();
this.benutzerPage.getLoeschenCheckbox().getRoot().click();
}
if (user.isPoststelle) {
this.benutzerPage.getPostCheckbox().click();
this.benutzerPage.getPostCheckbox().getRoot().click();
}
this.modifyOrganisationsEinheiten(user.organisationseinheiten);
......
import { E2EPostfachNavigator } from './postfach.navigator';
export class E2EPostfachHelper {
private readonly navigator: E2EPostfachNavigator = new E2EPostfachNavigator();
public openPostfachPage(): void {
this.navigator.openPostfachPage();
}
}
import { PostfachE2EComponent } from '../../components/postfach/postfach.e2e.component';
import { MainPage } from '../../page-objects/main.po';
import { exist } from '../../support/cypress.util';
export class E2EPostfachNavigator {
private mainPage: MainPage = new MainPage();
private postfach: PostfachE2EComponent = new PostfachE2EComponent();
public openPostfachPage(): void {
this.navigateToDomain();
this.mainPage.getPostfachNavigationItem().click();
exist(this.postfach.getHeadline());
}
private navigateToDomain(): void {
this.mainPage.getHeader().getLogo().click();
}
}
......@@ -46,6 +46,7 @@ export interface AdminUserE2E {
username: string;
email: string;
isAdmin?: boolean;
isDatenbeauftragung?: boolean;
isUser?: boolean;
isLoeschen?: boolean;
isPoststelle?: boolean;
......
......@@ -22,17 +22,16 @@
* unter der Lizenz sind dem Lizenztext zu entnehmen.
*/
import { BuildInfoE2EComponent } from '../components/buildinfo/buildinfo.e2e.component';
import { containClass, exist } from '../support/cypress.util';
import { HeaderE2EComponent } from './header.po';
export class MainPage {
private readonly buildInfo: BuildInfoE2EComponent = new BuildInfoE2EComponent();
private readonly header: HeaderE2EComponent = new HeaderE2EComponent();
private readonly benutzerNavigationItem: string = 'caption-Benutzer__Rollen';
private readonly postfachNavigationItem: string = 'postfach-navigation';
private readonly organisationEinheitNavigationItem: string = 'organisations-einheiten-navigation';
private readonly statistikNavigationItem: string = 'statistik-navigation';
private readonly benutzerNavigationItem: string = 'link-path-benutzer';
private readonly organisationEinheitNavigationItem: string = 'link-path-organisationseinheiten';
private readonly postfachNavigationItem: string = 'link-path-postfach';
private readonly statistikNavigationItem: string = 'link-path-statistik';
public getBuildInfo(): BuildInfoE2EComponent {
return this.buildInfo;
......@@ -46,41 +45,17 @@ export class MainPage {
return cy.getTestElement(this.benutzerNavigationItem);
}
public clickBenutzerNavigationItem(): void {
this.getBenutzerNavigationItem().click();
}
public benutzerNavigationItemIsVisible(): void {
exist(this.getBenutzerNavigationItem());
}
public getPostfachNavigationItem(): Cypress.Chainable<Element> {
return cy.getTestElement(this.postfachNavigationItem);
}
public clickPostfachNavigationItem(): void {
this.getPostfachNavigationItem().click();
}
public getOrganisationEinheitNavigationItem(): Cypress.Chainable<Element> {
return cy.getTestElement(this.organisationEinheitNavigationItem);
}
public clickOrganisationsEinheitenNavigationItem(): void {
this.getOrganisationEinheitNavigationItem().click();
}
public getStatistikNavigationItem(): Cypress.Chainable<Element> {
return cy.getTestElement(this.statistikNavigationItem);
}
public clickStatistikNavigationItem(): void {
this.getStatistikNavigationItem().click();
}
public isStatistikNavigationItemSelected(): void {
containClass(this.getStatistikNavigationItem().get('a'), 'border-selected');
}
}
export function waitForSpinnerToDisappear(): boolean {
......
......@@ -60,10 +60,6 @@ export function mouseEnter(element: Cypress.Chainable<Element>): void {
element.trigger('mouseenter');
}
export function mouseOver(element: Cypress.Chainable<Element>): void {
element.trigger('mouseover');
}
export function contains(element: Cypress.Chainable<Element>, containing: string): void {
element.should('exist').contains(containing);
}
......@@ -128,10 +124,6 @@ export function enterWith(element: Cypress.Chainable<Element>, value: string, de
element.type(CypressKeyboardActions.ENTER);
}
export function typeText(element: Cypress.Chainable<Element>, value: string): void {
element.type(value);
}
export function backspaceOn(element: Cypress.Chainable<Element>): void {
element.type(CypressKeyboardActions.BACKSPACE);
}
......
......@@ -10,6 +10,6 @@ export function replaceAllWhitespaces(value: string, replaceWith: string): strin
return value.replace(/ /g, replaceWith);
}
export function simpleTransliteration(value: string) {
export function simpleTransliteration(value: string): string {
return value.normalize('NFKD').replace(/[^-A-Za-z0-9_]/g, '');
}
......@@ -89,10 +89,12 @@ export enum AlfaRollen {
LOESCHEN = 'VERWALTUNG_LOESCHEN',
POSTSTELLE = 'VERWALTUNG_POSTSTELLE',
ADMIN = 'ADMIN_ADMIN',
DATEN = 'DATENBEAUFTRAGUNG',
}
export enum AlfaUsers {
ARAINE = 'ariane',
ARIANE = 'ariane',
DARIA = 'daria',
DOROTHEA = 'dorothea',
LUDWIG = 'ludwig',
PETER = 'peter',
......
{
"name": "admin",
"version": "1.6.0-SNAPSHOT"
"version": "1.7.0-SNAPSHOT"
}
......@@ -55,13 +55,20 @@ describe('AppComponent', () => {
const routerOutletSelector: string = getDataTestIdOf('router-outlet');
const menuContainer: string = getDataTestIdOf('menu-container');
const authenticationService: Mock<AuthenticationService> = {
let authenticationService: Mock<AuthenticationService>;
let router: Mock<Router>;
let route: Mock<ActivatedRoute>;
let apiRootService: Mock<ApiRootService>;
let configurationService: Mock<ConfigurationService>;
let keycloakTokenService: Mock<KeycloakTokenService>;
beforeEach(async () => {
authenticationService = {
...mock(AuthenticationService),
login: jest.fn().mockResolvedValue(Promise.resolve()),
};
const router: Mock<Router> = mock(Router);
const route: Mock<ActivatedRoute> = {
router = mock(Router);
route = {
...mock(ActivatedRoute),
snapshot: {
queryParams: {
......@@ -72,12 +79,7 @@ describe('AppComponent', () => {
},
} as any,
};
const apiRootService: Mock<ApiRootService> = mock(ApiRootService);
let configurationService: Mock<ConfigurationService>;
let keycloakTokenService: Mock<KeycloakTokenService>;
beforeEach(async () => {
apiRootService = mock(ApiRootService);
configurationService = mock(ConfigurationService);
keycloakTokenService = mock(KeycloakTokenService);
......@@ -145,81 +147,110 @@ describe('AppComponent', () => {
expect(authenticationService.login).toHaveBeenCalled();
});
it('should call doAfterLoggedIn', async () => {
component.doAfterLoggedIn = jest.fn();
it('should call doAfterLoggedIn only once', async () => {
component._doAfterLoggedIn = jest.fn();
component.ngOnInit();
await fixture.whenStable();
expect(component.doAfterLoggedIn).toHaveBeenCalled();
expect(component._doAfterLoggedIn).toHaveBeenCalledTimes(1);
});
});
describe('do after logged in', () => {
beforeEach(() => {
component.evaluateInitialNavigation = jest.fn();
component._evaluateInitialNavigation = jest.fn();
});
it('should call apiRootService to getApiRoot', () => {
component.doAfterLoggedIn();
component._doAfterLoggedIn();
expect(apiRootService.getApiRoot).toHaveBeenCalled();
});
it('should call keycloak token service to register token provider', () => {
component.doAfterLoggedIn();
component._doAfterLoggedIn();
expect(keycloakTokenService.registerAccessTokenProvider).toHaveBeenCalled();
});
it('should call evaluateInitialNavigation', () => {
component.doAfterLoggedIn();
component._doAfterLoggedIn();
expect(component.evaluateInitialNavigation).toHaveBeenCalled();
expect(component._evaluateInitialNavigation).toHaveBeenCalled();
});
});
describe('evaluate initial navigation', () => {
beforeEach(() => {
component.evaluateNavigationByApiRoot = jest.fn();
component._evaluateNavigationByApiRoot = jest.fn();
component._subscribeApiRootForEvaluation = jest.fn();
});
it('should call evaluate navigation by apiRoot', () => {
it('should call router navigate', () => {
window.location.pathname = '/path';
(router as any).url = '/path';
component._evaluateInitialNavigation();
expect(router.navigate).toHaveBeenCalledWith([window.location.pathname]);
});
it('should call subscribe api root evaluation if url starts with /?state', () => {
(router as any).url = '/?state=some-state';
component._evaluateInitialNavigation();
expect(component._subscribeApiRootForEvaluation).toHaveBeenCalled();
});
});
describe('subscribeApiRootForEvaluation', () => {
const apiRootResource: ApiRootResource = createApiRootResource();
beforeEach(() => {
component.apiRootStateResource$ = of(createStateResource(apiRootResource));
component._evaluateNavigationByApiRoot = jest.fn();
});
it('should set apiRootSubscription', () => {
component._subscribeApiRootForEvaluation();
component.evaluateInitialNavigation();
expect(component.apiRootSubscription).toBeDefined();
});
it('should call evaluate navigation by apiRoot', () => {
component._subscribeApiRootForEvaluation();
expect(component.evaluateNavigationByApiRoot).toHaveBeenCalledWith(apiRootResource);
expect(component._evaluateNavigationByApiRoot).toHaveBeenCalledWith(apiRootResource);
});
it('should NOT call evaluate navigation by apiRoot if resource is loading', () => {
component.apiRootStateResource$ = of(createEmptyStateResource<ApiRootResource>(true));
component.evaluateNavigationByApiRoot = jest.fn();
component.apiRootStateResource$ = of(createStateResource(apiRootResource, true));
component.evaluateInitialNavigation();
component._subscribeApiRootForEvaluation();
expect(component.evaluateNavigationByApiRoot).not.toHaveBeenCalled();
expect(component._evaluateNavigationByApiRoot).not.toHaveBeenCalled();
});
});
describe('evaluate navigation api root', () => {
it('should evaluate navigation by configuration if link exists', () => {
component.evaluateNavigationByConfiguration = jest.fn();
component._evaluateNavigationByConfiguration = jest.fn();
const apiRootResource: ApiRootResource = createApiRootResource([ApiRootLinkRel.CONFIGURATION]);
component.evaluateNavigationByApiRoot(apiRootResource);
component._evaluateNavigationByApiRoot(apiRootResource);
expect(component.evaluateNavigationByConfiguration).toHaveBeenCalled();
expect(component._evaluateNavigationByConfiguration).toHaveBeenCalled();
});
it('should navigate by api root if link is missing', () => {
component.navigateByApiRoot = jest.fn();
component._navigateByApiRoot = jest.fn();
const apiRootResource: ApiRootResource = createApiRootResource();
component.evaluateNavigationByApiRoot(apiRootResource);
component._evaluateNavigationByApiRoot(apiRootResource);
expect(component.navigateByApiRoot).toHaveBeenCalledWith(apiRootResource);
expect(component._navigateByApiRoot).toHaveBeenCalledWith(apiRootResource);
});
});
......@@ -228,83 +259,83 @@ describe('AppComponent', () => {
beforeEach(() => {
configurationService.get.mockReturnValue(of(createStateResource(configurationResource)));
component.navigateByConfiguration = jest.fn();
component._navigateByConfiguration = jest.fn();
});
it('should call configuration service to get resource', () => {
component.evaluateNavigationByConfiguration();
component._evaluateNavigationByConfiguration();
expect(configurationService.get).toHaveBeenCalled();
});
it('should call navigate by configuration', () => {
component.evaluateNavigationByConfiguration();
component._evaluateNavigationByConfiguration();
expect(component.navigateByConfiguration).toHaveBeenCalledWith(configurationResource);
expect(component._navigateByConfiguration).toHaveBeenCalledWith(configurationResource);
});
it('should NOT call navigate by configuration if resource is loading', () => {
configurationService.get.mockReturnValue(of(createEmptyStateResource<ConfigurationResource>(true)));
component.evaluateNavigationByConfiguration();
component._evaluateNavigationByConfiguration();
expect(component.navigateByConfiguration).not.toHaveBeenCalled();
expect(component._navigateByConfiguration).not.toHaveBeenCalled();
});
});
describe('navigate by configuration', () => {
beforeEach(() => {
component.unsubscribe = jest.fn();
component._unsubscribe = jest.fn();
});
it('should navigate to postfach if settings link exists', () => {
component.navigateByConfiguration(createConfigurationResource([ConfigurationLinkRel.SETTING]));
component._navigateByConfiguration(createConfigurationResource([ConfigurationLinkRel.SETTING]));
expect(router.navigate).toHaveBeenCalledWith(['/postfach']);
});
it('should navigate to statistik if aggregation mapping link exists', () => {
component.navigateByConfiguration(createConfigurationResource([ConfigurationLinkRel.AGGREGATION_MAPPINGS]));
component._navigateByConfiguration(createConfigurationResource([ConfigurationLinkRel.AGGREGATION_MAPPINGS]));
expect(router.navigate).toHaveBeenCalledWith(['/statistik']);
});
it('should navigate to unavailable page if no link exists', () => {
component.navigateByConfiguration(createConfigurationResource());
component._navigateByConfiguration(createConfigurationResource());
expect(router.navigate).toHaveBeenCalledWith(['/unavailable']);
});
it('should call unsubscribe', () => {
component.navigateByConfiguration(createConfigurationResource());
component._navigateByConfiguration(createConfigurationResource());
expect(component.unsubscribe).toHaveBeenCalled();
expect(component._unsubscribe).toHaveBeenCalled();
});
});
describe('navigate by api root', () => {
beforeEach(() => {
component.unsubscribe = jest.fn();
component._unsubscribe = jest.fn();
});
it('should navigate to benutzer und rollen if users link exists', () => {
const apiRootResource: ApiRootResource = createApiRootResource([ApiRootLinkRel.USERS]);
component.navigateByApiRoot(apiRootResource);
component._navigateByApiRoot(apiRootResource);
expect(router.navigate).toHaveBeenCalledWith([`/${ROUTES.BENUTZER}`]);
});
it('should navigate to unavailable page if no link exists', () => {
component.navigateByApiRoot(createApiRootResource());
component._navigateByApiRoot(createApiRootResource());
expect(router.navigate).toHaveBeenCalledWith([`/${ROUTES.UNAVAILABLE}`]);
});
it('should call unsubscribe', () => {
component.navigateByApiRoot(createApiRootResource());
component._navigateByApiRoot(createApiRootResource());
expect(component.unsubscribe).toHaveBeenCalled();
expect(component._unsubscribe).toHaveBeenCalled();
});
});
......@@ -314,7 +345,7 @@ describe('AppComponent', () => {
component.apiRootSubscription = <any>mock(Subscription);
component.apiRootSubscription.unsubscribe = jest.fn();
component.unsubscribe();
component._unsubscribe();
expect(component.apiRootSubscription.unsubscribe).toHaveBeenCalled();
});
......@@ -323,7 +354,7 @@ describe('AppComponent', () => {
component.apiRootSubscription = undefined;
const unsubscribeSpy: jest.SpyInstance = jest.spyOn(Subscription.prototype, 'unsubscribe');
component.unsubscribe();
component._unsubscribe();
expect(unsubscribeSpy).not.toHaveBeenCalled();
unsubscribeSpy.mockRestore();
......@@ -335,7 +366,7 @@ describe('AppComponent', () => {
component.configurationSubscription = <any>mock(Subscription);
component.configurationSubscription.unsubscribe = jest.fn();
component.unsubscribe();
component._unsubscribe();
expect(component.configurationSubscription.unsubscribe).toHaveBeenCalled();
});
......@@ -344,7 +375,7 @@ describe('AppComponent', () => {
component.apiRootSubscription = undefined;
const unsubscribeSpy: jest.SpyInstance = jest.spyOn(Subscription.prototype, 'unsubscribe');
component.unsubscribe();
component._unsubscribe();
expect(unsubscribeSpy).not.toHaveBeenCalled();
unsubscribeSpy.mockRestore();
......
......@@ -33,13 +33,7 @@ import { Component, inject, OnInit } from '@angular/core';
import { Router, RouterLink, RouterOutlet } from '@angular/router';
import { AuthenticationService } from '@authentication';
import { hasLink } from '@ngxp/rest';
import {
AdminLogoIconComponent,
NavbarComponent,
NavItemComponent,
OrgaUnitIconComponent,
UsersIconComponent,
} from '@ods/system';
import { AdminLogoIconComponent, NavbarComponent, NavItemComponent, OrgaUnitIconComponent, UsersIconComponent, } from '@ods/system';
import { filter, Observable, Subscription } from 'rxjs';
import { UserProfileButtonContainerComponent } from '../../../../libs/admin/user-profile/src/lib/user-menu/user-profile.button-container.component';
import { UnavailablePageComponent } from '../pages/unavailable/unavailable-page/unavailable-page.component';
......@@ -83,37 +77,49 @@ export class AppComponent implements OnInit {
public readonly routes = ROUTES;
ngOnInit(): void {
this.authenticationService.login().then(() => this.doAfterLoggedIn());
this.authenticationService.login().then(() => this._doAfterLoggedIn());
}
doAfterLoggedIn(): void {
_doAfterLoggedIn(): void {
this.apiRootStateResource$ = this.apiRootService.getApiRoot();
this.keycloakTokenService.registerAccessTokenProvider();
this.evaluateInitialNavigation();
this._evaluateInitialNavigation();
}
evaluateInitialNavigation(): void {
_evaluateInitialNavigation(): void {
if (this.router.url.startsWith('/?state')) {
this._subscribeApiRootForEvaluation();
} else {
this.refreshForGuardEvaluation();
}
}
_subscribeApiRootForEvaluation(): void {
this.apiRootSubscription = this.apiRootStateResource$
.pipe(filter(isLoaded), mapToResource<ApiRootResource>())
.subscribe((apiRootResource: ApiRootResource) => this.evaluateNavigationByApiRoot(apiRootResource));
.subscribe((apiRootResource: ApiRootResource) => this._evaluateNavigationByApiRoot(apiRootResource));
}
private refreshForGuardEvaluation(): void {
this.router.navigate([window.location.pathname]);
}
evaluateNavigationByApiRoot(apiRootResource: ApiRootResource): void {
_evaluateNavigationByApiRoot(apiRootResource: ApiRootResource): void {
if (hasLink(apiRootResource, ApiRootLinkRel.CONFIGURATION)) {
this.evaluateNavigationByConfiguration();
this._evaluateNavigationByConfiguration();
} else {
this.navigateByApiRoot(apiRootResource);
this._navigateByApiRoot(apiRootResource);
}
}
evaluateNavigationByConfiguration(): void {
_evaluateNavigationByConfiguration(): void {
this.configurationSubscription = this.configurationService
.get()
.pipe(filter(isLoaded), mapToResource<ApiRootResource>())
.subscribe((configurationResource: ConfigurationResource) => this.navigateByConfiguration(configurationResource));
.subscribe((configurationResource: ConfigurationResource) => this._navigateByConfiguration(configurationResource));
}
navigateByConfiguration(configurationResource: ConfigurationResource): void {
_navigateByConfiguration(configurationResource: ConfigurationResource): void {
if (hasLink(configurationResource, ConfigurationLinkRel.SETTING)) {
this.navigate(ROUTES.POSTFACH);
} else if (hasLink(configurationResource, ConfigurationLinkRel.AGGREGATION_MAPPINGS)) {
......@@ -121,23 +127,23 @@ export class AppComponent implements OnInit {
} else {
this.navigate(ROUTES.UNAVAILABLE);
}
this.unsubscribe();
this._unsubscribe();
}
navigateByApiRoot(apiRootResource: ApiRootResource): void {
_navigateByApiRoot(apiRootResource: ApiRootResource): void {
if (hasLink(apiRootResource, ApiRootLinkRel.USERS)) {
this.navigate(ROUTES.BENUTZER);
} else {
this.navigate(ROUTES.UNAVAILABLE);
}
this.unsubscribe();
this._unsubscribe();
}
private navigate(routePath: string): void {
this.router.navigate(['/' + routePath]);
}
unsubscribe(): void {
_unsubscribe(): void {
if (isNotUndefined(this.apiRootSubscription)) this.apiRootSubscription.unsubscribe();
if (isNotUndefined(this.configurationSubscription)) this.configurationSubscription.unsubscribe();
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment