test: Tests erfolgreich mit base url von playwright.config.ts

This commit is contained in:
ISA
2025-09-11 10:11:11 +02:00
parent 74880d9ccc
commit 5ef7e648eb
17 changed files with 504 additions and 484 deletions

View File

@@ -0,0 +1,84 @@
import { test, expect } from "@playwright/test";
import { headerTest } from "@/playwright/tests/components/header/headerTest";
import { navTest } from "@/playwright/tests/components/navigation/navTest";
import { footerTest } from "@/playwright/tests/components/footer/footerTest";
test.use({
viewport: {
height: 800,
width: 1280,
},
});
test("Berichte/Meldungen", async ({ page }) => {
await page.goto("/meldungen");
// Gemeinsame Layout-Checks
await headerTest(page);
await navTest(page);
await footerTest(page);
await expect(page.getByRole("heading", { name: "Berichte" })).toBeVisible();
await expect(page.getByText("Von")).toBeVisible();
await expect(
page.locator("div").filter({ hasText: /^Von$/ }).getByRole("textbox")
).toBeVisible();
await expect(page.getByText("Bis")).toBeVisible();
await expect(
page.locator("div").filter({ hasText: /^Bis$/ }).getByRole("textbox")
).toBeVisible();
await expect(page.getByRole("button", { name: "Anzeigen" })).toBeVisible();
await expect(
page.getByRole("button", { name: "Alle Quellen" })
).toBeVisible();
await page
.locator("div")
.filter({ hasText: /^Von$/ })
.getByRole("textbox")
.click();
await expect(page.getByLabel("Sunday", { exact: true })).toBeVisible();
await expect(page.getByLabel("Monday", { exact: true })).toBeVisible();
await expect(page.getByLabel("Tuesday", { exact: true })).toBeVisible();
await expect(page.getByLabel("Wednesday", { exact: true })).toBeVisible();
await expect(page.getByLabel("Thursday", { exact: true })).toBeVisible();
await expect(page.getByLabel("Friday", { exact: true })).toBeVisible();
await expect(page.getByLabel("Saturday", { exact: true })).toBeVisible();
await page
.locator("div")
.filter({ hasText: /^Von$/ })
.getByRole("textbox")
.click();
await page
.locator("div")
.filter({ hasText: /^Von$/ })
.getByRole("textbox")
.click();
await page.getByRole("heading", { name: "Berichte" }).click();
await page
.locator("div")
.filter({ hasText: /^Bis$/ })
.getByRole("textbox")
.click();
await expect(page.getByLabel("Sunday", { exact: true })).toBeVisible();
await page.getByLabel("Monday", { exact: true }).click();
await page.getByLabel("Tuesday", { exact: true }).click();
await page.getByLabel("Wednesday", { exact: true }).click();
await page.getByLabel("Thursday", { exact: true }).click();
await page.getByLabel("Friday", { exact: true }).click();
await page.getByLabel("Saturday", { exact: true }).click();
await page.getByRole("heading", { name: "Berichte" }).click();
await page.getByRole("button", { name: "Alle Quellen" }).click();
await page.getByRole("button", { name: "Alle Quellen" }).click();
await page.getByRole("cell", { name: "Prio" }).click();
await page.getByRole("cell", { name: "Zeitstempel" }).click();
await page.getByRole("cell", { name: "Quelle" }).click();
await page.getByRole("cell", { name: "Meldung" }).click();
await page.getByRole("cell", { name: "Status" }).click();
await expect(
page.getByRole("row", { name: "05.09.2025, 11:52:44" }).locator("div")
).toBeVisible();
await expect(
page
.getByRole("row", { name: "05.09.2025, 11:51:14" })
.getByRole("cell")
.first()
).toBeVisible();
});

View File

@@ -1,124 +0,0 @@
import type { Page } from "@playwright/test";
import { highlightAndExpectVisible } from "@playwright/utils/highlight";
import { navTest } from "@/playwright/tests/components/navigation/navTest";
import { headerTest } from "@/playwright/tests/components/header/headerTest";
import { footerTest } from "@/playwright/tests/components/footer/footerTest";
export async function runMeldungenTest(page: Page) {
await page.goto("/meldungen");
//----------------------
await headerTest(page);
await navTest(page);
await footerTest(page);
await page.waitForTimeout(400);
//----------------------
// Berichte Heading
const berichteHeading = page.getByRole("heading", { name: "Berichte" });
await highlightAndExpectVisible(page, berichteHeading);
await berichteHeading.click();
await page.waitForTimeout(100);
// Von
const vonText = page.getByText("Von");
await highlightAndExpectVisible(page, vonText);
await vonText.click();
await page.waitForTimeout(50);
const vonTextbox = page
.locator("div")
.filter({ hasText: /^Von$/ })
.getByRole("textbox");
await highlightAndExpectVisible(page, vonTextbox);
await vonTextbox.click();
await page.waitForTimeout(50);
/* const julyDate = page
.getByLabel("Choose Date")
.locator("div")
.filter({ hasText: "July" })
.first();
await highlightAndExpectVisible(page, julyDate);
await expect(julyDate).toBeVisible(); */
await page.waitForTimeout(50);
await vonTextbox.click();
await page.waitForTimeout(50);
const bisTextbox = page
.locator("div")
.filter({ hasText: /^Bis$/ })
.getByRole("textbox");
await highlightAndExpectVisible(page, bisTextbox);
await bisTextbox.click();
await page.waitForTimeout(50);
/* const augustDate = page
.getByLabel("Choose Date")
.locator("div")
.filter({ hasText: "August" })
.first();
await highlightAndExpectVisible(page, augustDate);
await expect(augustDate).toBeVisible();
await page.waitForTimeout(50); */
await bisTextbox.click();
await page.waitForTimeout(50);
await highlightAndExpectVisible(page, berichteHeading);
await berichteHeading.click();
await page.waitForTimeout(50);
// Buttons sichtbar
/* const anzeigenBtn = page.getByRole("button", { name: "Anzeigen" });
await highlightAndExpectVisible(page, anzeigenBtn);
await expect(anzeigenBtn).toBeVisible();
await page.waitForTimeout(50); */
const alleQuellenBtn = page.getByRole("button", { name: "Alle Quellen" });
await highlightAndExpectVisible(page, alleQuellenBtn);
// await expect(alleQuellenBtn).toBeVisible();
await alleQuellenBtn.click();
await page.waitForTimeout(50);
await alleQuellenBtn.click();
await page.waitForTimeout(50);
// Tabellenzellen
const tableCells = [
page.getByRole("cell", { name: "Prio" }),
page.getByRole("cell", { name: "Zeitstempel" }),
page.getByRole("cell", { name: "Quelle" }),
page.getByRole("cell", { name: "Meldung" }),
page.getByRole("cell", { name: "Status" }),
];
for (const cell of tableCells) {
await highlightAndExpectVisible(page, cell);
await cell.click();
await page.waitForTimeout(30);
}
// Interact with the first few data rows generically instead of hardcoded timestamps
const table = page.locator("table");
await table.first().waitFor({ state: "visible", timeout: 15000 });
const rows = table.locator("tbody tr");
const rowCount = await rows.count();
const maxRows = Math.min(5, rowCount);
for (let i = 0; i < maxRows; i++) {
const row = rows.nth(i);
const firstCell = row.locator("td").first();
await highlightAndExpectVisible(page, firstCell);
await firstCell.click();
// click a couple of other cells if present
const secondCell = row.locator("td").nth(1);
if (await secondCell.count()) {
await highlightAndExpectVisible(page, secondCell);
await secondCell.click();
}
const thirdCell = row.locator("td").nth(2);
if (await thirdCell.count()) {
await highlightAndExpectVisible(page, thirdCell);
await thirdCell.click();
}
await page.waitForTimeout(20);
}
}