Skip to content

Commit

Permalink
Spsh 980 lock user (#83)
Browse files Browse the repository at this point in the history
* Neuer Testfall Benutzer sperren

* 'Test Benutzer sperren' fertig

* 2 neue Tests Benutzer sperren

* fix findigs from review

* fix findigs from review

* baseUrl introduced in playwright.config

* minor changes

* minor changes

* Navigation in Pages hängen

* minor changes

* merged main into branch

* Update pages/admin/PersonManagementView.page.ts

Co-authored-by: Julian Aggarwal <[email protected]>

* revert change getByRolle

* renamed rolesTypes.ts to rollentypen.ts

---------

Co-authored-by: Kristoff Kiefer <[email protected]>
Co-authored-by: Julian Aggarwal <[email protected]>
  • Loading branch information
3 people authored Nov 18, 2024
1 parent ea089c2 commit 228ffc9
Show file tree
Hide file tree
Showing 13 changed files with 273 additions and 103 deletions.
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
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);
}
}
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
2 changes: 1 addition & 1 deletion 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
Loading

0 comments on commit 228ffc9

Please sign in to comment.