diff --git a/pages/FooterDataTable.page.ts b/pages/FooterDataTable.page.ts index aa034c7..7cf9473 100644 --- a/pages/FooterDataTable.page.ts +++ b/pages/FooterDataTable.page.ts @@ -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)'); } } \ No newline at end of file diff --git a/pages/admin/KlasseManagementView.page.ts b/pages/admin/KlasseManagementView.page.ts index 3e5f76c..7923492 100644 --- a/pages/admin/KlasseManagementView.page.ts +++ b/pages/admin/KlasseManagementView.page.ts @@ -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; @@ -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; @@ -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(); + } } } \ No newline at end of file diff --git a/tests/Klasse.spec.ts b/tests/Klasse.spec.ts index 2f2bcd5..269d07b 100644 --- a/tests/Klasse.spec.ts +++ b/tests/Klasse.spec.ts @@ -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(); + }); + }); }); \ No newline at end of file