-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SPSH-755 schulportal administration pruefen (#46)
* Neuerr Testfall Schulportal-Adminsitration mit Testdaten via api * Test Schulportal-Administration fertig * fix * testHelper umbenannt damit SonarCloud nicht wegen der Testabdeckung meckert * Bennung der Testdaten laut Konvention aus der readme. Logout nach jedem Testfall um Probleme bei der parallelen Ausführung bei mehreren workers zu minimieren. * Update base/testHelper.page.ts Co-authored-by: Julian Aggarwal <[email protected]> * Update base/testHelper.page.ts Co-authored-by: Julian Aggarwal <[email protected]> * User bzw Benutzer durch Person ersetzt * testHelper auf mehrere Dateien aufgesplittet --------- Co-authored-by: Julian Aggarwal <[email protected]>
- Loading branch information
1 parent
783dc5f
commit 2dc442e
Showing
14 changed files
with
306 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export interface UserInfo { | ||
username: string, | ||
password: string, | ||
rolleId: string, | ||
organisationId: string, | ||
personId: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { Page, expect } from '@playwright/test'; | ||
import { faker } from "@faker-js/faker/locale/de"; | ||
|
||
const FRONTEND_URL = process.env.FRONTEND_URL || ""; | ||
|
||
export async function createOrganisation(page: Page, name: string): Promise<string> { | ||
const response = await page.request.post(FRONTEND_URL + 'api/organisationen/', { | ||
data: { | ||
"administriertVon": null, | ||
"zugehoerigZu": null, | ||
"kennung": faker.string.numeric({length: 6}), | ||
"name": name, | ||
"namensergaenzung": null, | ||
"kuerzel": null, | ||
"typ": "SCHULE", | ||
"traegerschaft": null | ||
} | ||
}); | ||
expect(response.status()).toBe(201); | ||
const json = await response.json(); | ||
return json.id; | ||
} | ||
|
||
export async function getOrganisationId(page: Page, nameOrganisation: string): Promise<string> { | ||
const response = await page.request.get(FRONTEND_URL + `api/organisationen?name=${nameOrganisation}`, {}); | ||
expect(response.status()).toBe(200); | ||
const json = await response.json(); | ||
return json[0].id; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { Page, expect } from '@playwright/test'; | ||
import { getOrganisationId } from "./testHelperOrganisation.page"; | ||
import { createRolle, addSPToRolle } from "./testHelperRolle.page"; | ||
import { UserInfo } from "./testHelper.page"; | ||
|
||
const FRONTEND_URL = process.env.FRONTEND_URL || ""; | ||
|
||
export async function createPerson(page: Page, familienname: string, vorname: string, organisationId: string, rolleId: string): Promise<UserInfo> { | ||
const response = await page.request.post(FRONTEND_URL + 'api/personenkontext-workflow/', { | ||
data: { | ||
"familienname": familienname, | ||
"vorname": vorname, | ||
"organisationId": organisationId, | ||
"rolleId": rolleId | ||
} | ||
}); | ||
expect(response.status()).toBe(201); | ||
const json = await response.json(); | ||
return { | ||
username: json.person.referrer, | ||
password: json.person.startpasswort, | ||
rolleId: rolleId, | ||
organisationId: organisationId, | ||
personId: json.person.id | ||
} | ||
} | ||
|
||
export async function createPersonWithUserContext(page: Page, organisationName: string, rollenArt: string, familienname: string, vorname: string, idSP: string, rolleName: string): Promise<UserInfo> { | ||
// 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); | ||
const userInfo: UserInfo = await createPerson(page, familienname, vorname, organisationId, rolleId); | ||
return userInfo; | ||
} | ||
|
||
export async function deletePersonen(page: Page, personId: string): Promise<void> { | ||
const response = await page.request.delete(FRONTEND_URL + `api/personen/${personId}`, {}); | ||
expect(response.status()).toBe(204); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { Page, expect } from '@playwright/test'; | ||
|
||
const FRONTEND_URL = process.env.FRONTEND_URL || ""; | ||
|
||
export async function createRolle(page: Page, rollenArt: string, organisationId: string, rolleName?: string): Promise<string> { | ||
const response = await page.request.post(FRONTEND_URL + 'api/rolle/', { | ||
data: { | ||
"name": rolleName, | ||
"administeredBySchulstrukturknoten": organisationId, | ||
"rollenart": rollenArt, | ||
"merkmale": [], | ||
"systemrechte": [] | ||
} | ||
}); | ||
expect(response.status()).toBe(201); | ||
const json = await response.json(); | ||
return json.id; | ||
} | ||
|
||
export async function addSPToRolle(page: Page, rolleId: string, idSP: string): Promise<void> { | ||
const response = await page.request.post(FRONTEND_URL + `api/rolle/${rolleId}/serviceProviders`, { | ||
data: { | ||
"serviceProviderId": idSP | ||
} | ||
}); | ||
expect(response.status()).toBe(201); | ||
} | ||
|
||
export async function addSystemrechtToRolle(page: Page, rolleId: string, systemrecht: string): Promise<void> { | ||
const response = await page.request.patch(FRONTEND_URL + `api/rolle/${rolleId}`, { | ||
data: { | ||
"systemRecht": systemrecht | ||
} | ||
}); | ||
expect(response.status()).toBe(200); | ||
} | ||
|
||
export async function deleteRolle(page: Page, RolleId: string): Promise<void> { | ||
const response = await page.request.delete(FRONTEND_URL + `api/rolle/${RolleId}`, {}); | ||
expect(response.status()).toBe(204); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { Page, expect } from '@playwright/test'; | ||
|
||
const FRONTEND_URL = 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`, {}); | ||
expect(response.status()).toBe(200); | ||
const json = await response.json(); | ||
expect(response.status()).toBe(200); | ||
let idSP = ''; | ||
|
||
json.forEach((element) => { | ||
if (element.name === nameSP) { | ||
idSP = element.id; | ||
} | ||
}); | ||
return idSP; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
import { expect, test } from "@playwright/test"; | ||
import { LandingPage } from "../pages/LandingView.page"; | ||
import { StartPage } from "../pages/StartView.page"; | ||
import { LoginPage } from "../pages/LoginView.page"; | ||
import { HeaderPage } from "../pages/Header.page"; | ||
import { getSPId } from "../base/api/testHelperServiceprovider.page"; | ||
import { createPersonWithUserContext, deletePersonen } from "../base/api/testHelperPerson.page"; | ||
import { addSystemrechtToRolle, deleteRolle } from "../base/api/testHelperRolle.page"; | ||
import { UserInfo } from "../base/api/testHelper.page"; | ||
|
||
const PW = process.env.PW; | ||
const ADMIN = process.env.USER; | ||
const FRONTEND_URL = process.env.FRONTEND_URL || ""; | ||
|
||
test.describe(`Testfälle für Schulportal Administration": Umgebung: ${process.env.UMGEBUNG}: URL: ${process.env.FRONTEND_URL}:`, () => { | ||
test.afterEach(async ({ page }) => { | ||
await test.step(`Abmelden`, async () => { | ||
const Header = new HeaderPage(page); | ||
await Header.button_logout.click(); | ||
}); | ||
}); | ||
|
||
test("Prüfen, dass die Schulportal-Administration Kachel nicht sichtbar ist für Lehrkräfte", async ({page}) => { | ||
const Landing = new LandingPage(page); | ||
const Login = new LoginPage(page); | ||
const Header = new HeaderPage(page); | ||
|
||
// Testdaten erstellen | ||
await page.goto(FRONTEND_URL); | ||
await Landing.button_Anmelden.click(); | ||
await Login.login(ADMIN, PW); | ||
|
||
const idSP = await getSPId(page, 'E-Mail'); | ||
const userInfo: UserInfo = await createPersonWithUserContext(page, 'Testschule Schulportal', 'LEHR', 'TAuto-PW-B-MeierLehrer', 'TAuto-PW-B-Hans', idSP, 'TAuto-PW-R-RolleLehrer'); | ||
await Header.button_logout.click(); | ||
|
||
// Test durchführen | ||
await Landing.button_Anmelden.click(); | ||
await Login.login(userInfo.username, userInfo.password); | ||
await Login.UpdatePW(); | ||
const Startseite = new StartPage(page); | ||
await test.step(`Prüfen, dass die Kachel E-Mail angezeigt wird und die Kachel Schulportal-Administration nicht angezeigt wird`, async () => { | ||
await expect(Startseite.card_item_schulportal_administration).toBeHidden(); | ||
await expect(Startseite.card_item_email).toBeVisible(); | ||
}); | ||
await Header.button_logout.click(); | ||
|
||
// Testdaten löschen | ||
await Landing.button_Anmelden.click(); | ||
await Login.login(ADMIN, PW); | ||
await deletePersonen(page, userInfo.personId); | ||
await deleteRolle(page, userInfo.rolleId); | ||
}); | ||
|
||
test("Prüfen, dass die Schulportal-Administration Kachel nicht sichtbar ist für Schüler", async ({page}) => { | ||
const Landing = new LandingPage(page); | ||
const Login = new LoginPage(page); | ||
const Header = new HeaderPage(page); | ||
|
||
// Testdaten erstellen | ||
await page.goto(FRONTEND_URL); | ||
await Landing.button_Anmelden.click(); | ||
await Login.login(ADMIN, PW); | ||
|
||
const idSP = await getSPId(page, 'itslearning'); | ||
const userInfo: UserInfo = await createPersonWithUserContext(page, 'Testschule Schulportal', 'LERN', 'TAuto-PW-B-JansenSchüler', 'TAuto-PW-B-Helga', idSP, 'TAuto-PW-R-RolleSuS'); | ||
await Header.button_logout.click(); | ||
|
||
// Test durchführen | ||
await Landing.button_Anmelden.click(); | ||
await Login.login(userInfo.username, userInfo.password); | ||
await Login.UpdatePW(); | ||
const Startseite = new StartPage(page); | ||
await test.step(`Prüfen, dass die Kachel E-Mail angezeigt wird und die Kachel Schulportal-Administration nicht angezeigt wird`, async () => { | ||
await expect(Startseite.card_item_schulportal_administration).toBeHidden(); | ||
await expect(Startseite.card_item_itslearning).toBeVisible(); | ||
}); | ||
await Header.button_logout.click(); | ||
|
||
// Testdaten löschen | ||
await Landing.button_Anmelden.click(); | ||
await Login.login(ADMIN, PW); | ||
await deletePersonen(page, userInfo.personId); | ||
await deleteRolle(page, userInfo.rolleId); | ||
}); | ||
|
||
test("Prüfen, dass die Schulportal-Administration Kachel sichtbar ist für Schuladmins", async ({page}) => { | ||
const Landing = new LandingPage(page); | ||
const Login = new LoginPage(page); | ||
const Header = new HeaderPage(page); | ||
|
||
// Testdaten erstellen | ||
await page.goto(FRONTEND_URL); | ||
await Landing.button_Anmelden.click(); | ||
await Login.login(ADMIN, PW); | ||
|
||
const idSP = await getSPId(page, 'Schulportal-Administration'); | ||
const userInfo: UserInfo = await createPersonWithUserContext(page, 'Testschule Schulportal', 'LEIT', 'TAuto-PW-B-MeierAdmin', 'TAuto-PW-B-Peter', idSP, 'TAuto-PW-R-RolleSchuladmin'); | ||
|
||
await addSystemrechtToRolle(page, userInfo.rolleId, 'PERSONEN_VERWALTEN'); | ||
await Header.button_logout.click(); | ||
|
||
// Test durchführen | ||
await Landing.button_Anmelden.click(); | ||
await Login.login(userInfo.username, userInfo.password); | ||
await Login.UpdatePW(); | ||
const Startseite = new StartPage(page); | ||
await test.step(`Prüfen, dass die Kachel E-Mail nicht angezeigt wird und die Kachel Schulportal-Administration angezeigt wird`, async () => { | ||
await expect(Startseite.card_item_schulportal_administration).toBeVisible(); | ||
await expect(Startseite.card_item_email).toBeHidden(); | ||
}); | ||
await Header.button_logout.click(); | ||
|
||
// Testdaten löschen | ||
await Landing.button_Anmelden.click(); | ||
await Login.login(ADMIN, PW); | ||
await deletePersonen(page, userInfo.personId); | ||
await deleteRolle(page, userInfo.rolleId); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.