From 8850b0ffda008cf4b3934c1033814b9a7980fc8e Mon Sep 17 00:00:00 2001 From: ISA Date: Fri, 29 Aug 2025 13:47:23 +0200 Subject: [PATCH] fix: all.test.ts --- .env.development | 2 +- .env.production | 2 +- CHANGELOG.md | 5 + package-lock.json | 4 +- package.json | 2 +- playwright.config.ts | 2 +- playwright/tests/all.test.ts | 15 +-- playwright/tests/pages/analogInputsTest.ts | 110 ++++++++++----------- playwright/tests/pages/meldungenTest.ts | 13 ++- playwright/tests/pages/systemTest.ts | 107 +++++++++++++++++--- 10 files changed, 180 insertions(+), 82 deletions(-) diff --git a/.env.development b/.env.development index aa0e3f1..f3ceceb 100644 --- a/.env.development +++ b/.env.development @@ -6,6 +6,6 @@ NEXT_PUBLIC_USE_MOCK_BACKEND_LOOP_START=false NEXT_PUBLIC_EXPORT_STATIC=false NEXT_PUBLIC_USE_CGI=false # 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) diff --git a/.env.production b/.env.production index d535e57..d389f54 100644 --- a/.env.production +++ b/.env.production @@ -5,5 +5,5 @@ NEXT_PUBLIC_CPL_API_PATH=/CPL NEXT_PUBLIC_EXPORT_STATIC=true NEXT_PUBLIC_USE_CGI=true # App-Versionsnummer -NEXT_PUBLIC_APP_VERSION=1.6.780 +NEXT_PUBLIC_APP_VERSION=1.6.781 NEXT_PUBLIC_CPL_MODE=production \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index e68b122..32747eb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## [1.6.781] – 2025-08-29 + +- test: systemTest.ts + +--- ## [1.6.780] – 2025-08-29 - Headless wird sicher erzwungen (auch wenn lokal anders). diff --git a/package-lock.json b/package-lock.json index f32ca46..2562aa5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "cpl-v4", - "version": "1.6.780", + "version": "1.6.781", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "cpl-v4", - "version": "1.6.780", + "version": "1.6.781", "dependencies": { "@fontsource/roboto": "^5.1.0", "@headlessui/react": "^2.2.4", diff --git a/package.json b/package.json index 00f16f4..d9b04b1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cpl-v4", - "version": "1.6.780", + "version": "1.6.781", "private": true, "scripts": { "dev": "next dev", diff --git a/playwright.config.ts b/playwright.config.ts index 0d06d7b..348ea28 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -4,7 +4,7 @@ const CI = !!process.env.CI; export default defineConfig({ testDir: "./playwright/tests", - timeout: 90_000, + timeout: 300_000, expect: { timeout: 15_000 }, globalSetup: "./playwright/global-setup", diff --git a/playwright/tests/all.test.ts b/playwright/tests/all.test.ts index 741a149..f51a977 100644 --- a/playwright/tests/all.test.ts +++ b/playwright/tests/all.test.ts @@ -5,15 +5,16 @@ import { runDigitalInputsTest } from "./pages/digitalInputsTest"; import { runDigitalOutputsTest } from "./pages/digitalOutputsTest"; import { runAnalogInputsTest } from "./pages/analogInputsTest"; import { runMeldungenTest } from "./pages/meldungenTest"; - +import { runSystemTest } from "./pages/systemTest"; import { runSettingsPageTest } from "./pages/settingsPageTest"; test("Dashboard, AnalogInputs und SettingsPage", async ({ page }) => { - // await runDashboardTest(page); - // await runCableMonitoringTest(page); - //await runDigitalInputsTest(page); - //await runDigitalOutputsTest(page); - //await runAnalogInputsTest(page); + await runDashboardTest(page); + await runCableMonitoringTest(page); + await runDigitalInputsTest(page); + await runDigitalOutputsTest(page); + await runAnalogInputsTest(page); await runMeldungenTest(page); - //await runSettingsPageTest(page); + await runSystemTest(page); + await runSettingsPageTest(page); }); diff --git a/playwright/tests/pages/analogInputsTest.ts b/playwright/tests/pages/analogInputsTest.ts index 13473a5..695ea54 100644 --- a/playwright/tests/pages/analogInputsTest.ts +++ b/playwright/tests/pages/analogInputsTest.ts @@ -1,4 +1,5 @@ import type { Page } from "@playwright/test"; +import { expect } from "@playwright/test"; import { highlightAndExpectVisible } from "../utils/highlight"; // 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.getByRole("cell", { name: "7", exact: true }) ); - await page.waitForTimeout(1000); + await expect( + page.getByRole("cell", { name: "8", exact: true }) + ).toBeVisible(); await highlightAndExpectVisible( page, page.getByRole("cell", { name: "8", exact: true }) ); - await page.waitForTimeout(1000); + await expect(page.locator(".border.p-2.text-center").first()).toBeVisible(); await highlightAndExpectVisible( page, @@ -75,8 +78,6 @@ export async function runAnalogInputsTest(page: Page) { ); // Markiere die gesamte erste Datenzeile (Row mit "AE 1" falls vorhanden) - await page.waitForTimeout(1000); - await highlightAndExpectVisible( page, page @@ -84,13 +85,18 @@ export async function runAnalogInputsTest(page: Page) { .getByRole("button") .first() ); - await page.waitForTimeout(1000); + await expect(page.locator("tr:nth-child(3) > td:nth-child(5)")).toBeVisible(); await highlightAndExpectVisible( page, 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( page, @@ -99,7 +105,11 @@ export async function runAnalogInputsTest(page: Page) { .getByRole("button") .first() ); - await page.waitForTimeout(1000); + await expect( + page + .getByRole("row", { name: "8 -0.00 mA AE 8 Messkurve" }) + .getByLabel("Messkurve anzeigen") + ).toBeVisible(); await highlightAndExpectVisible( page, @@ -107,11 +117,14 @@ export async function runAnalogInputsTest(page: Page) { .getByRole("row", { name: "8 -0.00 mA AE 8 Messkurve" }) .getByLabel("Messkurve anzeigen") ); - await page.waitForTimeout(1000); 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 expect( + page.getByRole("heading", { name: "Einstellungen Messwerteingang" }) + ).toBeVisible(); await highlightAndExpectVisible( page, @@ -128,13 +141,19 @@ export async function runAnalogInputsTest(page: Page) { page, page.getByRole("button", { name: "Speichern" }) ); - await page.waitForTimeout(1000); + await expect( + page.getByRole("button", { name: "Modal schließen" }) + ).toBeVisible(); await highlightAndExpectVisible( page, page.getByRole("button", { name: "Modal schließen" }) ); - await page.waitForTimeout(1000); + await expect( + page.getByText( + "Einstellungen Messwerteingang 1Bezeichnung:Offset:Faktor:Einheit:" + ) + ).toBeVisible(); await highlightAndExpectVisible( page, @@ -142,14 +161,23 @@ export async function runAnalogInputsTest(page: Page) { "Einstellungen Messwerteingang 1Bezeichnung:Offset:Faktor:Einheit:" ) ); - await page.waitForTimeout(1000); 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 .getByRole("row", { name: "1 126.63 V AE 1 Messkurve" }) .getByLabel("Messkurve anzeigen") .click(); + await expect( + page.getByText( + "Messkurve Messwerteingang 1Eingang 1VonBisAlle MesswerteDaten laden" + ) + ).toBeVisible(); await highlightAndExpectVisible( page, @@ -172,72 +200,42 @@ export async function runAnalogInputsTest(page: Page) { 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( page, page.getByRole("button", { name: "Alle Messwerte " }) ); 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.waitForTimeout(1000); + await expect(page.getByRole("button", { name: "Stündlich" })).toBeVisible(); 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.waitForTimeout(1000); + await expect(page.getByRole("button", { name: "Fullscreen" })).toBeVisible(); 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 expect(page.getByRole("button", { name: "Fullscreen" })).toBeVisible(); await highlightAndExpectVisible( page, page.getByRole("button", { name: "Fullscreen" }) ); - await highlightAndExpectVisible( - page, - page.getByRole("button", { name: "Modal schließen" }) - ); - await page.waitForTimeout(1000); + // Modal schließen nur, wenn noch vorhanden + const modalCloseBtn = page.getByRole("button", { name: "Modal schließen" }); + if ((await modalCloseBtn.count()) > 0 && (await modalCloseBtn.isVisible())) { + await highlightAndExpectVisible(page, modalCloseBtn); + await expect(modalCloseBtn).toBeVisible(); + await modalCloseBtn.click(); + } - await page.getByRole("button", { name: "Modal schließen" }).click(); // ...dein AnalogInputs-Testcode... } diff --git a/playwright/tests/pages/meldungenTest.ts b/playwright/tests/pages/meldungenTest.ts index aba7a14..76c435a 100644 --- a/playwright/tests/pages/meldungenTest.ts +++ b/playwright/tests/pages/meldungenTest.ts @@ -4,6 +4,8 @@ import { expect } from "@playwright/test"; export async function runMeldungenTest(page: Page) { await page.goto("/meldungen"); + // Warte gezielt auf das Logo, um Server-Latenz abzufangen + await page.waitForSelector('img[alt="Logo"]', { timeout: 15000 }); // Logo const logo = page.getByRole("img", { name: "Logo", exact: true }); @@ -35,7 +37,7 @@ export async function runMeldungenTest(page: Page) { await expect(darkModeBtn).toBeVisible(); await page.waitForTimeout(100); - // Sidebar Links sichtbar + // Sidebar Links sichtbar (wie in den anderen Tests, kein explizites Sidebar-Handling) const sidebarLinks = [ { role: "link", name: "Übersicht" }, { role: "link", name: "Kabelüberwachung" }, @@ -53,6 +55,13 @@ export async function runMeldungenTest(page: Page) { 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 const berichteHeading = page.getByRole("heading", { name: "Berichte" }); 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(); for (const el of els) { await el.evaluate((node: unknown, ms: number) => { diff --git a/playwright/tests/pages/systemTest.ts b/playwright/tests/pages/systemTest.ts index 4735d2f..fbfe5f5 100644 --- a/playwright/tests/pages/systemTest.ts +++ b/playwright/tests/pages/systemTest.ts @@ -29,14 +29,103 @@ export async function runSystemTest(page: Page) { await cplv4Text.click(); await page.waitForTimeout(100); - // Dark Mode Button sichtbar - const darkModeBtn = page.getByRole("button", { name: "Dark Mode" }); - await highlightAndExpectVisible(page, darkModeBtn); - await expect(darkModeBtn).toBeVisible(); + // System Spannungen & + const systemSpannung = page.getByRole("heading", { + name: "System Spannungen &", + }); + 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); // Sidebar Links sichtbar - const sidebarLinks = [ + const sidebarLinks2 = [ { role: "link", name: "Übersicht" }, { role: "link", name: "Kabelüberwachung" }, { role: "link", name: "Meldungseingänge" }, @@ -46,18 +135,12 @@ export async function runSystemTest(page: Page) { { role: "link", name: "System" }, { 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 }); await highlightAndExpectVisible(page, locator); await expect(locator).toBeVisible(); await page.waitForTimeout(50); } - - // Berichte Heading - const berichteHeading = page.getByRole("heading", { name: "Berichte" }); - await highlightAndExpectVisible(page, berichteHeading); - await berichteHeading.click(); - await page.waitForTimeout(100); } //---------------------------------------------------------------------