Skip to content

Commit

Permalink
SPSH-1247 (#90)
Browse files Browse the repository at this point in the history
* Test

* PR Review.

* PR Review 2.
  • Loading branch information
YoussefBouch authored Nov 21, 2024
1 parent 687fb4b commit 676eec7
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 3 deletions.
14 changes: 12 additions & 2 deletions pages/FooterDataTable.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,19 @@ import { type Locator, Page } from '@playwright/test';
export class FooterDataTablePage{
readonly page: Page;
readonly combobox_AnzahlEintraege: Locator;
readonly text_AktuelleSeite: Locator;
readonly text_LetzteSeite: Locator;

constructor(page){
this.page = page;
this.combobox_AnzahlEintraege = page.locator('.v-data-table-footer__items-per-page .v-input');
this.page = page;

// Locator for the dropdown to select the number of entries per page
this.combobox_AnzahlEintraege = page.locator('.v-data-table-footer__items-per-page .v-input')

// Locator to identify the current page number
this.text_AktuelleSeite = page.locator('.v-data-table-footer__page-text');

// Locator to identify the last page
this.text_LetzteSeite = page.locator('.v-pagination__next button:not(.v-btn--disabled)');
}
}
21 changes: 20 additions & 1 deletion pages/admin/KlasseManagementView.page.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { type Locator, Page } from '@playwright/test';
import { expect, type Locator, Page } from '@playwright/test';
import { FooterDataTablePage } from '../FooterDataTable.page';

export class KlasseManagementViewPage{
readonly page: Page;
Expand All @@ -11,6 +12,8 @@ export class KlasseManagementViewPage{
readonly icon_KlasseLoeschen: Locator;
readonly button_KlasseLoeschen: Locator;
readonly button_SchliesseKlasseLoeschenDialog: Locator;
readonly tableRows: Locator;
readonly footerDataTable: FooterDataTablePage;

constructor(page: Page){
this.page = page;
Expand All @@ -23,5 +26,21 @@ export class KlasseManagementViewPage{
this.icon_KlasseLoeschen = page.getByTestId('open-klasse-delete-dialog-icon');
this.button_KlasseLoeschen = page.getByTestId('klasse-delete-button');
this.button_SchliesseKlasseLoeschenDialog = page.getByTestId('close-klasse-delete-success-dialog-button');
this.tableRows = page.locator('table >> tbody >> tr');
this.footerDataTable = new FooterDataTablePage(page);
}

// Loops through the Data in the table and checks if the Dienstellennummer and Klassenname are not empty
public async checkTableData() {
const tableRowsCount = await this.tableRows.count();
for (let i = 0; i < tableRowsCount; i++) {
const dienststellennummerCell = this.tableRows.nth(i).locator('td').nth(0);
const klassennameCell = this.tableRows.nth(i).locator('td').nth(1);

await expect(dienststellennummerCell).toBeVisible();
await expect(dienststellennummerCell).not.toHaveText('---');
await expect(klassennameCell).toBeVisible();
await expect(klassennameCell).not.toBeEmpty();
}
}
}
24 changes: 24 additions & 0 deletions tests/Klasse.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,4 +133,28 @@ test.describe(`Testfälle für die Administration von Klassen: Umgebung: ${proce
await expect(klasseCreationView.button_ZurueckErgebnisliste).toBeVisible();
});
});

test("Jede Klasse hat eine Dienststellennummer neben dem Klassennamen (ersten und letzten 100 Einträge)", { tag: [LONG, SHORT, STAGE] }, async ({ page }) => {
const startseite = new StartPage(page);
const menue = new MenuPage(page);
const klasseManagementView = new KlasseManagementViewPage(page);

await test.step(`Klassenverwaltung öffnen und prüfen, dass jede Klasse eine Dienststellennummer hat`, async () => {
// Navigate to Klassenverwaltung
await startseite.card_item_schulportal_administration.click();
await menue.menueItem_AlleKlassenAnzeigen.click();

// Wait until the table is visible
await expect(klasseManagementView.text_h2_Klassenverwaltung).toHaveText("Klassenverwaltung");

// Show first 100 entries
await klasseManagementView.footerDataTable.combobox_AnzahlEintraege.click();
await page.getByRole('option', { name: '100' }).click();

await klasseManagementView.checkTableData();
// Go to the last page
await klasseManagementView.footerDataTable.text_LetzteSeite.click();
await klasseManagementView.checkTableData();
});
});
});

0 comments on commit 676eec7

Please sign in to comment.