Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spsh 1557 fix test angebote per link oeffnen als lehrer #116

Merged
merged 10 commits into from
Dec 19, 2024
16 changes: 9 additions & 7 deletions base/api/testHelperPerson.page.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import { Page, expect } from '@playwright/test';
import { getOrganisationId } from "./testHelperOrganisation.page";
import { createRolle, addSPToRolle, getRolleId } from "./testHelperRolle.page";
import { getSPId } from "./testHelperServiceprovider.page";
import { UserInfo } from "./testHelper.page";
import { HeaderPage } from '../../pages/Header.page';
import { LoginPage } from '../../pages/LoginView.page';
import { lehrkraftOeffentlichRolle } from '../rollen';
import { generateNachname, generateVorname, generateKopersNr } from "../testHelperGenerateTestdataNames";
import { generateNachname, generateVorname, generateKopersNr, generateRolleName } from "../testHelperGenerateTestdataNames";
import { testschule } from "../organisation";
import { email, kalender, adressbuch } from "../sp";
import { typelehrer } from "../rollentypen";

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

Expand Down Expand Up @@ -50,12 +52,13 @@ export async function createPersonWithUserContext(page: Page, organisationName:
return userInfo;
}

export async function createRolleAndPersonWithUserContext(page: Page, organisationName: string, rollenArt: string, familienname: string, vorname: string, idSP: string, rolleName: string, koPersNr?: string): Promise<UserInfo> {
export async function createRolleAndPersonWithUserContext(page: Page, organisationName: string, rollenArt: string, familienname: string, vorname: string, idSPs: Array<string>, rolleName: string, koPersNr?: string): Promise<UserInfo> {
// Organisation wird nicht angelegt, da diese zur Zeit nicht gelöscht werden kann
// API-Calls machen und Benutzer mit Kontext anlegen
const organisationId: string = await getOrganisationId(page, organisationName);
const rolleId: string = await createRolle(page, rollenArt, organisationId, rolleName);
await addSPToRolle(page, rolleId, idSP);

await addSPToRolle(page, rolleId, idSPs);
const userInfo: UserInfo = await createPerson(page, familienname, vorname, organisationId, rolleId, koPersNr);
return userInfo;
}
Expand Down Expand Up @@ -100,9 +103,8 @@ export async function getPersonId(page: Page, searchString: string): Promise<str
export async function createTeacherAndLogin(page: Page) {
const header = new HeaderPage(page);
const login: LoginPage = new LoginPage(page);
const organisation = testschule;

const userInfo: UserInfo = await createPersonWithUserContext(page, organisation, await generateNachname(), await generateVorname(), lehrkraftOeffentlichRolle, await generateKopersNr());
const userInfo: UserInfo = await createRolleAndPersonWithUserContext(page, testschule, typelehrer, await generateNachname(), await generateVorname(), [await getSPId(page, email), await getSPId(page, kalender), await getSPId(page, adressbuch)], await generateRolleName(), await generateKopersNr());

await header.logout();
await header.button_login.click();
await login.login(userInfo.username, userInfo.password);
Expand Down
5 changes: 3 additions & 2 deletions base/api/testHelperRolle.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,16 @@ export async function createRolle(page: Page, rollenArt: string, organisationId:
return json.id;
}

export async function addSPToRolle(page: Page, rolleId: string, idSP: string): Promise<void> {
export async function addSPToRolle(page: Page, rolleId: string, idSPs: Array<string>): Promise<void> { // version=1 for the first update
jakobmadp marked this conversation as resolved.
Show resolved Hide resolved
const response = await page.request.put(FRONTEND_URL + `api/rolle/${rolleId}/serviceProviders`, {
data: {
"serviceProviderIds": [idSP],
"serviceProviderIds": idSPs,
"version": 1,
},
failOnStatusCode: false,
maxRetries: 3
});

expect(response.status()).toBe(201);
}

Expand Down
4 changes: 3 additions & 1 deletion base/sp.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
export const email = "E-Mail";
export const itslearning = "itslearning";
export const itslearning = "itslearning";
export const kalender = "Kalender";
export const adressbuch = "Adressbuch";
8 changes: 8 additions & 0 deletions base/testHelperGenerateTestdataNames.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,12 @@ export async function generateKopersNr(){

export async function generateKlassenname(){
return "TAuto-PW-K-12a " + faker.lorem.word({ length: { min: 8, max: 8 }}) + generateRandomString({length: 3,charSetType: CharacterSetType.Alphabetic});
}

export async function generateSchulname(){
return "TAuto-PW-S-" + faker.lorem.word({ length: { min: 8, max: 8 }}) + generateRandomString({length: 3,charSetType: CharacterSetType.Alphabetic});
}

export async function generateDienstellenNr(){
jakobmadp marked this conversation as resolved.
Show resolved Hide resolved
return "0" + faker.number.bigInt({ min: 10000000, max: 100000000 });
}
13 changes: 7 additions & 6 deletions tests/Klasse.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { StartPage } from "../pages/StartView.page";
import { MenuPage } from "../pages/MenuBar.page";
import { KlasseCreationViewPage } from "../pages/admin/KlasseCreationView.page";
import { KlasseManagementViewPage } from "../pages/admin/KlasseManagementView.page";
import { faker } from "@faker-js/faker/locale/de";
import { HeaderPage } from "../pages/Header.page";
import { LONG, SHORT, STAGE, BROWSER } from "../base/tags";
import { deleteKlasseByName, deletePersonenBySearchStrings, deleteRolleById } from "../base/testHelperDeleteTestdata.ts";
Expand All @@ -16,6 +15,7 @@ import { addSystemrechtToRolle } from "../base/api/testHelperRolle.page.ts";
import { getSPId } from "../base/api/testHelperServiceprovider.page.ts";
import { KlasseDetailsViewPage } from "../pages/admin/KlasseDetailsView.page.ts";
import { UserInfo } from "../base/api/testHelper.page.ts";
import { getOrganisationId } from "../base/api/testHelperOrganisation.page.ts";

const PW: string | undefined = process.env.PW;
const ADMIN: string | undefined = process.env.USER;
Expand Down Expand Up @@ -207,15 +207,15 @@ test.describe(`Testfälle für die Administration von Klassen: Umgebung: ${proce
const adminRolle = await generateRolleName();
const adminRollenart = 'SYSADMIN';
const adminOrganisation = landSH;
const adminIdSP = await getSPId(page, 'Schulportal-Administration');
const adminIdSPs: Array<string> = [await getSPId(page, 'Schulportal-Administration')];

userInfoAdmin = await createRolleAndPersonWithUserContext(
page,
adminOrganisation,
adminRollenart,
addminVorname,
adminNachname,
adminIdSP,
adminIdSPs,
adminRolle
);
await addSystemrechtToRolle(page, userInfoAdmin.rolleId, 'ROLLEN_VERWALTEN');
Expand Down Expand Up @@ -281,15 +281,15 @@ test.describe(`Testfälle für die Administration von Klassen: Umgebung: ${proce
const adminRolle = await generateRolleName();
const adminRollenart = 'LEIT';
const adminOrganisation = testschule;
const adminIdSP = await getSPId(page, 'Schulportal-Administration');
const adminIdSPs: Array<string> = [await getSPId(page, 'Schulportal-Administration')];;

userInfoAdmin = await createRolleAndPersonWithUserContext(
page,
adminOrganisation,
adminRollenart,
addminVorname,
adminNachname,
adminIdSP,
adminIdSPs,
adminRolle
);
await addSystemrechtToRolle(page, userInfoAdmin.rolleId, 'PERSONEN_VERWALTEN');
Expand All @@ -311,13 +311,14 @@ test.describe(`Testfälle für die Administration von Klassen: Umgebung: ${proce
await menue.menueItem_KlasseAnlegen.click();
await expect(klasseCreationView.text_h2_KlasseAnlegen).toHaveText('Neue Klasse hinzufügen');

await expect(klasseCreationView.combobox_Schulstrukturknoten).toContainText(testschule);
await klasseCreationView.input_Klassenname.fill(klassenname);
await klasseCreationView.button_KlasseAnlegen.click();
await expect(klasseCreationView.text_success).toBeVisible();
});

await test.step(`Klasse bearbeiten als Schuladmin`, async () => {
await menue.menueItem_AlleKlassenAnzeigen.click();
await page.goto('/admin/klassen');
await klasseManagementView.combobox_Filter_Schule.fill(schulname);
await page.getByText(`${schulname}`, { exact: true }).click();
await klasseManagementView.combobox_Filter_Klasse.fill(klassenname);
Expand Down
69 changes: 34 additions & 35 deletions tests/Person.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,14 @@ import { PersonCreationViewPage } from "../pages/admin/PersonCreationView.page";
import { PersonManagementViewPage } from "../pages/admin/PersonManagementView.page";
import { PersonDetailsViewPage } from "../pages/admin/PersonDetailsView.page";
import { HeaderPage } from "../pages/Header.page";
import { faker } from "@faker-js/faker/locale/de";
import { createRolleAndPersonWithUserContext } from "../base/api/testHelperPerson.page";
import { getSPId } from "../base/api/testHelperServiceprovider.page";
import { UserInfo } from "../base/api/testHelper.page";
import { addSystemrechtToRolle } from "../base/api/testHelperRolle.page";
import { LONG, SHORT, STAGE, BROWSER } from "../base/tags";
import { deletePersonenBySearchStrings, deleteRolleById, deleteRolleByName } from "../base/testHelperDeleteTestdata.ts";
import { landesadminRolle, schuelerRolle, schuladminOeffentlichRolle } from "../base/rollen.ts";
import { generateNachname, generateVorname, generateRolleName } from "../base/testHelperGenerateTestdataNames.ts";
import { generateNachname, generateVorname, generateRolleName, generateKopersNr } from "../base/testHelperGenerateTestdataNames.ts";
import { testschule665, testschule } from "../base/organisation.ts";
import { gotoTargetURL } from "../base/testHelperUtils.ts";

Expand Down Expand Up @@ -97,7 +96,7 @@ test.describe(`Testfälle für die Administration von Personen": Umgebung: ${pro
const rolle = "Lehrkraft";
const vorname = await generateVorname();
const nachname = await generateNachname();
const kopersnr = faker.string.numeric(7);
const kopersnr = await generateKopersNr()
const schulstrukturknoten = "Testschule Schulportal";
let einstiegspasswort = "";

Expand Down Expand Up @@ -146,8 +145,8 @@ test.describe(`Testfälle für die Administration von Personen": Umgebung: ${pro
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 vorname = await generateVorname();
const nachname = await generateNachname();
const schulstrukturknoten = "Öffentliche Schulen Land Schleswig-Holstein";

await test.step(`Dialog Person anlegen öffnen`, async () => {
Expand Down Expand Up @@ -182,9 +181,9 @@ test.describe(`Testfälle für die Administration von Personen": Umgebung: ${pro
const personCreationView = new PersonCreationViewPage(page);

const rolle = "LiV";
const vorname = "TAuto-PW-V-" + faker.person.firstName();
const nachname = "TAuto-PW-N-" + faker.person.lastName();
const kopersnr = faker.string.numeric(7);
const vorname = await generateVorname();
const nachname = await generateNachname();
const kopersnr = await generateKopersNr();
const schulstrukturknoten = "Testschule Schulportal";

await test.step(`Dialog Person anlegen öffnen`, async () => {
Expand Down Expand Up @@ -222,16 +221,16 @@ test.describe(`Testfälle für die Administration von Personen": Umgebung: ${pro
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 vorname = await generateVorname();
const nachname = await generateNachname();
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, await generateRolleName());
const idSPs: Array<string> = [await getSPId(page, 'Schulportal-Administration')];
userInfo = await createRolleAndPersonWithUserContext(page, schulstrukturknoten, 'LEIT', nachname, vorname, idSPs, await generateRolleName());
await addSystemrechtToRolle(page, userInfo.rolleId, 'PERSONEN_VERWALTEN');
await addSystemrechtToRolle(page, userInfo.rolleId, 'PERSONEN_ANLEGEN');

Expand All @@ -247,9 +246,9 @@ test.describe(`Testfälle für die Administration von Personen": Umgebung: ${pro

// 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);
const newVorname = await generateVorname();
const newNachname = await generateNachname();
const newKopersnr = await generateKopersNr();

await startseite.card_item_schulportal_administration.click();
await menue.menueItem_BenutzerAnlegen.click();
Expand All @@ -274,8 +273,8 @@ test.describe(`Testfälle für die Administration von Personen": Umgebung: ${pro
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 vorname = await generateVorname();
const nachname = await generateNachname();
const schulstrukturknoten = testschule;
const klasse = "Playwright3a";

Expand Down Expand Up @@ -406,9 +405,9 @@ test.describe(`Testfälle für die Administration von Personen": Umgebung: ${pro
const personCreationView = new PersonCreationViewPage(page);

const rolle = "Lehrkraft";
const vorname = "TAuto-PW-V-" + faker.person.firstName();
const nachname = "TAuto-PW-N-" + faker.person.lastName();
const kopersnr = faker.string.numeric(7);
const vorname = await generateVorname();
const nachname = await generateNachname();
const kopersnr = await generateKopersNr();
const schulstrukturknoten = "Testschule Schulportal";

await test.step(`Benutzer Lehrkraft anlegen`, async () => {
Expand Down Expand Up @@ -488,9 +487,9 @@ test.describe(`Testfälle für die Administration von Personen": Umgebung: ${pro
test("Eine Lehrkraft anlegen in der Rolle Landesadmin und die Bestätigungsseite vollständig prüfen", {tag: [LONG, SHORT, STAGE]}, async ({ page }) => {
const personCreationView = new PersonCreationViewPage(page);
const rolle = "Lehrkraft";
const vorname = "TAuto-PW-V-" + faker.person.firstName();
const nachname = "TAuto-PW-N-" + faker.person.lastName();
const kopersnr = faker.string.numeric(7);
const vorname = await generateVorname();
const nachname = await generateNachname();
const kopersnr = await generateKopersNr();;
const schulstrukturknoten = "Testschule Schulportal";
const dienststellenNr = "1111111";

Expand Down Expand Up @@ -543,8 +542,8 @@ test.describe(`Testfälle für die Administration von Personen": Umgebung: ${pro
let userInfo: UserInfo;

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, await generateRolleName());
const idSPs: Array<string> = [await getSPId(page, 'Schulportal-Administration')];
userInfo = await createRolleAndPersonWithUserContext(page, 'Land Schleswig-Holstein', 'SYSADMIN', await generateNachname(), await generateVorname(), idSPs, 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 All @@ -567,19 +566,19 @@ test.describe(`Testfälle für die Administration von Personen": Umgebung: ${pro
// Testdaten
const schulstrukturknoten = "Testschule Schulportal";
const dienststellenNr = "1111111";
const vorname1 = "TAuto-PW-VA-" + faker.person.firstName();
const nachname1 = "TAuto-PW-NA-" + faker.person.lastName();
const vorname1 = await generateVorname();
const nachname1 = await generateNachname();
const klassenname = "Playwright3a";

const rolle2 = "Lehrkraft";
const vorname2 = "TAuto-PW-VB-" + faker.person.firstName();
const nachname2 = "TAuto-PW-NB-" + faker.person.lastName();
const kopersnr2 = faker.string.numeric(7);
const vorname2 = await generateVorname();
const nachname2 = await generateNachname();
const kopersnr2 = await generateKopersNr();

const rolle3 = "Lehrkraft";
const vorname3 = "TAuto-PW-VC-" + faker.person.firstName();
const nachname3 = "TAuto-PW-NC-" + faker.person.lastName();
const kopersnr3 = faker.string.numeric(7);
const vorname3 = await generateVorname();
const nachname3 = await generateNachname();
const kopersnr3 = await generateKopersNr();

await test.step(`Dialog Person anlegen öffnen`, async () => {
await page.goto('/' + 'admin/personen/new');
Expand Down Expand Up @@ -708,10 +707,10 @@ test.describe(`Testfälle für die Administration von Personen": Umgebung: ${pro
const nachname = await generateNachname();
const rolle = await generateRolleName();
const berechtigung = 'SYSADMIN';
const idSP = await getSPId(page, 'Schulportal-Administration');
const idSPs: Array<string> = [await getSPId(page, 'Schulportal-Administration')];

await test.step(`Neuen Benutzer über die api anlegen`, async () => {
await createRolleAndPersonWithUserContext(page, 'Land Schleswig-Holstein', berechtigung, vorname, nachname, idSP, rolle);
await createRolleAndPersonWithUserContext(page, 'Land Schleswig-Holstein', berechtigung, vorname, nachname, idSPs, rolle);
roleName.push(rolle);
})

Expand Down
Loading
Loading