Files
CPLv4.0/playwright/tests/pages/analogInputs/analogInputsTest.ts
2025-09-02 14:22:58 +02:00

254 lines
7.3 KiB
TypeScript

import type { Page } from "@playwright/test";
import { expect } from "@playwright/test";
import { highlightAndExpectVisible } from "@playwright/utils/highlight";
import { navTest } from "@playwright/components/navTest";
import { headerTest } from "@playwright/components/headerTest";
import { footerTest } from "@playwright/components/footerTest";
// Kombinierte Helper-Funktion: injiziert CSS (nur einmal), hebt hervor und prüft Sichtbarkeit
export async function runAnalogInputsTest(page: Page) {
await page.goto("/analogInputs");
//----------------------
await headerTest(page);
await navTest(page);
await footerTest(page);
await page.waitForTimeout(400);
//----------------------
await highlightAndExpectVisible(
page,
page.getByRole("heading", { name: "Messwerteingänge" }).nth(1)
);
await highlightAndExpectVisible(
page,
page.getByRole("cell", { name: "Eingang" })
);
// ...existing code...
await highlightAndExpectVisible(
page,
page.getByRole("cell", { name: "Messwert" })
);
await highlightAndExpectVisible(
page,
page.getByRole("cell", { name: "Einheit" })
);
await highlightAndExpectVisible(
page,
page.getByRole("cell", { name: "Bezeichnung" })
);
await highlightAndExpectVisible(
page,
page.getByRole("cell", { name: "Einstellungen" })
);
await highlightAndExpectVisible(
page,
page.getByRole("cell", { name: "Messkurve", exact: true })
);
await highlightAndExpectVisible(page, page.getByText("1", { exact: true }));
await highlightAndExpectVisible(page, page.getByText("2", { exact: true }));
await highlightAndExpectVisible(page, page.getByText("3", { exact: true }));
await highlightAndExpectVisible(
page,
page.getByRole("cell", { name: "4", exact: true }).locator("path")
);
await highlightAndExpectVisible(
page,
page.getByRole("cell", { name: "5", exact: true })
);
await highlightAndExpectVisible(page, page.getByText("6", { exact: true }));
await highlightAndExpectVisible(
page,
page.getByRole("cell", { name: "7", exact: true })
);
await expect(
page.getByRole("cell", { name: "8", exact: true })
).toBeVisible();
await highlightAndExpectVisible(
page,
page.getByRole("cell", { name: "8", exact: true })
);
await expect(page.locator(".border.p-2.text-center").first()).toBeVisible();
await highlightAndExpectVisible(
page,
page.locator(".border.p-2.text-center").first()
);
// Markiere die gesamte erste Datenzeile (Row mit "AE 1" falls vorhanden)
await highlightAndExpectVisible(
page,
page
.getByRole("row", { name: "2 5.67 °C Temperatur" })
.getByRole("button")
.first()
);
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 expect(
page
.getByRole("row", { name: "0.01 V AE 4 Messkurve anzeigen" })
.getByRole("button")
.first()
).toBeVisible();
await highlightAndExpectVisible(
page,
page
.getByRole("row", { name: "0.01 V AE 4 Messkurve anzeigen" })
.getByRole("button")
.first()
);
await expect(
page
.getByRole("row", { name: "8 -0.00 mA AE 8 Messkurve" })
.getByLabel("Messkurve anzeigen")
).toBeVisible();
await highlightAndExpectVisible(
page,
page
.getByRole("row", { name: "8 -0.00 mA AE 8 Messkurve" })
.getByLabel("Messkurve anzeigen")
);
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({ timeout: 15000 });
await highlightAndExpectVisible(
page,
page.getByRole("heading", { name: "Einstellungen Messwerteingang" })
);
await highlightAndExpectVisible(page, page.getByText("Bezeichnung:"));
await highlightAndExpectVisible(page, page.getByText("Offset:"), 5000);
await highlightAndExpectVisible(page, page.getByText("Faktor:"), 5000);
await highlightAndExpectVisible(page, page.getByText("Einheit:"), 5000);
await highlightAndExpectVisible(
page,
page.getByText("Speicherintervall:"),
5000
);
await highlightAndExpectVisible(
page,
page.getByRole("button", { name: "Speichern" })
);
await expect(
page.getByRole("button", { name: "Modal schließen" })
).toBeVisible();
await highlightAndExpectVisible(
page,
page.getByRole("button", { name: "Modal schließen" })
);
await expect(
page.getByText(
"Einstellungen Messwerteingang 1Bezeichnung:Offset:Faktor:Einheit:"
)
).toBeVisible();
await highlightAndExpectVisible(
page,
page.getByText(
"Einstellungen Messwerteingang 1Bezeichnung:Offset:Faktor:Einheit:"
)
);
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,
page.getByText(
"Messkurve Messwerteingang 1Eingang 1VonBisAlle MesswerteDaten laden"
)
);
await highlightAndExpectVisible(
page,
page.getByRole("heading", { name: "Messkurve Messwerteingang" })
);
await highlightAndExpectVisible(page, page.locator("canvas"));
await highlightAndExpectVisible(page, page.getByText("Eingang 1VonBisAlle"));
await highlightAndExpectVisible(
page,
page.getByRole("button", { name: "Daten laden" })
);
await highlightAndExpectVisible(
page,
page.getByRole("button", { name: "Alle Messwerte " })
);
await page.getByRole("button", { name: "Alle Messwerte " }).click();
await expect(page.getByRole("option", { name: "Stündlich" })).toBeVisible();
await page.getByRole("option", { name: "Stündlich" }).click();
await expect(page.getByRole("button", { name: "Stündlich" })).toBeVisible();
await page.getByRole("button", { name: "Stündlich" }).click();
await expect(page.getByRole("option", { name: "Täglich" })).toBeVisible();
await page.getByRole("option", { name: "Täglich" }).click();
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" })
);
// 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();
}
}