Skip to content

Commit

Permalink
Spsh 1089 (#62)
Browse files Browse the repository at this point in the history
* Transition to Rolle anlegen

* Semantics and Transitions on Rolle anlegen

* Transition to administration

* Added the central table

* Test for SP assigment

* RoleManagementView now knows about rows

* Made ComboBox a top level concept

* Renaming to make intention clearer

* Add possibility of local env

* Delete roles created

* MAde an Entrypoint

* Simplified login

* Refactor test to use more local versions of RolleCreationView

* Removed more constant page classes

* Made tests more readable

* Exclude certain architecture relevant classes

* Add assertion to express that roleName is defined

* Changed exclusion path

* Typo

* DBP-952 add license file (#60)

DBP-952 add license file (#60)

* SPSH-1103 fixed profile tests (#61)

* fixed profile tests

* minor changes

* kein 2FA button für Schueler

* fix test

* fixed test Benutzer löschen (#63)

Co-authored-by: Caspar Neumann <146704428+casparneumann-cap@users.noreply.github.com>

* Transition to Rolle anlegen

* Semantics and Transitions on Rolle anlegen

* Transition to administration

* Added the central table

* Test for SP assigment

* RoleManagementView now knows about rows

* Made ComboBox a top level concept

* Renaming to make intention clearer

* Add possibility of local env

* Delete roles created

* MAde an Entrypoint

* Simplified login

* Refactor test to use more local versions of RolleCreationView

* Removed more constant page classes

* Made tests more readable

* Exclude certain architecture relevant classes

* Add assertion to express that roleName is defined

* Changed exclusion path

* Typo

* go to base by default

---------

Co-authored-by: M. Westerholz <37044238+MWesterholz@users.noreply.github.com>
Co-authored-by: Manfred <141728305+jakobmadp@users.noreply.github.com>
Co-authored-by: jakobmadp~ <manfred.jakob@dataport.de>
Co-authored-by: Caspar Neumann <146704428+casparneumann-cap@users.noreply.github.com>
  • Loading branch information
5 people authored Sep 30, 2024
1 parent 4a76966 commit 63aac7a
Show file tree
Hide file tree
Showing 14 changed files with 699 additions and 332 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
node_modules/
/test-results/
/playwright-report/
/playwright/.cache/
/playwright/.cache/
/.env
6 changes: 4 additions & 2 deletions base/api/testHelperRolle.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@ export async function createRolle(page: Page, rollenArt: string, organisationId:
}

export async function addSPToRolle(page: Page, rolleId: string, idSP: string): Promise<void> {
const response = await page.request.post(FRONTEND_URL + `api/rolle/${rolleId}/serviceProviders`, {
const response = await page.request.put(FRONTEND_URL + `api/rolle/${rolleId}/serviceProviders`, {
data: {
"serviceProviderId": idSP
"serviceProviderIds": [
idSP
]
}
});
expect(response.status()).toBe(201);
Expand Down
33 changes: 33 additions & 0 deletions elements/ComboBox.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { type Locator, Page } from "@playwright/test";

export class ComboBox {
constructor(
private readonly page: Page,
private readonly locator: Locator,
) {}

private readonly itemsLocator = this.page.locator(
"div.v-overlay.v-menu div.v-list-item",
);

public async selectByPosition(selection: number[]): Promise<string[]> {
const selectedItems: string[] = [];
await this.locator.click();
const items = this.itemsLocator;
for (const index of selection) {
const item = items.nth(index);
selectedItems.push(await item.locator(".v-list-item-title").innerText());
await item.click();
}
return selectedItems;
}

public async selectByTitle(title: string): Promise<void> {
await this.locator.click();
const item = this.itemsLocator.filter({
has: this.page.getByText(title, { exact: true }),
});
await item.waitFor({ state: "visible" });
await item.click();
}
}
14 changes: 14 additions & 0 deletions pages/FromAnywhere.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { Page } from "@playwright/test";
import { LandingPage } from "./LandingView.page";

function FromAnywhere(page: Page) {
return {
async start(): Promise<LandingPage> {
return page
.goto(process.env.FRONTEND_URL)
.then(() => new LandingPage(page));
},
};
}

export default FromAnywhere;
28 changes: 17 additions & 11 deletions pages/LandingView.page.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
import { type Locator, Page } from '@playwright/test';
import { type Locator, Page } from "@playwright/test";
import { LoginPage } from "./LoginView.page";

export class LandingPage{
readonly page: Page;
readonly text_Willkommen: Locator;
readonly button_Anmelden: Locator;
export class LandingPage {
readonly page: Page;
readonly text_Willkommen: Locator;
readonly button_Anmelden: Locator;

constructor(page){
this.page = page;
this.text_Willkommen = page.getByTestId('landing-headline');
this.button_Anmelden = page.getByTestId('login-button');
}
}
constructor(page) {
this.page = page;
this.text_Willkommen = page.getByTestId("landing-headline");
this.button_Anmelden = page.getByTestId("login-button");
}

public async login(): Promise<LoginPage> {
await this.button_Anmelden.click();
return new LoginPage(this.page);
}
}
97 changes: 52 additions & 45 deletions pages/LoginView.page.ts
Original file line number Diff line number Diff line change
@@ -1,49 +1,56 @@
import { expect, type Locator, Page } from '@playwright/test';
import generator from 'generate-password-ts';
import { expect, type Locator, Page } from "@playwright/test";
import generator from "generate-password-ts";
import { StartPage } from "./StartView.page";

export class LoginPage{
readonly page: Page;
readonly input_username: Locator;
readonly input_password: Locator;
readonly input_NewPassword: Locator;
readonly input_ConfirmPW: Locator;
readonly button_login: Locator;
readonly button_submitPWChange: Locator;
readonly text_h1: Locator;
readonly text_h1_updatePW: Locator;
readonly text_span_inputerror: Locator;
export class LoginPage {
readonly page: Page;
readonly input_username: Locator;
readonly input_password: Locator;
readonly input_NewPassword: Locator;
readonly input_ConfirmPW: Locator;
readonly button_login: Locator;
readonly button_submitPWChange: Locator;
readonly text_h1: Locator;
readonly text_h1_updatePW: Locator;
readonly text_span_inputerror: Locator;

constructor(page){
this.page = page;
this.text_h1 = page.getByTestId('login-page-title');
this.text_h1_updatePW = page.getByTestId('login-page-title')
this.input_username = page.getByTestId('username-input');
this.input_password = page.getByTestId('password-input')
this.input_NewPassword = page.getByTestId('new-password-input');
this.input_ConfirmPW = page.getByTestId('new-password-confirm-input');
this.button_login = page.getByTestId('login-button');
this.button_submitPWChange = page.getByTestId('set-password-button');
this.text_span_inputerror = page.getByText('Ungültiger Benutzername oder Passwort');
}
constructor(page) {
this.page = page;
this.text_h1 = page.getByTestId("login-page-title");
this.text_h1_updatePW = page.getByTestId("login-page-title");
this.input_username = page.getByTestId("username-input");
this.input_password = page.getByTestId("password-input");
this.input_NewPassword = page.getByTestId("new-password-input");
this.input_ConfirmPW = page.getByTestId("new-password-confirm-input");
this.button_login = page.getByTestId("login-button");
this.button_submitPWChange = page.getByTestId("set-password-button");
this.text_span_inputerror = page.getByText(
"Ungültiger Benutzername oder Passwort",
);
}

async login(username, password){
await expect(this.text_h1).toBeVisible();
await this.input_username.click();
await this.input_username.fill(username);
await this.input_password.click();
await this.input_password.fill(password);
await this.button_login.click();
}
async login(
username = process.env.USER,
password = process.env.PW,
): Promise<StartPage> {
await expect(this.text_h1).toBeVisible();
await this.input_username.click();
await this.input_username.fill(username);
await this.input_password.click();
await this.input_password.fill(password);
await this.button_login.click();

async UpdatePW(){
let new_Password = '';
new_Password = generator.generate({ length: 10, numbers: true });
await expect(this.text_h1_updatePW).toBeVisible();
await this.input_NewPassword.click();
await this.input_NewPassword.fill(new_Password);
await this.input_ConfirmPW.click();
await this.input_ConfirmPW.fill(new_Password);
await this.button_submitPWChange.click();
return new_Password;
}
}
return new StartPage(this.page);
}

async UpdatePW() {
const new_Password = generator.generate({ length: 10, numbers: true });
await expect(this.text_h1_updatePW).toBeVisible();
await this.input_NewPassword.click();
await this.input_NewPassword.fill(new_Password);
await this.input_ConfirmPW.click();
await this.input_ConfirmPW.fill(new_Password);
await this.button_submitPWChange.click();
return new_Password;
}
}
112 changes: 75 additions & 37 deletions pages/MenuBar.page.ts
Original file line number Diff line number Diff line change
@@ -1,39 +1,77 @@
import { type Locator, Page } from '@playwright/test';
import { type Locator, Page } from "@playwright/test";
import { RolleCreationViewPage } from "./admin/RolleCreationView.page";
import {RolleManagementViewPage} from "./admin/RolleManagementView.page";

export class MenuPage{
readonly page: Page;
readonly header_label_Navigation: Locator;
readonly button_BackStartpage: Locator;
readonly label_Benutzerverwaltung: Locator;
readonly menueItem_AlleBenutzerAnzeigen: Locator;
readonly menueItem_BenutzerAnlegen: Locator;
readonly label_Klassenverwaltung: Locator;
readonly menueItem_AlleKlassenAnzeigen: Locator;
readonly menueItem_KlasseAnlegen: Locator;
readonly label_Rollenverwaltung: Locator;
readonly menueItem_AlleRollenAnzeigen: Locator;
readonly menueItem_RolleAnlegen: Locator;
readonly label_Schulverwaltung: Locator;
readonly menueItem_AlleSchulenAnzeigen: Locator;
readonly menueItem_SchuleAnlegen: Locator;
readonly label_Schultraegerverwaltung: Locator;
export class MenuPage {
readonly page: Page;
readonly header_label_Navigation: Locator;
readonly button_BackStartpage: Locator;
readonly label_Benutzerverwaltung: Locator;
readonly menueItem_AlleBenutzerAnzeigen: Locator;
readonly menueItem_BenutzerAnlegen: Locator;
readonly label_Klassenverwaltung: Locator;
readonly menueItem_AlleKlassenAnzeigen: Locator;
readonly menueItem_KlasseAnlegen: Locator;
readonly label_Rollenverwaltung: Locator;
readonly menueItem_AlleRollenAnzeigen: Locator;
readonly menueItem_RolleAnlegen: Locator;
readonly label_Schulverwaltung: Locator;
readonly menueItem_AlleSchulenAnzeigen: Locator;
readonly menueItem_SchuleAnlegen: Locator;
readonly label_Schultraegerverwaltung: Locator;

constructor(page){
this.page = page;
this.header_label_Navigation = page.locator('[data-testid="menu-bar-title"] .v-list-item-title');
this.button_BackStartpage = page.getByTestId('back-to-start-link');
this.label_Benutzerverwaltung = page.locator('[data-testid="person-management-title"] .v-list-item-title');
this.menueItem_AlleBenutzerAnzeigen = page.getByTestId('person-management-menu-item');
this.menueItem_BenutzerAnlegen = page.getByTestId('person-creation-menu-item');
this.label_Klassenverwaltung = page.locator('[data-testid="klasse-management-title"] .v-list-item-title');
this.menueItem_AlleKlassenAnzeigen = page.getByTestId('klassen-management-menu-item');
this.menueItem_KlasseAnlegen = page.getByTestId('klasse-creation-menu-item');
this.label_Rollenverwaltung = page.locator('[data-testid="rolle-management-title"] .v-list-item-title');
this.menueItem_AlleRollenAnzeigen = page.locator('[data-testid="rolle-management-menu-item"] .v-list-item-title');
this.menueItem_RolleAnlegen = page.getByTestId('rolle-creation-menu-item');
this.label_Schulverwaltung = page.locator('[data-testid="schule-management-title"] .v-list-item-title');
this.menueItem_AlleSchulenAnzeigen = page.locator('[data-testid="schule-management-menu-item"] .v-list-item-title');
this.menueItem_SchuleAnlegen = page.getByTestId('schule-creation-menu-item');
this.label_Schultraegerverwaltung = page.locator('[data-testid="schultraeger-management-title"] .v-list-item-title');
}
}
constructor(page) {
this.page = page;
this.header_label_Navigation = page.locator(
'[data-testid="menu-bar-title"] .v-list-item-title',
);
this.button_BackStartpage = page.getByTestId("back-to-start-link");
this.label_Benutzerverwaltung = page.locator(
'[data-testid="person-management-title"] .v-list-item-title',
);
this.menueItem_AlleBenutzerAnzeigen = page.getByTestId(
"person-management-menu-item",
);
this.menueItem_BenutzerAnlegen = page.getByTestId(
"person-creation-menu-item",
);
this.label_Klassenverwaltung = page.locator(
'[data-testid="klasse-management-title"] .v-list-item-title',
);
this.menueItem_AlleKlassenAnzeigen = page.getByTestId(
"klassen-management-menu-item",
);
this.menueItem_KlasseAnlegen = page.getByTestId(
"klasse-creation-menu-item",
);
this.label_Rollenverwaltung = page.locator(
'[data-testid="rolle-management-title"] .v-list-item-title',
);
this.menueItem_AlleRollenAnzeigen = page.locator(
'[data-testid="rolle-management-menu-item"] .v-list-item-title',
);
this.menueItem_RolleAnlegen = page.getByTestId("rolle-creation-menu-item");
this.label_Schulverwaltung = page.locator(
'[data-testid="schule-management-title"] .v-list-item-title',
);
this.menueItem_AlleSchulenAnzeigen = page.locator(
'[data-testid="schule-management-menu-item"] .v-list-item-title',
);
this.menueItem_SchuleAnlegen = page.getByTestId(
"schule-creation-menu-item",
);
this.label_Schultraegerverwaltung = page.locator(
'[data-testid="schultraeger-management-title"] .v-list-item-title',
);
}

public async rolleAnlegen(): Promise<RolleCreationViewPage> {
await this.menueItem_RolleAnlegen.click();
return new RolleCreationViewPage(this.page);
}

public async alleRollenAnzeigen(): Promise<RolleManagementViewPage> {
await this.menueItem_AlleRollenAnzeigen.click();
return new RolleManagementViewPage(this.page);
}
}
48 changes: 33 additions & 15 deletions pages/StartView.page.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,35 @@
import { type Locator, Page } from '@playwright/test';
import { type Locator, Page } from "@playwright/test";
import { MenuPage } from "./MenuBar.page";
import { LandingPage } from "./LandingView.page";

export class StartPage{
readonly page: Page;
readonly text_h2_Ueberschrift: Locator;
readonly card_item_email: Locator;
readonly card_item_itslearning: Locator;
readonly card_item_schulportal_administration: Locator;
export class StartPage {
readonly page: Page;
readonly text_h2_Ueberschrift: Locator;
readonly card_item_email: Locator;
readonly card_item_itslearning: Locator;
readonly card_item_schulportal_administration: Locator;

constructor(page){
this.page = page;
this.text_h2_Ueberschrift = page.getByTestId('all-service-provider-title');
this.card_item_email = page.locator('[href="https://de.wikipedia.org/wiki/E-Mail"]').first();
this.card_item_itslearning = page.locator('[href="https://sh-staging.itslintegrations.com/"]');
this.card_item_schulportal_administration = page.getByText('Schulportal-Administration');
}
}
constructor(page) {
this.page = page;
this.text_h2_Ueberschrift = page.getByTestId("all-service-provider-title");
this.card_item_email = page
.locator('[href="https://de.wikipedia.org/wiki/E-Mail"]')
.first();
this.card_item_itslearning = page.locator(
'[href="https://sh-staging.itslintegrations.com/"]',
);
this.card_item_schulportal_administration = page.getByText(
"Schulportal-Administration",
);
}

public async administration(): Promise<MenuPage> {
await this.card_item_schulportal_administration.click();
return new MenuPage(this.page);
}

public async start(): Promise<LandingPage> {
await this.page.goto(process.env.FRONTEND_URL || "/");
return new LandingPage(this.page);
}
}
Loading

0 comments on commit 63aac7a

Please sign in to comment.