Skip to content

Commit

Permalink
Merge branch 'main' into SPSH-1002
Browse files Browse the repository at this point in the history
  • Loading branch information
phaelcg committed Nov 18, 2024
2 parents adc43b1 + 228ffc9 commit fa452ba
Show file tree
Hide file tree
Showing 21 changed files with 336 additions and 147 deletions.
1 change: 0 additions & 1 deletion base/api/testHelperPerson.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ export async function createTeacherAndLogin(page) {
await login.UpdatePW();
}


export async function lockPerson(page: Page, personId: string, organisationId: string): Promise<void> {
const response = await page.request.put(FRONTEND_URL + `api/personen/${personId}/lock-user`, {
data: {
Expand Down
2 changes: 2 additions & 0 deletions base/organisation.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export const testschule = "Testschule Schulportal";
export const testschule665 = "Testschule-PW665";
1 change: 1 addition & 0 deletions base/rollentypen.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const typelehrer = "LEHR";
1 change: 1 addition & 0 deletions base/sp.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const email = "E-Mail";
15 changes: 15 additions & 0 deletions base/testHelperGenerateTestdataNames.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { faker } from "@faker-js/faker/locale/de";

export async function generateLehrerVorname(){
return "TAuto-PW-V-" + faker.person.firstName();
}

export async function generateLehrerNachname(){
return "TAuto-PW-N-" + faker.person.lastName();
}

export async function generateRolleName(){
return "TAuto-PW-R-" + faker.lorem.word({ length: { min: 8, max: 12 }});
}


13 changes: 13 additions & 0 deletions base/testHelperUtils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import moment from 'moment';

export async function gotoTargetURL(page, target: string) {
await page.goto(target);
}

export async function generateDateToday() {
return moment().format('DD.MM.YYYY');
}

export async function generateDateFuture(days: number, months: number) {
return moment().add({ days: days, months: months }).format('DD.MM.YYYY');
}
11 changes: 10 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
"@fast-csv/format": "^4.3.5",
"@fast-csv/parse": "^4.3.6",
"fast-csv": "^4.3.6",
"generate-password-ts": "^1.6.5"
"generate-password-ts": "^1.6.5",
"moment": "^2.30.1"
},
"name": "schulportal-testautomatisierung",
"description": "",
Expand Down
2 changes: 1 addition & 1 deletion pages/FromAnywhere.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ function FromAnywhere(page: Page) {
return {
async start(): Promise<LandingPage> {
return page
.goto(process.env.FRONTEND_URL)
.goto('/')
.then(() => new LandingPage(page));
},
};
Expand Down
2 changes: 1 addition & 1 deletion pages/LoginView.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export class LoginPage {
}

async UpdatePW() {
const new_Password = generator.generate({ length: 10, numbers: true });
const new_Password = generator.generate({ length: 8, numbers: true }) + '1Aa!';
await expect(this.text_h1_updatePW).toBeVisible();
await this.input_NewPassword.click();
await this.input_NewPassword.fill(new_Password);
Expand Down
2 changes: 1 addition & 1 deletion pages/admin/KlasseCreationView.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export class KlasseCreationViewPage{
this.button_Schliessen = page.getByTestId('close-layout-card-button');
this.combobox_Schulstrukturknoten = page.getByTestId('schule-select').locator('.v-input__control');
this.input_Klassenname = page.getByTestId('klassenname-input').locator('input');
this.button_KlasseAnlegen = page.getByTestId('klasse-form-create-button');
this.button_KlasseAnlegen = page.getByTestId('klasse-form-submit-button');
// Bestätigungsseite Klasse
this.text_success = page.getByTestId('klasse-success-text');
this.icon_success = page.locator('.mdi-check-circle');
Expand Down
2 changes: 1 addition & 1 deletion pages/admin/PersonCreationView.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export class PersonCreationViewPage{
this.Input_Kopersnr = page.getByTestId('kopersnr-input').locator('.v-field__input');
this.combobox_Schulstrukturknoten = page.getByTestId('organisation-select').locator('.v-field__input');
this.combobox_Klasse = page.getByTestId('klasse-select').locator('.v-field__input');
this.button_PersonAnlegen = page.getByTestId('person-creation-form-create-button');
this.button_PersonAnlegen = page.getByTestId('person-creation-form-submit-button');
// Bestätigungsseite Klasse
this.text_success = page.getByTestId('person-success-text');
this.icon_success = page.locator('.mdi-check-circle');
Expand Down
59 changes: 58 additions & 1 deletion pages/admin/PersonDetailsView.page.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { type Locator, Page } from '@playwright/test';
import { type Locator, Page, expect } from '@playwright/test';

export class PersonDetailsViewPage{
readonly page: Page;
Expand All @@ -20,12 +20,24 @@ export class PersonDetailsViewPage{
readonly button_editSchulzuordnung: Locator;
readonly button_addSchulzuordnung: Locator;
readonly combobox_organisation: Locator;
readonly combobox_organisationDialogBenutzerSperren: Locator;
readonly combobox_rolle: Locator;
readonly input_kopersNr: Locator;
readonly button_submitAddSchulzuordnung: Locator;
readonly button_confirmAddSchulzuordnung: Locator;
readonly button_saveAssignmentChanges: Locator;
readonly button_closeSaveAssignmentChanges: Locator;
readonly button_lockPerson: Locator;
readonly button_lockPersonConfirm: Locator;
readonly text_h2_dialogBenutzerSperren: Locator;
readonly text_infoLockedUser: Locator;
readonly icon_lockedUser: Locator;
readonly text_lockedUser: Locator;
readonly text_unlockedUser: Locator;
readonly input_befristungSperre: Locator;
readonly radio_button_befristet: Locator;
readonly text_sperrdatumAb: Locator;
readonly text_sperrdatumBis: Locator;

constructor(page){
this.page = page;
Expand All @@ -46,12 +58,57 @@ export class PersonDetailsViewPage{
// Schulzuordnungen
this.button_editSchulzuordnung = page.locator('div').filter({ hasText: /^Schulzuordnung\(en\)Bearbeiten$/ }).getByTestId('zuordnung-edit-button');
this.button_addSchulzuordnung = page.getByTestId('zuordnung-create-button');
this.combobox_organisationDialogBenutzerSperren = page.getByTestId('person-lock-card').locator('.v-field__input');
this.combobox_organisation = page.getByTestId('organisation-select').locator('.v-field__input');
this.combobox_rolle = page.getByTestId('rolle-select').locator('.v-field__input');
this.input_kopersNr = page.getByTestId('kopersnr-input').locator('.v-field__input');
this.button_submitAddSchulzuordnung = page.getByTestId('zuordnung-creation-submit-button');
this.button_confirmAddSchulzuordnung = page.getByRole('button', { name: 'Ja' });
this.button_saveAssignmentChanges = page.getByTestId('zuordnung-changes-save');
this.button_closeSaveAssignmentChanges = page.getByRole('dialog').getByRole('button', { name: 'Schließen' });
this.button_lockPerson = page.getByTestId('open-lock-dialog-button');
this.button_lockPersonConfirm = page.getByTestId('lock-user-button');
this.text_h2_dialogBenutzerSperren = page.getByTestId('person-lock-card').getByTestId('layout-card-headline');
this.text_infoLockedUser = page.getByTestId('lock-user-info-text');
this.icon_lockedUser = page.getByTestId('person-lock-info').locator('i');
this.text_lockedUser = page.getByText('Dieser Benutzer ist gesperrt.');
this.text_unlockedUser = page.getByText('Dieser Benutzer ist aktiv.');
this.input_befristungSperre = page.getByTestId('befristung-input').getByPlaceholder('TT.MM.JJJJ');
this.radio_button_befristet = page.getByTestId('befristet-radio-button').getByLabel('Befristet');
this.text_sperrdatumAb = page.getByTestId('lock-info-1-attribute');
this.text_sperrdatumBis = page.getByTestId('lock-info-2-attribute');
}

public async lockUserWithoutDate() {
await this.button_lockPerson.click();
await expect(this.text_h2_dialogBenutzerSperren).toHaveText('Benutzer sperren');
await expect(this.combobox_organisationDialogBenutzerSperren).toHaveText('Land Schleswig-Holstein');
await expect(this.text_infoLockedUser).toHaveText('Für die Dauer der Sperre hat der Benutzer keinen Zugriff mehr auf das Schulportal SH und die daran angeschlossenen Dienste.');
await expect(this.input_befristungSperre).toBeHidden();
await this.button_lockPersonConfirm.click()
}

public async lockUserWithDate(lockDateTo) {
await this.button_lockPerson.click();
await expect(this.text_h2_dialogBenutzerSperren).toHaveText('Benutzer sperren');
await expect(this.combobox_organisationDialogBenutzerSperren).toHaveText('Land Schleswig-Holstein');
await expect(this.text_infoLockedUser).toHaveText('Für die Dauer der Sperre hat der Benutzer keinen Zugriff mehr auf das Schulportal SH und die daran angeschlossenen Dienste.');
await this.radio_button_befristet.click();
await expect(this.input_befristungSperre).toBeVisible();
await this.input_befristungSperre.fill(lockDateTo);
await this.button_lockPersonConfirm.click()
}

public async checkUserIslocked() {
await expect(this.icon_lockedUser).toBeVisible();
await expect(this.text_lockedUser).toBeVisible();
}

public async checkLockDateFrom(lockDateFrom: string) {
await expect(this.text_sperrdatumAb).toHaveText(lockDateFrom);
}

public async checkLockDateTo(lockDateTo: string) {
await expect(this.text_sperrdatumBis).toHaveText(lockDateTo);
}
}
16 changes: 14 additions & 2 deletions pages/admin/PersonManagementView.page.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { type Locator, Page } from '@playwright/test';
import { type Locator, Page, expect } from '@playwright/test';
import {PersonDetailsViewPage} from "./PersonDetailsView.page.js";

export class PersonManagementViewPage{
readonly page: Page;
Expand All @@ -18,7 +19,7 @@ export class PersonManagementViewPage{
readonly comboboxMenuIcon_Klasse: Locator;
readonly comboboxMenuIcon_Status: Locator;

constructor(page){
constructor(page: Page){
this.page = page;
this.text_h1_Administrationsbereich = page.getByTestId('admin-headline');
this.text_h2_Benutzerverwaltung = page.getByTestId('layout-card-headline');
Expand All @@ -36,4 +37,15 @@ export class PersonManagementViewPage{
this.comboboxMenuIcon_Klasse = page.locator('[data-testid="klasse-select"] .mdi-menu-down');
this.comboboxMenuIcon_Status = page.locator('[data-testid="status-select"] .mdi-menu-down');
}

public async searchBySuchfeld(name: string) {
await this.input_Suchfeld.fill(name);
await this.button_Suchen.click();
await expect(this.comboboxMenuIcon_Status).toBeVisible();
}

public async openGesamtuebersichtPerson(page: Page, name: string): Promise<PersonDetailsViewPage> {
await page.getByRole("cell", { name: name, exact: true }).click();
return new PersonDetailsViewPage(page);
}
}
2 changes: 1 addition & 1 deletion pages/admin/RolleCreationView.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export class RolleCreationViewPage {
this.input_Rollenname = page
.getByTestId("rollenname-input")
.locator("input");
this.button_RolleAnlegen = page.getByTestId("rolle-form-create-button");
this.button_RolleAnlegen = page.getByTestId("rolle-form-submit-button");
this.button_WeitereRolleAnlegen = page.getByTestId(
"create-another-rolle-button",
);
Expand Down
2 changes: 1 addition & 1 deletion pages/admin/SchuleCreationView.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export class SchuleCreationViewPage{
this.radio_button_Public_Schule = page.getByTestId('schulform-radio-button-0');
this.input_Dienststellennummer = page.getByTestId('dienststellennummer-input').locator('input');
this.input_Schulname = page.getByTestId('schulname-input').locator('input');
this.button_SchuleAnlegen = page.getByTestId('schule-creation-form-create-button');
this.button_SchuleAnlegen = page.getByTestId('schule-creation-form-submit-button');
this.button_WeitereSchuleAnlegen = page.getByTestId('create-another-schule-button');
// Bestätigungsseite
this.button_ZurueckErgebnisliste = page.getByTestId('back-to-list-button');
Expand Down
3 changes: 3 additions & 0 deletions playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { defineConfig, devices } from "@playwright/test";
import dotenv from "dotenv";
import * as path from "node:path";

const FRONTEND_URL = process.env.FRONTEND_URL || "";

dotenv.config({
path: "./.env.dev",
});
Expand All @@ -23,6 +25,7 @@ export default defineConfig({
locale: "de-DE",
timezoneId: "Europe/Brussels",
screenshot: "only-on-failure",
baseURL: FRONTEND_URL,
},

projects: [
Expand Down
90 changes: 56 additions & 34 deletions tests/Person.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ test.describe(`Testfälle für die Administration von Personen": Umgebung: ${pro
const landing = new LandingPage(page);
const startseite = new StartPage(page);
const login = new LoginPage(page);
await page.goto(FRONTEND_URL);
await page.goto('/');
await landing.button_Anmelden.click();
await login.login(ADMIN, PW);
await expect(startseite.text_h2_Ueberschrift).toBeVisible();
Expand Down Expand Up @@ -211,39 +211,61 @@ test.describe(`Testfälle für die Administration von Personen": Umgebung: ${pro
});
});

test("Einen Benutzer mit der Rolle Schuladmin anlegen als Landesadmin", {tag: [LONG, SHORT, STAGE]}, async ({ page }) => {
const startseite = new StartPage(page);
const menue = new MenuPage(page);
const personCreationView = new PersonCreationViewPage(page);

const vorname = "TAuto-PW-V-" + faker.person.firstName();
const nachname = "TAuto-PW-N-" + faker.person.lastName();
const schulstrukturknoten = "(Testschule Schulportal)";

await test.step(`Dialog Person anlegen öffnen`, async () => {
await startseite.card_item_schulportal_administration.click();
await menue.menueItem_BenutzerAnlegen.click();
await expect(personCreationView.text_h2_PersonAnlegen).toHaveText("Neuen Benutzer hinzufügen");
});

await test.step(`Benutzer anlegen`, async () => {
await personCreationView.combobox_Schulstrukturknoten.click();
await page.getByText(schulstrukturknoten).click();
await personCreationView.combobox_Rolle.click();
await page.getByText(schuladminOeffentlichRolle, { exact: true }).click();
await personCreationView.Input_Vorname.fill(vorname);
await personCreationView.Input_Nachname.fill(nachname);
await personCreationView.button_PersonAnlegen.click();
});

await test.step(`Prüfen dass der Benutzer mit der Rolle Landesadmin angelegt wurde`, async () => {
await expect(personCreationView.text_success).toBeVisible();
// Benutzer wird im afterEach-Block gelöscht
// gesteuert wird die Löschung über die Variable username
username.push(await personCreationView.data_Benutzername.innerText());
await expect(personCreationView.data_Rolle).toHaveText(schuladminOeffentlichRolle);
});
});
test("Einen Benutzer mit der Rolle Schuladmin anlegen als Landesadmin und anschließend mit diesem Benutzer anmelden und einen weiteren Benutzer anlegen",
{ tag: [LONG, SHORT, STAGE] }, async ({ page }) => {
const startseite = new StartPage(page);
const menue = new MenuPage(page);
const personCreationView = new PersonCreationViewPage(page);
const login = new LoginPage(page);
const header = new HeaderPage(page);
const landing = new LandingPage(page);

const vorname = "TAuto-PW-V-" + faker.person.firstName();
const nachname = "TAuto-PW-N-" + faker.person.lastName();
const schulstrukturknoten = "Testschule Schulportal";
const rolle = "Lehrkraft";
let userInfo: UserInfo;

// Step 1: Create a Schuladmin as Landesadmin and login as the newly created Schuladmin user
await test.step(`Schuladmin anlegen und mit diesem anmelden`, async () => {
const idSP = await getSPId(page, 'Schulportal-Administration');
userInfo = await createRolleAndPersonWithUserContext(page, schulstrukturknoten, 'LEIT', nachname, vorname, idSP, 'TAuto-PW-E-RolleLEIT');
await addSystemrechtToRolle(page, userInfo.rolleId, 'PERSONEN_VERWALTEN');
await addSystemrechtToRolle(page, userInfo.rolleId, 'PERSONEN_ANLEGEN');

username.push(userInfo.username);
roleId.push(userInfo.rolleId);

await header.logout();
await landing.button_Anmelden.click();
await login.login(userInfo.username, userInfo.password);
userInfo.password = await login.UpdatePW();
await expect(startseite.text_h2_Ueberschrift).toBeVisible();
});

// Step 2: Create another user as Schuladmin
await test.step(`Schuladmin anlegen und mit diesem anmelden`, async () => {
const newVorname = "TAuto-PW-V-" + faker.person.firstName();
const newNachname = "TAuto-PW-N-" + faker.person.lastName();
const newKopersnr = faker.string.numeric(7);

await startseite.card_item_schulportal_administration.click();
await menue.menueItem_BenutzerAnlegen.click();
await expect(personCreationView.text_h2_PersonAnlegen).toHaveText("Neuen Benutzer hinzufügen");

await personCreationView.combobox_Rolle.click();
await page.getByText(rolle, { exact: true }).click();
await personCreationView.Input_Vorname.fill(newVorname);
await personCreationView.Input_Nachname.fill(newNachname);
await personCreationView.Input_Kopersnr.fill(newKopersnr);
await personCreationView.button_PersonAnlegen.click();
await expect(personCreationView.text_success).toBeVisible();

// Save the username for cleanup
username.push(await personCreationView.data_Benutzername.innerText());
});
}
);

test("Einen Benutzer mit der Rolle Schueler anlegen als Landesadmin", {tag: [LONG, SHORT, STAGE]}, async ({ page }) => {
const startseite = new StartPage(page);
Expand Down
Loading

0 comments on commit fa452ba

Please sign in to comment.