test: Tests erfolgreich mit base url von playwright.config.ts
This commit is contained in:
144
playwright/tests/pages/digitalOutputs/digitalOutputs.test.ts
Normal file
144
playwright/tests/pages/digitalOutputs/digitalOutputs.test.ts
Normal file
@@ -0,0 +1,144 @@
|
||||
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("digitalOutputs", async ({ page }) => {
|
||||
await page.goto("/dashboard");
|
||||
// Gemeinsame Layout-Checks
|
||||
await headerTest(page);
|
||||
await navTest(page);
|
||||
await footerTest(page);
|
||||
await page.getByRole("link", { name: "Schaltausgänge" }).click();
|
||||
await expect(page.locator("h1")).toBeVisible();
|
||||
await expect(
|
||||
page.locator("h2").filter({ hasText: "Schaltausgänge" }).locator("svg")
|
||||
).toBeVisible();
|
||||
await expect(
|
||||
page.locator("h2").filter({ hasText: "Schaltausgänge" })
|
||||
).toBeVisible();
|
||||
await expect(
|
||||
page.getByRole("cell", { name: "Ausgang", exact: true })
|
||||
).toBeVisible();
|
||||
await expect(page.getByRole("cell", { name: "Bezeichnung" })).toBeVisible();
|
||||
await expect(page.getByRole("cell", { name: "Schalter" })).toBeVisible();
|
||||
await expect(page.getByRole("cell", { name: "Aktion" })).toBeVisible();
|
||||
await expect(
|
||||
page.getByRole("cell", { name: "1", exact: true }).locator("svg")
|
||||
).toBeVisible();
|
||||
await expect(
|
||||
page.getByRole("cell", { name: "1", exact: true })
|
||||
).toBeVisible();
|
||||
await expect(
|
||||
page.getByRole("cell", { name: "2", exact: true })
|
||||
).toBeVisible();
|
||||
await expect(
|
||||
page.getByRole("cell", { name: "3", exact: true })
|
||||
).toBeVisible();
|
||||
await expect(
|
||||
page.getByRole("cell", { name: "4", exact: true })
|
||||
).toBeVisible();
|
||||
await expect(page.getByRole("cell", { name: "Ausgang1" })).toBeVisible();
|
||||
await expect(page.getByRole("cell", { name: "Ausgang2" })).toBeVisible();
|
||||
await expect(page.getByRole("cell", { name: "Ausgang3" })).toBeVisible();
|
||||
await expect(page.getByRole("cell", { name: "Ausgang4" })).toBeVisible();
|
||||
await expect(
|
||||
page.getByRole("row", { name: "Ausgang1" }).getByRole("cell").nth(2)
|
||||
).toBeVisible();
|
||||
await expect(
|
||||
page.getByRole("row", { name: "Ausgang2" }).getByRole("cell").nth(2)
|
||||
).toBeVisible();
|
||||
await expect(
|
||||
page.getByRole("row", { name: "Ausgang3" }).getByRole("cell").nth(2)
|
||||
).toBeVisible();
|
||||
await expect(
|
||||
page.getByRole("row", { name: "Ausgang4" }).getByRole("cell").nth(2)
|
||||
).toBeVisible();
|
||||
await expect(
|
||||
page.getByRole("row", { name: "Ausgang1" }).getByRole("cell").nth(3)
|
||||
).toBeVisible();
|
||||
await expect(
|
||||
page.getByRole("row", { name: "Ausgang2" }).getByRole("cell").nth(3)
|
||||
).toBeVisible();
|
||||
await expect(
|
||||
page.getByRole("row", { name: "Ausgang3" }).getByRole("cell").nth(3)
|
||||
).toBeVisible();
|
||||
await expect(
|
||||
page.getByRole("row", { name: "Ausgang4" }).getByRole("cell").nth(3)
|
||||
).toBeVisible();
|
||||
await page
|
||||
.getByRole("row", { name: "Ausgang1" })
|
||||
.locator("svg")
|
||||
.nth(1)
|
||||
.click();
|
||||
await expect(page.getByRole("main")).toMatchAriaSnapshot(`
|
||||
- heading "Einstellungen Schaltausgang 1" [level=2]
|
||||
- button "Modal schließen"
|
||||
`);
|
||||
await expect(page.getByRole("main")).toMatchAriaSnapshot(`
|
||||
- text: "Bezeichnung:"
|
||||
- textbox "z. B. Licht Relais 1"
|
||||
`);
|
||||
await expect(page.getByRole("main")).toMatchAriaSnapshot(
|
||||
`- button "Speichern"`
|
||||
);
|
||||
await page.getByRole("button", { name: "Modal schließen" }).click();
|
||||
await page
|
||||
.getByRole("row", { name: "Ausgang2" })
|
||||
.locator("svg")
|
||||
.nth(1)
|
||||
.click();
|
||||
await expect(page.getByRole("main")).toMatchAriaSnapshot(`
|
||||
- heading "Einstellungen Schaltausgang 2" [level=2]
|
||||
- button "Modal schließen"
|
||||
`);
|
||||
await expect(page.getByRole("main")).toMatchAriaSnapshot(`
|
||||
- text: "Bezeichnung:"
|
||||
- textbox "z. B. Licht Relais 1"
|
||||
`);
|
||||
await expect(page.getByRole("main")).toMatchAriaSnapshot(
|
||||
`- button "Speichern"`
|
||||
);
|
||||
await page.getByRole("button", { name: "Modal schließen" }).click();
|
||||
await page
|
||||
.getByRole("row", { name: "Ausgang3" })
|
||||
.locator("svg")
|
||||
.nth(1)
|
||||
.click();
|
||||
await expect(page.getByRole("main")).toMatchAriaSnapshot(`
|
||||
- heading "Einstellungen Schaltausgang 3" [level=2]
|
||||
- button "Modal schließen"
|
||||
`);
|
||||
await expect(page.getByRole("main")).toMatchAriaSnapshot(`
|
||||
- text: "Bezeichnung:"
|
||||
- textbox "z. B. Licht Relais 1"
|
||||
`);
|
||||
await expect(page.getByRole("main")).toMatchAriaSnapshot(
|
||||
`- button "Speichern"`
|
||||
);
|
||||
await page.getByRole("button", { name: "Modal schließen" }).click();
|
||||
await page
|
||||
.getByRole("row", { name: "Ausgang4" })
|
||||
.locator("svg")
|
||||
.nth(1)
|
||||
.click();
|
||||
await expect(page.getByRole("main")).toMatchAriaSnapshot(`
|
||||
- heading "Einstellungen Schaltausgang 4" [level=2]
|
||||
- button "Modal schließen"
|
||||
`);
|
||||
await expect(page.getByRole("main")).toMatchAriaSnapshot(`
|
||||
- text: "Bezeichnung:"
|
||||
- textbox "z. B. Licht Relais 1"
|
||||
`);
|
||||
await expect(page.getByRole("main")).toMatchAriaSnapshot(
|
||||
`- button "Speichern"`
|
||||
);
|
||||
await page.getByRole("button", { name: "Modal schließen" }).click();
|
||||
});
|
||||
@@ -1,64 +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 runDigitalOutputsTest(page: Page) {
|
||||
await page.goto("/digitalOutputs");
|
||||
//----------------------
|
||||
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"));
|
||||
page.locator("h1").click();
|
||||
await highlightAndExpectVisible(
|
||||
page,
|
||||
page.locator("h2").filter({ hasText: "Schaltausgänge" })
|
||||
);
|
||||
|
||||
page
|
||||
.locator("h2")
|
||||
.filter({ hasText: "Schaltausgänge" })
|
||||
.locator("svg")
|
||||
.click();
|
||||
page.locator("h2").filter({ hasText: "Schaltausgänge" }).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" })
|
||||
);
|
||||
await highlightAndExpectVisible(
|
||||
page,
|
||||
page.getByRole("cell", { name: "Schalter" })
|
||||
);
|
||||
await highlightAndExpectVisible(
|
||||
page,
|
||||
page.getByRole("cell", { name: "Aktion" })
|
||||
);
|
||||
// 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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user