Skip to content

Commit

Permalink
Merge branch 'main' into SPSH-967
Browse files Browse the repository at this point in the history
  • Loading branch information
phaelcg committed Nov 21, 2024
2 parents 437d261 + 8d00ca6 commit 2a082bd
Show file tree
Hide file tree
Showing 15 changed files with 147 additions and 81 deletions.
9 changes: 7 additions & 2 deletions base/api/testHelperPerson.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { HeaderPage } from '../../pages/Header.page';
import { LoginPage } from '../../pages/LoginView.page';
import { faker } from '@faker-js/faker';
import { lehrkraftOeffentlichRolle } from '../roles';
import { generateLehrerNachname, generateLehrerVorname } from "../testHelperGenerateTestdataNames";

const FRONTEND_URL: string | undefined = process.env.FRONTEND_URL || "";

Expand Down Expand Up @@ -43,6 +44,8 @@ export async function createPersonWithUserContext(page: Page, organisationName:
// API-Calls machen und Benutzer mit Kontext anlegen
const organisationId: string = await getOrganisationId(page, organisationName);
const rolleId: string = await getRolleId(page, rolleName);
console.log('rolleName: ' + rolleName);
console.log('rolleId: ' + rolleId);
const userInfo: UserInfo = await createPerson(page, familienname, vorname, organisationId, rolleId, koPersNr);
return userInfo;
}
Expand Down Expand Up @@ -95,8 +98,8 @@ export async function getPersonId(page: Page, Benutzername: string): Promise<str
export async function createTeacherAndLogin(page) {
const header = new HeaderPage(page);
const login: LoginPage = new LoginPage(page);
const vorname = "TAuto-PW-V-" + faker.person.firstName();
const nachname = "TAuto-PW-N-" + faker.person.lastName();
const vorname = await generateLehrerVorname();
const nachname = await generateLehrerNachname();
const organisation = 'Testschule Schulportal';
const kopersNr = '0815' + faker.string.numeric({ length: 3 });

Expand All @@ -105,6 +108,8 @@ export async function createTeacherAndLogin(page) {
await header.button_login.click();
await login.login(userInfo.username, userInfo.password);
await login.UpdatePW();
await expect(header.icon_myProfil).toBeVisible();
await expect(header.icon_logout).toBeVisible();
}

export async function lockPerson(page: Page, personId: string, organisationId: string): Promise<void> {
Expand Down
6 changes: 5 additions & 1 deletion base/api/testHelperServiceprovider.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ import { Page, expect } from '@playwright/test';
const FRONTEND_URL: string | undefined = process.env.FRONTEND_URL || "";

export async function getSPId(page: Page, nameSP: string): Promise<string> {
const response = await page.request.get(FRONTEND_URL + `api/provider/all`, {});
let response = await page.request.get(FRONTEND_URL + `api/provider/all`, {});
if(response.status() != 200) {
console.log(response);
response = await page.request.get(FRONTEND_URL + `api/provider/all`, {});
}
expect(response.status()).toBe(200);
const json = await response.json();
expect(response.status()).toBe(200);
Expand Down
13 changes: 6 additions & 7 deletions base/testHelperGenerateTestdataNames.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import { faker } from "@faker-js/faker/locale/de";
import { generateRandomString, CharacterSetType } from "ts-randomstring/lib/index.js"

export async function generateLehrerVorname(){
return "TAuto-PW-V-" + faker.person.firstName();
return "TAuto-PW-V-" + faker.person.firstName() + generateRandomString({length: 3,charSetType: CharacterSetType.Alphabetic})
}

export async function generateLehrerNachname(){
return "TAuto-PW-N-" + faker.person.lastName();
return "TAuto-PW-N-" + faker.person.lastName() + generateRandomString({length: 3,charSetType: CharacterSetType.Alphabetic})
}

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


export async function generateRolleName(){
return "TAuto-PW-R-" + faker.lorem.word({ length: { min: 7, max: 7 }}) + generateRandomString({length: 3,charSetType: CharacterSetType.Alphabetic})
}
36 changes: 35 additions & 1 deletion package-lock.json

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

15 changes: 3 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,7 @@
"@fast-csv/parse": "^4.3.6",
"fast-csv": "^4.3.6",
"generate-password-ts": "^1.6.5",
"moment": "^2.30.1"
},
"name": "schulportal-testautomatisierung",
"description": "",
"version": "0.6.0",
"main": "index.js",
"directories": {
"test": "tests"
},
"keywords": [],
"author": "Dataport AöR",
"license": "EUPL-1.2"
"moment": "^2.30.1",
"ts-randomstring": "^1.0.8"
}
}
2 changes: 1 addition & 1 deletion playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export default defineConfig({
forbidOnly: !!process.env.CI,
retries: process.env.CI ? 2 : 0,
maxFailures: 9,
workers: process.env.CI ? 1 : undefined,
workers: process.env.CI ? 2 : undefined,
reporter: [["html"]],
use: {
trace: "on-first-retry",
Expand Down
2 changes: 1 addition & 1 deletion tests/Klasse.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ test.describe(`Testfälle für die Administration von Klassen: Umgebung: ${proce
await test.step(`In der Ergebnisliste prüfen, dass die neue Klasse angezeigt wird`, async () => {
await menue.menueItem_AlleKlassenAnzeigen.click();
await klasseManagementView.combobox_Filter_Schule.fill(schulname);
await page.getByText(`${schulname}`, { exact: true }).click();
await page.getByText(`${schulname}`, { exact: true }).click({delay:1000});
await klasseManagementView.text_h2_Klassenverwaltung.click(); // dies schließt das Dropdown Klasse
await expect(page.getByRole('cell', { name: klassenname })).toBeVisible();
});
Expand Down
15 changes: 8 additions & 7 deletions tests/Person.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { addSystemrechtToRolle } from "../base/api/testHelperRolle.page";
import { LONG, SHORT, STAGE, BROWSER } from "../base/tags";
import { deletePersonByUsername, deleteRolleById, deleteRolleByName } from "../base/testHelperDeleteTestdata.ts";
import { landesadminRolle, schuelerRolle, schuladminOeffentlichRolle } from "../base/roles.ts";
import { generateRolleName } from "../base/testHelperGenerateTestdataNames.ts";
import { generateLehrerNachname, generateLehrerVorname, generateRolleName } from "../base/testHelperGenerateTestdataNames.ts";

const PW: string | undefined = process.env.PW;
const ADMIN: string | undefined = process.env.USER;
Expand Down Expand Up @@ -230,7 +230,7 @@ test.describe(`Testfälle für die Administration von Personen": Umgebung: ${pro
// 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, generateRolleName());
userInfo = await createRolleAndPersonWithUserContext(page, schulstrukturknoten, 'LEIT', nachname, vorname, idSP, await generateRolleName());
await addSystemrechtToRolle(page, userInfo.rolleId, 'PERSONEN_VERWALTEN');
await addSystemrechtToRolle(page, userInfo.rolleId, 'PERSONEN_ANLEGEN');

Expand Down Expand Up @@ -393,9 +393,10 @@ test.describe(`Testfälle für die Administration von Personen": Umgebung: ${pro
await personCreationView.combobox_Rolle.click();
await expect(personCreationView.listbox_Rolle).toContainText(rolleLehr);
await expect(personCreationView.listbox_Rolle).toContainText(rolleLiV);
await expect(personCreationView.listbox_Rolle).toContainText(schuladminOeffentlichRolle);
await expect(personCreationView.listbox_Rolle).toContainText(schuelerRolle);
await expect(personCreationView.listbox_Rolle).not.toContainText(landesadminRolle);
await page.keyboard.type(schuladminOeffentlichRolle);
await expect(personCreationView.listbox_Rolle).toContainText(schuladminOeffentlichRolle);
});
});

Expand Down Expand Up @@ -519,7 +520,7 @@ test.describe(`Testfälle für die Administration von Personen": Umgebung: ${pro

await test.step(`Testdaten: Landesadmin anlegen und mit diesem anmelden`, async () => {
const idSP = await getSPId(page, 'Schulportal-Administration');
userInfo = await createRolleAndPersonWithUserContext(page, 'Land Schleswig-Holstein', 'SYSADMIN', 'TAuto-PW-B-Master', 'TAuto-PW-B-Hans', idSP, generateRolleName());
userInfo = await createRolleAndPersonWithUserContext(page, 'Land Schleswig-Holstein', 'SYSADMIN', 'TAuto-PW-B-Master', 'TAuto-PW-B-Hans', idSP, await generateRolleName());
await addSystemrechtToRolle(page, userInfo.rolleId, 'ROLLEN_VERWALTEN');
await addSystemrechtToRolle(page, userInfo.rolleId, 'PERSONEN_SOFORT_LOESCHEN');
await addSystemrechtToRolle(page, userInfo.rolleId, 'PERSONEN_VERWALTEN');
Expand Down Expand Up @@ -679,9 +680,9 @@ test.describe(`Testfälle für die Administration von Personen": Umgebung: ${pro
const PersonDetailsView = new PersonDetailsViewPage(page);
const header = new HeaderPage(page);

const vorname = "TAuto-PW-V-" + faker.person.firstName();
const nachname = "TAuto-PW-N-" + faker.person.lastName();
const rolle = generateRolleName();
const vorname = await generateLehrerVorname();
const nachname = await generateLehrerNachname();
const rolle = await generateRolleName();
const berechtigung = 'SYSADMIN';
const idSP = await getSPId(page, 'Schulportal-Administration');

Expand Down
8 changes: 4 additions & 4 deletions tests/PersonBearbeiten.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,15 @@ test.describe(`Testfälle für die Administration von Personen": Umgebung: ${pro

const addminVorname = "TAuto-PW-V-" + faker.person.firstName();
const adminNachname = "TAuto-PW-N-" + faker.person.lastName();
const adminRolle = generateRolleName();
const adminRolle = await generateRolleName();
const adminRollenart = 'LEIT';
const adminOrganisation = 'Testschule-PW665';
const adminIdSP = await getSPId(page, 'Schulportal-Administration');
let userInfoAdmin: UserInfo;

const lehrerVorname = "TAuto-PW-V-" + faker.person.firstName();
const lehrerNachname = "TAuto-PW-N-" + faker.person.lastName();
const lehrerRolle = generateRolleName();
const lehrerRolle = await generateRolleName();
const lehrerRollenart = 'LEHR';
const lehrerOrganisation = 'Testschule-PW665';
const lehrerIdSP = await getSPId(page, 'E-Mail');
Expand Down Expand Up @@ -149,7 +149,7 @@ test.describe(`Testfälle für die Administration von Personen": Umgebung: ${pro
const sperrDatumAb = await generateDateToday() // Konkrete Testdaten für diesen Testfall

await test.step(`Testdaten: Lehrer mit einer Rolle(LEHR) und SP(email) über die api anlegen ${ADMIN}`, async () => {
userInfoLehrer = await createRolleAndPersonWithUserContext(page, testschule, typelehrer, await generateLehrerNachname(), await generateLehrerVorname(), await getSPId(page, email), generateRolleName());
userInfoLehrer = await createRolleAndPersonWithUserContext(page, testschule, typelehrer, await generateLehrerNachname(), await generateLehrerVorname(), await getSPId(page, email), await generateRolleName());
username.push(userInfoLehrer.username);
rolleId.push(userInfoLehrer.rolleId);
})
Expand All @@ -175,7 +175,7 @@ test.describe(`Testfälle für die Administration von Personen": Umgebung: ${pro
const sperrDatumBis = await generateDateFuture(5, 2); // Konkrete Testdaten für diesen Testfall

await test.step(`Testdaten: Lehrer mit einer Rolle(LEHR) und SP(email) über die api anlegen ${ADMIN}`, async () => {
userInfoLehrer = await createRolleAndPersonWithUserContext(page, testschule, typelehrer, await generateLehrerNachname(), await generateLehrerVorname(), await getSPId(page, email), generateRolleName());
userInfoLehrer = await createRolleAndPersonWithUserContext(page, testschule, typelehrer, await generateLehrerNachname(), await generateLehrerVorname(), await getSPId(page, email), await generateRolleName());
username.push(userInfoLehrer.username);
rolleId.push(userInfoLehrer.rolleId);
})
Expand Down
Loading

0 comments on commit 2a082bd

Please sign in to comment.