From 1d1f4533c5d2ed87958bdedaacbaaaf0b19396a9 Mon Sep 17 00:00:00 2001 From: OZGCloud <ozgcloud@mgm-tp.com> Date: Fri, 4 Nov 2022 13:01:08 +0100 Subject: [PATCH] OZG-1414 OZG-3106 add test for current user --- .../current-user-profile.component.e2e.ts | 14 ++++++ ...user-profile-current-user-icon.e2e-spec.ts | 44 +++++++++++++++++++ .../goofy-e2e/src/page-objects/header.po.ts | 14 +++++- .../header/header.component.html | 4 +- 4 files changed, 73 insertions(+), 3 deletions(-) create mode 100644 goofy-client/apps/goofy-e2e/src/components/user-profile/current-user-profile.component.e2e.ts create mode 100644 goofy-client/apps/goofy-e2e/src/integration/main-tests/user-profile/user-profile-current-user-icon.e2e-spec.ts diff --git a/goofy-client/apps/goofy-e2e/src/components/user-profile/current-user-profile.component.e2e.ts b/goofy-client/apps/goofy-e2e/src/components/user-profile/current-user-profile.component.e2e.ts new file mode 100644 index 0000000000..acea5dec2e --- /dev/null +++ b/goofy-client/apps/goofy-e2e/src/components/user-profile/current-user-profile.component.e2e.ts @@ -0,0 +1,14 @@ +import { UserProfileE2EComponent } from "./user-profile.component.e2e"; + +export class CurrentUserProfileE2EComponent { + + private readonly locatorRoot: string = 'current-user'; + + public getRoot() { + return cy.getTestElement(this.locatorRoot); + } + + public getUserProfile(): UserProfileE2EComponent { + return new UserProfileE2EComponent(this.locatorRoot); + } +} \ No newline at end of file diff --git a/goofy-client/apps/goofy-e2e/src/integration/main-tests/user-profile/user-profile-current-user-icon.e2e-spec.ts b/goofy-client/apps/goofy-e2e/src/integration/main-tests/user-profile/user-profile-current-user-icon.e2e-spec.ts new file mode 100644 index 0000000000..a0d340d4fd --- /dev/null +++ b/goofy-client/apps/goofy-e2e/src/integration/main-tests/user-profile/user-profile-current-user-icon.e2e-spec.ts @@ -0,0 +1,44 @@ +import { CurrentUserProfileE2EComponent } from "apps/goofy-e2e/src/components/user-profile/current-user-profile.component.e2e"; +import { UserE2E } from "apps/goofy-e2e/src/model/user"; +import { HeaderE2EComponent } from "apps/goofy-e2e/src/page-objects/header.po"; +import { MainPage, waitForSpinnerToDisappear } from "apps/goofy-e2e/src/page-objects/main.po"; +import { dropCollections } from "apps/goofy-e2e/src/support/cypress-helper"; +import { exist, haveText } from "apps/goofy-e2e/src/support/cypress.util"; +import { getUserManagerUserSabine, getUserSabine, initUsermanagerUsers, loginAsSabine } from "apps/goofy-e2e/src/support/user-util"; + +describe('Current User Profile', () => { + const mainPage: MainPage = new MainPage(); + + const header: HeaderE2EComponent = mainPage.getHeader(); + const currentUserProfile: CurrentUserProfileE2EComponent = header.getCurrentUserProfile(); + + const userSabine: UserE2E = getUserSabine(); + + describe('for sabine', () => { + + before(() => { + initUsermanagerUsers([getUserManagerUserSabine()]); + + loginAsSabine(); + + waitForSpinnerToDisappear(); + exist(header.getRoot()); + }) + + after(() => { + dropCollections(); + }) + + it('should show current user profile', () => { + exist(currentUserProfile.getRoot()); + }) + + it('should show assigned icon', () => { + exist(currentUserProfile.getUserProfile().getIconContainer().getAssignedIcon()); + }) + + it('should show initials', () => { + haveText(currentUserProfile.getUserProfile().getIconContainer().getAssignedIcon(), userSabine.initials) + }) + }) +}) \ No newline at end of file diff --git a/goofy-client/apps/goofy-e2e/src/page-objects/header.po.ts b/goofy-client/apps/goofy-e2e/src/page-objects/header.po.ts index b2527afde3..869c93eec3 100644 --- a/goofy-client/apps/goofy-e2e/src/page-objects/header.po.ts +++ b/goofy-client/apps/goofy-e2e/src/page-objects/header.po.ts @@ -1,3 +1,4 @@ +import { CurrentUserProfileE2EComponent } from "../components/user-profile/current-user-profile.component.e2e"; import { UserSettingsE2EComponent } from "../components/user-settings/user-settings.component.e2e"; export class HeaderE2EComponent { @@ -5,13 +6,20 @@ export class HeaderE2EComponent { private readonly locatorUserIconButton: string = 'user-icon-button'; private readonly locatorLogoutButton: string = 'logout-button'; private readonly locatorTitle: string = 'title'; + private readonly locatorRoot: string = 'header'; private readonly userSettings: UserSettingsE2EComponent = new UserSettingsE2EComponent(); + private readonly currentUserProfile: CurrentUserProfileE2EComponent = new CurrentUserProfileE2EComponent(); + + public getRoot() { + return cy.getTestElement(this.locatorRoot); + } public getTitle() { return cy.getTestElement(this.locatorTitle); } + //TODO: in CurrentUserProfileE2EComponent verschieben public logout(): void { this.getUserIconButton().click(); this.getLogoutButton().click(); @@ -24,8 +32,12 @@ export class HeaderE2EComponent { private getLogoutButton() { return cy.getTestElement(this.locatorLogoutButton); } - + // public getUserSettings(): UserSettingsE2EComponent { return this.userSettings; } + + public getCurrentUserProfile(): CurrentUserProfileE2EComponent { + return this.currentUserProfile; + } } \ No newline at end of file diff --git a/goofy-client/libs/navigation/src/lib/header-container/header/header.component.html b/goofy-client/libs/navigation/src/lib/header-container/header/header.component.html index 44beeb8de4..d1a44c1627 100644 --- a/goofy-client/libs/navigation/src/lib/header-container/header/header.component.html +++ b/goofy-client/libs/navigation/src/lib/header-container/header/header.component.html @@ -1,4 +1,4 @@ -<header> +<header data-test-id="header"> <div class="left"> <goofy-client-icon-button-with-spinner icon="menu" toolTip="Hauptmenü umschalten" (clickEmitter)="toggleMenuEvent.emit(!this.navigationCollapse)"> </goofy-client-icon-button-with-spinner> @@ -16,7 +16,7 @@ <div class="right"> <goofy-client-user-settings-container data-test-id="user-settings"></goofy-client-user-settings-container> - <goofy-client-user-profile-in-header-container></goofy-client-user-profile-in-header-container> + <goofy-client-user-profile-in-header-container data-test-id="current-user"></goofy-client-user-profile-in-header-container> </div> </header> -- GitLab