From 379904123d9667a7b1eb2854ae26acf7626edef5 Mon Sep 17 00:00:00 2001 From: OZGCloud <ozgcloud@mgm-tp.com> Date: Fri, 4 Nov 2022 13:15:07 +0100 Subject: [PATCH] OZG-1414 OZG-3106 move actions to current user component --- .../current-user-profile.component.e2e.ts | 18 +++++++++++++++++- .../main-tests/app/login-logout.e2e-spec.ts | 15 +++++++++------ goofy-client/apps/goofy-e2e/src/model/app.ts | 3 +++ .../goofy-e2e/src/page-objects/header.po.ts | 16 ---------------- .../apps/goofy-e2e/src/support/app-util.ts | 8 ++++++++ 5 files changed, 37 insertions(+), 23 deletions(-) create mode 100644 goofy-client/apps/goofy-e2e/src/model/app.ts create mode 100644 goofy-client/apps/goofy-e2e/src/support/app-util.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 index acea5dec2e..f857600472 100644 --- 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 @@ -1,7 +1,10 @@ -import { UserProfileE2EComponent } from "./user-profile.component.e2e"; +import { UserProfileE2EComponent } from './user-profile.component.e2e'; export class CurrentUserProfileE2EComponent { + private readonly locatorUserIconButton: string = 'user-icon-button'; + private readonly locatorLogoutButton: string = 'logout-button'; + private readonly locatorRoot: string = 'current-user'; public getRoot() { @@ -11,4 +14,17 @@ export class CurrentUserProfileE2EComponent { public getUserProfile(): UserProfileE2EComponent { return new UserProfileE2EComponent(this.locatorRoot); } + + public logout(): void { + this.getUserIconButton().click(); + this.getLogoutButton().click(); + } + + private getUserIconButton() { + return cy.getTestElement(this.locatorUserIconButton); + } + + private getLogoutButton() { + return cy.getTestElement(this.locatorLogoutButton); + } } \ No newline at end of file diff --git a/goofy-client/apps/goofy-e2e/src/integration/main-tests/app/login-logout.e2e-spec.ts b/goofy-client/apps/goofy-e2e/src/integration/main-tests/app/login-logout.e2e-spec.ts index f3cca66e65..0223e6b2cf 100644 --- a/goofy-client/apps/goofy-e2e/src/integration/main-tests/app/login-logout.e2e-spec.ts +++ b/goofy-client/apps/goofy-e2e/src/integration/main-tests/app/login-logout.e2e-spec.ts @@ -1,13 +1,16 @@ +import { App } from 'apps/goofy-e2e/src/model/app'; +import { getApp } from 'apps/goofy-e2e/src/support/app-util'; import { UserE2E } from '../../../model/user'; import { HeaderE2EComponent } from '../../../page-objects/header.po'; import { MainPage } from '../../../page-objects/main.po'; import { exist, haveText } from '../../../support/cypress.util'; import { getUserSabine } from '../../../support/user-util'; -const mainFixture = require('../../../fixtures/main.json'); -const user: UserE2E = getUserSabine(); - describe('Login and Logout', () => { + + const app: App = getApp(); + const user: UserE2E = getUserSabine(); + const mainPage: MainPage = new MainPage(); const header: HeaderE2EComponent = mainPage.getHeader(); @@ -24,11 +27,11 @@ describe('Login and Logout', () => { }) it('should display Goofy', () => { - haveText(header.getTitle(), mainFixture.title); + haveText(header.getTitle(), app.title); }) - it.skip('FIXME(OZG-2950 UserManager) should logout', () => { - header.logout(); + it('should logout', () => { + header.getCurrentUserProfile().logout(); exist(cy.get('#kc-login')); }) diff --git a/goofy-client/apps/goofy-e2e/src/model/app.ts b/goofy-client/apps/goofy-e2e/src/model/app.ts new file mode 100644 index 0000000000..5e0f1e90ea --- /dev/null +++ b/goofy-client/apps/goofy-e2e/src/model/app.ts @@ -0,0 +1,3 @@ +export class App { + title: string +} \ 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 869c93eec3..96a927b8f6 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 @@ -3,8 +3,6 @@ import { UserSettingsE2EComponent } from "../components/user-settings/user-setti 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'; @@ -19,20 +17,6 @@ export class HeaderE2EComponent { return cy.getTestElement(this.locatorTitle); } - //TODO: in CurrentUserProfileE2EComponent verschieben - public logout(): void { - this.getUserIconButton().click(); - this.getLogoutButton().click(); - } - - private getUserIconButton() { - return cy.getTestElement(this.locatorUserIconButton); - } - - private getLogoutButton() { - return cy.getTestElement(this.locatorLogoutButton); - } - // public getUserSettings(): UserSettingsE2EComponent { return this.userSettings; } diff --git a/goofy-client/apps/goofy-e2e/src/support/app-util.ts b/goofy-client/apps/goofy-e2e/src/support/app-util.ts new file mode 100644 index 0000000000..9875845269 --- /dev/null +++ b/goofy-client/apps/goofy-e2e/src/support/app-util.ts @@ -0,0 +1,8 @@ +import { App } from '../model/app'; + +//TODO main.json in app.json umbenennen +const appFixture: App = require('../fixtures/main.json'); + +export function getApp(): App { + return appFixture; +} \ No newline at end of file -- GitLab