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,141 @@
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("Einstellungen", async ({ page }) => {
await page.goto("/einstellungen");
// Gemeinsame Layout-Checks
await headerTest(page);
await navTest(page);
await footerTest(page);
await page.getByRole("button", { name: "Allgemeine Einstellungen" }).click();
await expect(
page.getByRole("heading", { name: "Allgemeine Einstellungen" })
).toBeVisible();
await expect(page.getByText("Name:")).toBeVisible();
await expect(
page
.locator("div")
.filter({ hasText: /^Name:$/ })
.getByRole("textbox")
).toBeVisible();
await expect(page.getByText("MAC Adresse 1:")).toBeVisible();
await expect(
page
.locator("div")
.filter({ hasText: /^MAC Adresse 1:$/ })
.getByRole("textbox")
).toHaveValue("0 48 86 81 46 143");
await expect(page.getByText("Systemzeit:")).toBeVisible();
await expect(
page
.locator("div")
.filter({ hasText: /^Systemzeit übernehmen$/ })
.getByRole("textbox")
).toHaveValue("23.10.24 15:10:28");
await expect(
page.getByRole("button", { name: "Systemzeit übernehmen" })
).toBeVisible();
await expect(page.getByText("IP:")).toBeVisible();
await expect(
page.locator("div").filter({ hasText: /^IP:$/ }).getByRole("textbox")
).toBeVisible();
await expect(page.getByText("Subnet:")).toBeVisible();
await expect(
page
.locator("div")
.filter({ hasText: /^Subnet:$/ })
.getByRole("textbox")
).toBeVisible();
await expect(page.getByText("Gateway:")).toBeVisible();
await expect(
page
.locator("div")
.filter({ hasText: /^Gateway:$/ })
.getByRole("textbox")
).toBeVisible();
await expect(
page.getByRole("button", { name: "Neustart CPL" })
).toBeVisible();
await expect(page.getByRole("button", { name: "Speichern" })).toBeVisible();
await page.getByRole("button", { name: "OPCUA" }).click();
await expect(
page.getByRole("img", { name: "OPCUA Logo" }).first()
).toBeVisible();
await expect(
page.getByRole("img", { name: "OPCUA Logo" }).nth(1)
).toBeVisible();
await expect(page.getByText("Server Status:")).toBeVisible();
await expect(page.getByRole("button", { name: "Aktiviert" })).toBeVisible();
await expect(page.getByText("1")).toBeVisible();
await expect(page.getByText("Nodeset Name")).toBeVisible();
await expect(page.getByText("OPCUA Zustand")).toBeVisible();
await expect(page.getByRole("textbox")).toHaveValue(
"CPL V4 OPC UA Application Deutsche Bahn"
);
await expect(page.getByText("Aktuelle OPC-Clients")).toBeVisible();
await expect(page.getByText("0", { exact: true })).toBeVisible();
await page.getByRole("button", { name: "Datenbank" }).click();
await expect(
page.getByRole("heading", { name: "Datenbank Einstellungen" })
).toBeVisible();
await expect(
page.getByRole("button", { name: "Meldungen löschen" })
).toBeVisible();
await expect(
page.getByRole("button", { name: "Messwerte Logger löschen" })
).toBeVisible();
await page.getByRole("button", { name: "NTP" }).click();
await expect(
page.getByRole("heading", { name: "NTP Einstellungen" })
).toBeVisible();
await expect(page.getByText("NTP Server 1")).toBeVisible();
await expect(
page
.locator("div")
.filter({ hasText: /^NTP Server 1$/ })
.getByRole("textbox")
).toBeVisible();
await expect(page.getByText("NTP Server 2")).toBeVisible();
await expect(
page
.locator("div")
.filter({ hasText: /^NTP Server 2$/ })
.getByRole("textbox")
).toBeVisible();
await expect(page.getByText("NTP Server 3")).toBeVisible();
await expect(
page
.locator("div")
.filter({ hasText: /^NTP Server 3$/ })
.getByRole("textbox")
).toBeVisible();
await expect(page.getByText("Zeitzone")).toBeVisible();
await expect(
page
.locator("div")
.filter({ hasText: /^Zeitzone$/ })
.getByRole("textbox")
).toBeVisible();
await expect(page.getByText("NTP aktiv:")).toBeVisible();
await expect(page.getByRole("button", { name: "Speichern" })).toBeVisible();
await page.getByRole("button", { name: "Benutzerverwaltung" }).click();
await expect(
page.getByRole("heading", { name: "Login Admin-Bereich" })
).toBeVisible();
await expect(
page.getByRole("textbox", { name: "Benutzername" })
).toBeVisible();
await expect(page.getByRole("textbox", { name: "Passwort" })).toBeVisible();
await expect(
page.getByRole("button", { name: "Admin anmelden" })
).toBeVisible();
});

View File

@@ -1,175 +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 runSettingsPageTest(page: Page) {
await page.goto("/einstellungen");
//----------------------
await headerTest(page);
await navTest(page);
await footerTest(page);
await page.waitForTimeout(400);
//----------------------
//await page.getByRole("button").filter({ hasText: /^$/ }).click();
await page.getByRole("button", { name: "Allgemeine Einstellungen" }).click();
await highlightAndExpectVisible(
page,
page.getByRole("button", { name: "Allgemeine Einstellungen" })
);
await highlightAndExpectVisible(
page,
page.getByRole("heading", { name: "Allgemeine Einstellungen" })
);
await highlightAndExpectVisible(page, page.getByText("Name:"));
await highlightAndExpectVisible(
page,
page
.locator("div")
.filter({ hasText: /^Name:$/ })
.getByRole("textbox")
);
await highlightAndExpectVisible(page, page.getByText("MAC Adresse 1:"));
await highlightAndExpectVisible(
page,
page.getByRole("button", { name: "Systemzeit übernehmen" })
);
await highlightAndExpectVisible(page, page.getByText("IP:"));
await highlightAndExpectVisible(
page,
page.locator("div").filter({ hasText: /^IP:$/ }).getByRole("textbox")
);
await highlightAndExpectVisible(page, page.getByText("Subnet:"));
await highlightAndExpectVisible(
page,
page
.locator("div")
.filter({ hasText: /^Subnet:$/ })
.getByRole("textbox")
);
await highlightAndExpectVisible(page, page.getByText("Gateway:"));
await highlightAndExpectVisible(
page,
page
.locator("div")
.filter({ hasText: /^Gateway:$/ })
.getByRole("textbox")
);
await highlightAndExpectVisible(
page,
page.getByRole("button", { name: "Neustart CPL" })
);
await highlightAndExpectVisible(
page,
page.getByRole("button", { name: "Speichern" })
);
await page.getByRole("button", { name: "OPCUA" }).click();
await highlightAndExpectVisible(
page,
page.getByRole("img", { name: "OPCUA Logo" }).first()
);
await highlightAndExpectVisible(
page,
page.getByRole("img", { name: "OPCUA Logo" }).nth(1)
);
await highlightAndExpectVisible(page, page.getByText("Server Status:"));
await highlightAndExpectVisible(
page,
page.getByRole("button", { name: "Aktiviert" })
);
await highlightAndExpectVisible(page, page.getByText("OPCUA Zustand"));
await highlightAndExpectVisible(page, page.getByText("1"));
await highlightAndExpectVisible(page, page.getByText("Nodeset Name"));
await highlightAndExpectVisible(page, page.getByText("Aktuelle OPC-Clients"));
await highlightAndExpectVisible(page, page.getByText("0", { exact: true }));
await page.getByRole("button", { name: "Datenbank" }).click();
await highlightAndExpectVisible(
page,
page.getByRole("heading", { name: "Datenbank Einstellungen" })
);
await highlightAndExpectVisible(
page,
page.getByRole("button", { name: "Meldungen löschen" })
);
await highlightAndExpectVisible(
page,
page.getByRole("button", { name: "Messwerte Logger löschen" })
);
await page.getByRole("button", { name: "NTP" }).click();
await highlightAndExpectVisible(
page,
page.getByRole("heading", { name: "NTP Einstellungen" })
);
await highlightAndExpectVisible(page, page.getByText("NTP Server 1"));
await highlightAndExpectVisible(
page,
page
.locator("div")
.filter({ hasText: /^NTP Server 1$/ })
.getByRole("textbox")
);
await highlightAndExpectVisible(page, page.getByText("NTP Server 3"));
await highlightAndExpectVisible(
page,
page
.locator("div")
.filter({ hasText: /^NTP Server 3$/ })
.getByRole("textbox")
);
await highlightAndExpectVisible(page, page.getByText("NTP Server 2"));
await highlightAndExpectVisible(
page,
page
.locator("div")
.filter({ hasText: /^NTP Server 2$/ })
.getByRole("textbox")
);
await highlightAndExpectVisible(page, page.getByText("Zeitzone"));
await highlightAndExpectVisible(
page,
page
.locator("div")
.filter({ hasText: /^Zeitzone$/ })
.getByRole("textbox")
);
await highlightAndExpectVisible(page, page.getByText("NTP aktiv:"));
await highlightAndExpectVisible(page, page.getByRole("checkbox"));
await highlightAndExpectVisible(
page,
page.getByRole("button", { name: "Speichern" })
);
await page.getByRole("button", { name: "Benutzerverwaltung" }).click();
await highlightAndExpectVisible(
page,
page.getByRole("heading", { name: "Login Admin-Bereich" })
);
await highlightAndExpectVisible(
page,
page.getByRole("textbox", { name: "Benutzername" })
);
await highlightAndExpectVisible(
page,
page.getByRole("textbox", { name: "Passwort" })
);
await highlightAndExpectVisible(
page,
page.getByRole("button", { name: "Admin anmelden" })
);
await page.getByRole("textbox", { name: "Benutzername" }).click();
await page.getByRole("textbox", { name: "Benutzername" }).fill("admin");
await page.getByRole("textbox", { name: "Passwort" }).click();
await page.getByRole("textbox", { name: "Passwort" }).fill("admin");
await page.getByRole("button", { name: "Admin anmelden" }).click();
await highlightAndExpectVisible(page, page.getByText("Login erfolgreich!"));
await highlightAndExpectVisible(
page,
page.getByRole("button", { name: "Abmelden" })
);
await highlightAndExpectVisible(
page,
page.getByRole("button", { name: "Admin anmelden" })
);
}
//---------------------------------------------------------------------