fix: all.test.ts

This commit is contained in:
ISA
2025-08-29 13:47:23 +02:00
parent 6df31455a9
commit 8850b0ffda
10 changed files with 180 additions and 82 deletions

View File

@@ -6,6 +6,6 @@ NEXT_PUBLIC_USE_MOCK_BACKEND_LOOP_START=false
NEXT_PUBLIC_EXPORT_STATIC=false NEXT_PUBLIC_EXPORT_STATIC=false
NEXT_PUBLIC_USE_CGI=false NEXT_PUBLIC_USE_CGI=false
# App-Versionsnummer # App-Versionsnummer
NEXT_PUBLIC_APP_VERSION=1.6.780 NEXT_PUBLIC_APP_VERSION=1.6.781
NEXT_PUBLIC_CPL_MODE=json # json (Entwicklungsumgebung) oder jsSimulatedProd (CPL ->CGI-Interface-Simulator) oder production (CPL-> CGI-Interface Platzhalter) NEXT_PUBLIC_CPL_MODE=json # json (Entwicklungsumgebung) oder jsSimulatedProd (CPL ->CGI-Interface-Simulator) oder production (CPL-> CGI-Interface Platzhalter)

View File

@@ -5,5 +5,5 @@ NEXT_PUBLIC_CPL_API_PATH=/CPL
NEXT_PUBLIC_EXPORT_STATIC=true NEXT_PUBLIC_EXPORT_STATIC=true
NEXT_PUBLIC_USE_CGI=true NEXT_PUBLIC_USE_CGI=true
# App-Versionsnummer # App-Versionsnummer
NEXT_PUBLIC_APP_VERSION=1.6.780 NEXT_PUBLIC_APP_VERSION=1.6.781
NEXT_PUBLIC_CPL_MODE=production NEXT_PUBLIC_CPL_MODE=production

View File

@@ -1,3 +1,8 @@
## [1.6.781] 2025-08-29
- test: systemTest.ts
---
## [1.6.780] 2025-08-29 ## [1.6.780] 2025-08-29
- Headless wird sicher erzwungen (auch wenn lokal anders). - Headless wird sicher erzwungen (auch wenn lokal anders).

4
package-lock.json generated
View File

@@ -1,12 +1,12 @@
{ {
"name": "cpl-v4", "name": "cpl-v4",
"version": "1.6.780", "version": "1.6.781",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "cpl-v4", "name": "cpl-v4",
"version": "1.6.780", "version": "1.6.781",
"dependencies": { "dependencies": {
"@fontsource/roboto": "^5.1.0", "@fontsource/roboto": "^5.1.0",
"@headlessui/react": "^2.2.4", "@headlessui/react": "^2.2.4",

View File

@@ -1,6 +1,6 @@
{ {
"name": "cpl-v4", "name": "cpl-v4",
"version": "1.6.780", "version": "1.6.781",
"private": true, "private": true,
"scripts": { "scripts": {
"dev": "next dev", "dev": "next dev",

View File

@@ -4,7 +4,7 @@ const CI = !!process.env.CI;
export default defineConfig({ export default defineConfig({
testDir: "./playwright/tests", testDir: "./playwright/tests",
timeout: 90_000, timeout: 300_000,
expect: { timeout: 15_000 }, expect: { timeout: 15_000 },
globalSetup: "./playwright/global-setup", globalSetup: "./playwright/global-setup",

View File

@@ -5,15 +5,16 @@ import { runDigitalInputsTest } from "./pages/digitalInputsTest";
import { runDigitalOutputsTest } from "./pages/digitalOutputsTest"; import { runDigitalOutputsTest } from "./pages/digitalOutputsTest";
import { runAnalogInputsTest } from "./pages/analogInputsTest"; import { runAnalogInputsTest } from "./pages/analogInputsTest";
import { runMeldungenTest } from "./pages/meldungenTest"; import { runMeldungenTest } from "./pages/meldungenTest";
import { runSystemTest } from "./pages/systemTest";
import { runSettingsPageTest } from "./pages/settingsPageTest"; import { runSettingsPageTest } from "./pages/settingsPageTest";
test("Dashboard, AnalogInputs und SettingsPage", async ({ page }) => { test("Dashboard, AnalogInputs und SettingsPage", async ({ page }) => {
// await runDashboardTest(page); await runDashboardTest(page);
// await runCableMonitoringTest(page); await runCableMonitoringTest(page);
//await runDigitalInputsTest(page); await runDigitalInputsTest(page);
//await runDigitalOutputsTest(page); await runDigitalOutputsTest(page);
//await runAnalogInputsTest(page); await runAnalogInputsTest(page);
await runMeldungenTest(page); await runMeldungenTest(page);
//await runSettingsPageTest(page); await runSystemTest(page);
await runSettingsPageTest(page);
}); });

View File

@@ -1,4 +1,5 @@
import type { Page } from "@playwright/test"; import type { Page } from "@playwright/test";
import { expect } from "@playwright/test";
import { highlightAndExpectVisible } from "../utils/highlight"; import { highlightAndExpectVisible } from "../utils/highlight";
// Kombinierte Helper-Funktion: injiziert CSS (nur einmal), hebt hervor und prüft Sichtbarkeit // Kombinierte Helper-Funktion: injiziert CSS (nur einmal), hebt hervor und prüft Sichtbarkeit
@@ -61,13 +62,15 @@ export async function runAnalogInputsTest(page: Page) {
page, page,
page.getByRole("cell", { name: "7", exact: true }) page.getByRole("cell", { name: "7", exact: true })
); );
await page.waitForTimeout(1000); await expect(
page.getByRole("cell", { name: "8", exact: true })
).toBeVisible();
await highlightAndExpectVisible( await highlightAndExpectVisible(
page, page,
page.getByRole("cell", { name: "8", exact: true }) page.getByRole("cell", { name: "8", exact: true })
); );
await page.waitForTimeout(1000); await expect(page.locator(".border.p-2.text-center").first()).toBeVisible();
await highlightAndExpectVisible( await highlightAndExpectVisible(
page, page,
@@ -75,8 +78,6 @@ export async function runAnalogInputsTest(page: Page) {
); );
// Markiere die gesamte erste Datenzeile (Row mit "AE 1" falls vorhanden) // Markiere die gesamte erste Datenzeile (Row mit "AE 1" falls vorhanden)
await page.waitForTimeout(1000);
await highlightAndExpectVisible( await highlightAndExpectVisible(
page, page,
page page
@@ -84,13 +85,18 @@ export async function runAnalogInputsTest(page: Page) {
.getByRole("button") .getByRole("button")
.first() .first()
); );
await page.waitForTimeout(1000); await expect(page.locator("tr:nth-child(3) > td:nth-child(5)")).toBeVisible();
await highlightAndExpectVisible( await highlightAndExpectVisible(
page, page,
page.locator("tr:nth-child(3) > td:nth-child(5)") page.locator("tr:nth-child(3) > td:nth-child(5)")
); );
await page.waitForTimeout(1000); await expect(
page
.getByRole("row", { name: "0.01 V AE 4 Messkurve anzeigen" })
.getByRole("button")
.first()
).toBeVisible();
await highlightAndExpectVisible( await highlightAndExpectVisible(
page, page,
@@ -99,7 +105,11 @@ export async function runAnalogInputsTest(page: Page) {
.getByRole("button") .getByRole("button")
.first() .first()
); );
await page.waitForTimeout(1000); await expect(
page
.getByRole("row", { name: "8 -0.00 mA AE 8 Messkurve" })
.getByLabel("Messkurve anzeigen")
).toBeVisible();
await highlightAndExpectVisible( await highlightAndExpectVisible(
page, page,
@@ -107,11 +117,14 @@ export async function runAnalogInputsTest(page: Page) {
.getByRole("row", { name: "8 -0.00 mA AE 8 Messkurve" }) .getByRole("row", { name: "8 -0.00 mA AE 8 Messkurve" })
.getByLabel("Messkurve anzeigen") .getByLabel("Messkurve anzeigen")
); );
await page.waitForTimeout(1000);
await page.getByRole("cell", { name: "1", exact: true }).click(); await page.getByRole("cell", { name: "1", exact: true }).click();
await expect(page.locator(".border.p-2.text-center").first()).toBeVisible();
await page.locator(".border.p-2.text-center").first().click(); await page.locator(".border.p-2.text-center").first().click();
await expect(
page.getByRole("heading", { name: "Einstellungen Messwerteingang" })
).toBeVisible();
await highlightAndExpectVisible( await highlightAndExpectVisible(
page, page,
@@ -128,13 +141,19 @@ export async function runAnalogInputsTest(page: Page) {
page, page,
page.getByRole("button", { name: "Speichern" }) page.getByRole("button", { name: "Speichern" })
); );
await page.waitForTimeout(1000); await expect(
page.getByRole("button", { name: "Modal schließen" })
).toBeVisible();
await highlightAndExpectVisible( await highlightAndExpectVisible(
page, page,
page.getByRole("button", { name: "Modal schließen" }) page.getByRole("button", { name: "Modal schließen" })
); );
await page.waitForTimeout(1000); await expect(
page.getByText(
"Einstellungen Messwerteingang 1Bezeichnung:Offset:Faktor:Einheit:"
)
).toBeVisible();
await highlightAndExpectVisible( await highlightAndExpectVisible(
page, page,
@@ -142,14 +161,23 @@ export async function runAnalogInputsTest(page: Page) {
"Einstellungen Messwerteingang 1Bezeichnung:Offset:Faktor:Einheit:" "Einstellungen Messwerteingang 1Bezeichnung:Offset:Faktor:Einheit:"
) )
); );
await page.waitForTimeout(1000);
await page.getByRole("button", { name: "Modal schließen" }).click(); await page.getByRole("button", { name: "Modal schließen" }).click();
await expect(
page
.getByRole("row", { name: "1 126.63 V AE 1 Messkurve" })
.getByLabel("Messkurve anzeigen")
).toBeVisible();
await page await page
.getByRole("row", { name: "1 126.63 V AE 1 Messkurve" }) .getByRole("row", { name: "1 126.63 V AE 1 Messkurve" })
.getByLabel("Messkurve anzeigen") .getByLabel("Messkurve anzeigen")
.click(); .click();
await expect(
page.getByText(
"Messkurve Messwerteingang 1Eingang 1VonBisAlle MesswerteDaten laden"
)
).toBeVisible();
await highlightAndExpectVisible( await highlightAndExpectVisible(
page, page,
@@ -172,72 +200,42 @@ export async function runAnalogInputsTest(page: Page) {
page.getByRole("button", { name: "Daten laden" }) page.getByRole("button", { name: "Daten laden" })
); );
await highlightAndExpectVisible(
page,
page.getByRole("button", { name: "Alle Messwerte " })
);
await highlightAndExpectVisible(page, page.getByText("Von"));
await highlightAndExpectVisible(page, page.getByText("Bis"));
await highlightAndExpectVisible(
page,
page.locator("div").filter({ hasText: /^Von$/ })
);
await highlightAndExpectVisible(
page,
page.locator("div").filter({ hasText: /^Von$/ }).getByRole("textbox")
);
await page.waitForTimeout(1000);
await highlightAndExpectVisible(
page,
page.locator("div").filter({ hasText: /^Bis$/ })
);
await page.waitForTimeout(1000);
await highlightAndExpectVisible(
page,
page.locator("div").filter({ hasText: /^Bis$/ }).getByRole("textbox")
);
await page.waitForTimeout(1000);
await highlightAndExpectVisible(page, page.getByRole("img"));
await page.waitForTimeout(1000);
await highlightAndExpectVisible( await highlightAndExpectVisible(
page, page,
page.getByRole("button", { name: "Alle Messwerte " }) page.getByRole("button", { name: "Alle Messwerte " })
); );
await page.getByRole("button", { name: "Alle Messwerte " }).click(); await page.getByRole("button", { name: "Alle Messwerte " }).click();
await page.waitForTimeout(1000); await expect(page.getByRole("option", { name: "Stündlich" })).toBeVisible();
await page.getByRole("option", { name: "Stündlich" }).click(); await page.getByRole("option", { name: "Stündlich" }).click();
await page.waitForTimeout(1000); await expect(page.getByRole("button", { name: "Stündlich" })).toBeVisible();
await page.getByRole("button", { name: "Stündlich" }).click(); await page.getByRole("button", { name: "Stündlich" }).click();
await page.waitForTimeout(1000); await expect(page.getByRole("option", { name: "Täglich" })).toBeVisible();
await page.getByRole("option", { name: "Täglich" }).click(); await page.getByRole("option", { name: "Täglich" }).click();
await page.waitForTimeout(1000); await expect(page.getByRole("button", { name: "Fullscreen" })).toBeVisible();
await page.getByRole("button", { name: "Fullscreen" }).click(); await page.getByRole("button", { name: "Fullscreen" }).click();
await expect(
page.getByRole("button", { name: "Exit fullscreen" })
).toBeVisible();
await page.getByRole("button", { name: "Exit fullscreen" }).click(); await page.getByRole("button", { name: "Exit fullscreen" }).click();
await expect(page.getByRole("button", { name: "Fullscreen" })).toBeVisible();
await highlightAndExpectVisible( await highlightAndExpectVisible(
page, page,
page.getByRole("button", { name: "Fullscreen" }) page.getByRole("button", { name: "Fullscreen" })
); );
await highlightAndExpectVisible( // Modal schließen nur, wenn noch vorhanden
page, const modalCloseBtn = page.getByRole("button", { name: "Modal schließen" });
page.getByRole("button", { name: "Modal schließen" }) if ((await modalCloseBtn.count()) > 0 && (await modalCloseBtn.isVisible())) {
); await highlightAndExpectVisible(page, modalCloseBtn);
await page.waitForTimeout(1000); await expect(modalCloseBtn).toBeVisible();
await modalCloseBtn.click();
}
await page.getByRole("button", { name: "Modal schließen" }).click();
// ...dein AnalogInputs-Testcode... // ...dein AnalogInputs-Testcode...
} }

View File

@@ -4,6 +4,8 @@ import { expect } from "@playwright/test";
export async function runMeldungenTest(page: Page) { export async function runMeldungenTest(page: Page) {
await page.goto("/meldungen"); await page.goto("/meldungen");
// Warte gezielt auf das Logo, um Server-Latenz abzufangen
await page.waitForSelector('img[alt="Logo"]', { timeout: 15000 });
// Logo // Logo
const logo = page.getByRole("img", { name: "Logo", exact: true }); const logo = page.getByRole("img", { name: "Logo", exact: true });
@@ -35,7 +37,7 @@ export async function runMeldungenTest(page: Page) {
await expect(darkModeBtn).toBeVisible(); await expect(darkModeBtn).toBeVisible();
await page.waitForTimeout(100); await page.waitForTimeout(100);
// Sidebar Links sichtbar // Sidebar Links sichtbar (wie in den anderen Tests, kein explizites Sidebar-Handling)
const sidebarLinks = [ const sidebarLinks = [
{ role: "link", name: "Übersicht" }, { role: "link", name: "Übersicht" },
{ role: "link", name: "Kabelüberwachung" }, { role: "link", name: "Kabelüberwachung" },
@@ -53,6 +55,13 @@ export async function runMeldungenTest(page: Page) {
await page.waitForTimeout(50); await page.waitForTimeout(50);
} }
for (const link of sidebarLinks) {
const locator = page.getByRole(link.role as any, { name: link.name });
await highlightAndExpectVisible(page, locator);
await expect(locator).toBeVisible();
await page.waitForTimeout(50);
}
// Berichte Heading // Berichte Heading
const berichteHeading = page.getByRole("heading", { name: "Berichte" }); const berichteHeading = page.getByRole("heading", { name: "Berichte" });
await highlightAndExpectVisible(page, berichteHeading); await highlightAndExpectVisible(page, berichteHeading);
@@ -196,6 +205,8 @@ export async function highlightAndExpectVisible(
}); });
} }
// Erst prüfen, ob das Element sichtbar ist, sonst bricht der Test sauber ab
await expect(locator).toBeVisible({ timeout: 10000 });
const els = await locator.elementHandles(); const els = await locator.elementHandles();
for (const el of els) { for (const el of els) {
await el.evaluate((node: unknown, ms: number) => { await el.evaluate((node: unknown, ms: number) => {

View File

@@ -29,14 +29,103 @@ export async function runSystemTest(page: Page) {
await cplv4Text.click(); await cplv4Text.click();
await page.waitForTimeout(100); await page.waitForTimeout(100);
// Dark Mode Button sichtbar // System Spannungen &
const darkModeBtn = page.getByRole("button", { name: "Dark Mode" }); const systemSpannung = page.getByRole("heading", {
await highlightAndExpectVisible(page, darkModeBtn); name: "System Spannungen &",
await expect(darkModeBtn).toBeVisible(); });
await highlightAndExpectVisible(page, systemSpannung);
await systemSpannung.click();
await page.waitForTimeout(100);
// +15V
const plus15V = page.getByRole("heading", { name: "+15V" });
await highlightAndExpectVisible(page, plus15V);
await plus15V.click();
await page.waitForTimeout(100);
// 15.06 VDetailansicht
const v15Detail = page.getByText("15.06 VDetailansicht");
await highlightAndExpectVisible(page, v15Detail);
await v15Detail.click();
await page.waitForTimeout(100);
// +5V
const plus5V = page.getByRole("heading", { name: "+5V" });
await highlightAndExpectVisible(page, plus5V);
await plus5V.click();
await page.waitForTimeout(100);
// 4.98 VDetailansicht
const v5Detail = page.getByText("4.98 VDetailansicht");
await highlightAndExpectVisible(page, v5Detail);
await v5Detail.click();
await page.waitForTimeout(100);
// -15V
const minus15V = page.getByRole("heading", { name: "-15V" });
await highlightAndExpectVisible(page, minus15V);
await minus15V.click();
await page.waitForTimeout(100);
// -15.09 VDetailansicht
const vMinus15Detail = page.getByText("-15.09 VDetailansicht");
await highlightAndExpectVisible(page, vMinus15Detail);
await vMinus15Detail.click();
await page.waitForTimeout(100);
// -98V
const minus98V = page.getByRole("heading", { name: "-98V" });
await highlightAndExpectVisible(page, minus98V);
await minus98V.click();
await page.waitForTimeout(100);
// -96.48 VDetailansicht
const vMinus98Detail = page.getByText("-96.48 VDetailansicht");
await highlightAndExpectVisible(page, vMinus98Detail);
await vMinus98Detail.click();
await page.waitForTimeout(100);
// ADC Temp
const adcTemp = page.getByRole("heading", { name: "ADC Temp" });
await highlightAndExpectVisible(page, adcTemp);
await adcTemp.click();
await page.waitForTimeout(100);
// 59.78 °CDetailansicht
const adcTempDetail = page.getByText("59.78 °CDetailansicht");
await highlightAndExpectVisible(page, adcTempDetail);
await adcTempDetail.click();
await page.waitForTimeout(100);
// CPU Temp
const cpuTemp = page.getByRole("heading", { name: "CPU Temp" });
await highlightAndExpectVisible(page, cpuTemp);
await cpuTemp.click();
await page.waitForTimeout(100);
await highlightAndExpectVisible(page, cpuTemp);
await cpuTemp.click();
await page.waitForTimeout(100);
// 56.92 °CDetailansicht
const cpuTempDetail = page.getByText("56.92 °CDetailansicht");
await highlightAndExpectVisible(page, cpuTempDetail);
await cpuTempDetail.click();
await page.waitForTimeout(100);
// img nth(2)
const img2 = page.getByRole("img").nth(2);
await highlightAndExpectVisible(page, img2);
await img2.click({ position: { x: 72, y: 53 } });
await page.waitForTimeout(100);
// img nth(3)
const img3 = page.getByRole("img").nth(3);
await highlightAndExpectVisible(page, img3);
await img3.click({ position: { x: 272, y: 93 } });
await page.waitForTimeout(100); await page.waitForTimeout(100);
// Sidebar Links sichtbar // Sidebar Links sichtbar
const sidebarLinks = [ const sidebarLinks2 = [
{ role: "link", name: "Übersicht" }, { role: "link", name: "Übersicht" },
{ role: "link", name: "Kabelüberwachung" }, { role: "link", name: "Kabelüberwachung" },
{ role: "link", name: "Meldungseingänge" }, { role: "link", name: "Meldungseingänge" },
@@ -46,18 +135,12 @@ export async function runSystemTest(page: Page) {
{ role: "link", name: "System" }, { role: "link", name: "System" },
{ role: "link", name: "Einstellungen" }, { role: "link", name: "Einstellungen" },
]; ];
for (const link of sidebarLinks) { for (const link of sidebarLinks2) {
const locator = page.getByRole(link.role as any, { name: link.name }); const locator = page.getByRole(link.role as any, { name: link.name });
await highlightAndExpectVisible(page, locator); await highlightAndExpectVisible(page, locator);
await expect(locator).toBeVisible(); await expect(locator).toBeVisible();
await page.waitForTimeout(50); await page.waitForTimeout(50);
} }
// Berichte Heading
const berichteHeading = page.getByRole("heading", { name: "Berichte" });
await highlightAndExpectVisible(page, berichteHeading);
await berichteHeading.click();
await page.waitForTimeout(100);
} }
//--------------------------------------------------------------------- //---------------------------------------------------------------------