fix: DigitalOutputsVies.tsx
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
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/header/headerTest";
|
||||
@@ -11,6 +10,7 @@ export async function runDigitalOutputsTest(page: Page) {
|
||||
await headerTest(page);
|
||||
await navTest(page);
|
||||
await footerTest(page);
|
||||
// Wait a moment for initial redux fetch and render in slower CI environments
|
||||
await page.waitForTimeout(400);
|
||||
//----------------------
|
||||
await highlightAndExpectVisible(page, page.locator("h1"));
|
||||
@@ -26,13 +26,17 @@ export async function runDigitalOutputsTest(page: Page) {
|
||||
.locator("svg")
|
||||
.click();
|
||||
page.locator("h2").filter({ hasText: "Schaltausgänge" }).click();
|
||||
await highlightAndExpectVisible(
|
||||
page,
|
||||
page.getByRole("cell", { name: "Ausgang", exact: true })
|
||||
);
|
||||
const ausgang2Cell = page.getByRole("cell", { name: "Ausgang2" }).nth(1);
|
||||
await ausgang2Cell.waitFor({ state: "visible", timeout: 15000 }); // bis zu 15 Sekunden warten
|
||||
await ausgang2Cell.click();
|
||||
// Wait for the outputs table to render and be visible
|
||||
const table = page.locator("table");
|
||||
await table.first().waitFor({ state: "visible", timeout: 15000 });
|
||||
|
||||
// Prefer robust selection: select the row by its first cell text matching the id "2"
|
||||
const rowAusgang2 = table
|
||||
.getByRole("row")
|
||||
.filter({ has: page.getByRole("cell", { name: /^\s*2\s*$/ }) })
|
||||
.first();
|
||||
await rowAusgang2.waitFor({ state: "visible", timeout: 15000 });
|
||||
await rowAusgang2.click();
|
||||
await highlightAndExpectVisible(
|
||||
page,
|
||||
page.getByRole("cell", { name: "Schalter" })
|
||||
@@ -45,12 +49,16 @@ export async function runDigitalOutputsTest(page: Page) {
|
||||
page,
|
||||
page.getByRole("cell", { name: "Aktion" })
|
||||
);
|
||||
page.getByRole("cell", { name: "1" }).locator("svg").click();
|
||||
//page.getByRole("cell", { name: "1" }).click();
|
||||
page.getByRole("cell", { name: "2", exact: true }).locator("svg").click();
|
||||
page.getByRole("cell", { name: "2", exact: true }).click();
|
||||
page.getByRole("cell", { name: "3", exact: true }).locator("svg").click();
|
||||
page.getByRole("cell", { name: "3", exact: true }).click();
|
||||
page.getByRole("cell", { name: "4", exact: true }).locator("svg").click();
|
||||
page.getByRole("cell", { name: "4", exact: true }).click();
|
||||
// Interact with the switch icon within each row deterministically
|
||||
for (const id of [1, 2, 3, 4]) {
|
||||
const row = table
|
||||
.getByRole("row")
|
||||
.filter({
|
||||
has: page.getByRole("cell", { name: new RegExp(`^\\s*${id}\\s*$`) }),
|
||||
})
|
||||
.first();
|
||||
await row.waitFor({ state: "visible", timeout: 10000 });
|
||||
const switchIcon = row.locator("td >> nth=2").locator("svg");
|
||||
await switchIcon.first().click();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,34 +97,28 @@ export async function runMeldungenTest(page: Page) {
|
||||
await page.waitForTimeout(30);
|
||||
}
|
||||
|
||||
// Dynamische Zeilen und Zellen (Beispiel für mehrere Zeitstempel)
|
||||
const zeiten = [
|
||||
"11.08.2025, 11:52:44",
|
||||
"11.08.2025, 11:51:14",
|
||||
"11.08.2025, 11:44:19",
|
||||
"11.08.2025, 11:43:44",
|
||||
"11.08.2025, 11:36:42",
|
||||
"11.08.2025, 11:35:45",
|
||||
"11.08.2025, 11:21:16",
|
||||
"11.08.2025, 11:21:05",
|
||||
"11.08.2025, 11:14:01",
|
||||
];
|
||||
for (const zeit of zeiten) {
|
||||
const row = page.getByRole("row", { name: zeit });
|
||||
await highlightAndExpectVisible(page, row.getByRole("cell").first());
|
||||
await row.getByRole("cell").first().click();
|
||||
await page.waitForTimeout(20);
|
||||
|
||||
const timeCell = page.getByRole("cell", { name: zeit.split(", ")[1] });
|
||||
await highlightAndExpectVisible(page, timeCell);
|
||||
await timeCell.click();
|
||||
await page.waitForTimeout(20);
|
||||
|
||||
for (let i = 2; i <= 4; i++) {
|
||||
const cell = row.getByRole("cell").nth(i);
|
||||
await highlightAndExpectVisible(page, cell);
|
||||
await cell.click();
|
||||
await page.waitForTimeout(20);
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user