Test: done
This commit is contained in:
38
playwright/components/navTest.ts
Normal file
38
playwright/components/navTest.ts
Normal file
@@ -0,0 +1,38 @@
|
||||
import type { Page } from "@playwright/test";
|
||||
import { highlightAndExpectVisible } from "@playwright/utils/highlight";
|
||||
|
||||
export async function navTest(page: Page) {
|
||||
await page.goto("http://localhost:3000/dashboard");
|
||||
await highlightAndExpectVisible(
|
||||
page,
|
||||
page.getByRole("link", { name: "Übersicht" })
|
||||
);
|
||||
await highlightAndExpectVisible(
|
||||
page,
|
||||
page.getByRole("link", { name: "Kabelüberwachung" })
|
||||
);
|
||||
await highlightAndExpectVisible(
|
||||
page,
|
||||
page.getByRole("link", { name: "Meldungseingänge" })
|
||||
);
|
||||
await highlightAndExpectVisible(
|
||||
page,
|
||||
page.getByRole("link", { name: "Schaltausgänge" })
|
||||
);
|
||||
await highlightAndExpectVisible(
|
||||
page,
|
||||
page.getByRole("link", { name: "Messwerteingänge" })
|
||||
);
|
||||
await highlightAndExpectVisible(
|
||||
page,
|
||||
page.getByRole("link", { name: "Berichte" })
|
||||
);
|
||||
await highlightAndExpectVisible(
|
||||
page,
|
||||
page.getByRole("link", { name: "System" })
|
||||
);
|
||||
await highlightAndExpectVisible(
|
||||
page,
|
||||
page.getByRole("link", { name: "Einstellungen" })
|
||||
);
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
import type { Locator, Page } from "@playwright/test";
|
||||
import { expect } from "@playwright/test";
|
||||
import type { Page } from "@playwright/test";
|
||||
import { highlightAndExpectVisible } from "@playwright/utils/highlight";
|
||||
|
||||
export async function runDashboardTest(page: Page) {
|
||||
await page.goto("http://localhost:3000/dashboard");
|
||||
@@ -202,40 +202,3 @@ export async function runDashboardTest(page: Page) {
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
export async function highlightAndExpectVisible(
|
||||
page: Page,
|
||||
locator: Locator,
|
||||
durationMs = 800
|
||||
) {
|
||||
// CSS nur einmal pro Page injizieren
|
||||
const alreadyInjected = await page.evaluate(
|
||||
() => (window as any).__pwForceCssInjected === true
|
||||
);
|
||||
|
||||
if (!alreadyInjected) {
|
||||
await page.addStyleTag({
|
||||
content: `
|
||||
.pw-force-outline {
|
||||
outline: 3px solid #ff1744 !important;
|
||||
outline-offset: 2px !important;
|
||||
box-shadow: 0 0 0 3px rgba(224,0,43,.35) !important;
|
||||
}
|
||||
`,
|
||||
});
|
||||
await page.evaluate(() => {
|
||||
(window as any).__pwForceCssInjected = true;
|
||||
});
|
||||
}
|
||||
|
||||
const els = await locator.elementHandles();
|
||||
for (const el of els) {
|
||||
await el.evaluate((node: unknown, ms: number) => {
|
||||
const n = node as HTMLElement;
|
||||
n.classList.add("pw-force-outline");
|
||||
window.setTimeout(() => n.classList.remove("pw-force-outline"), ms);
|
||||
}, durationMs);
|
||||
}
|
||||
|
||||
await expect(locator).toBeVisible();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import type { Locator, Page } from "@playwright/test";
|
||||
import type { Page } from "@playwright/test";
|
||||
import { expect } from "@playwright/test";
|
||||
import { highlightAndExpectVisible } from "@playwright/utils/highlight";
|
||||
|
||||
export async function runDigitalOutputsTest(page: Page) {
|
||||
await page.goto("/digitalOutputs");
|
||||
@@ -210,40 +211,3 @@ export async function runDigitalOutputsTest(page: Page) {
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
export async function highlightAndExpectVisible(
|
||||
page: Page,
|
||||
locator: Locator,
|
||||
durationMs = 800
|
||||
) {
|
||||
// CSS nur einmal pro Page injizieren
|
||||
const alreadyInjected = await page.evaluate(
|
||||
() => (window as any).__pwForceCssInjected === true
|
||||
);
|
||||
|
||||
if (!alreadyInjected) {
|
||||
await page.addStyleTag({
|
||||
content: `
|
||||
.pw-force-outline {
|
||||
outline: 3px solid #ff1744 !important;
|
||||
outline-offset: 2px !important;
|
||||
box-shadow: 0 0 0 3px rgba(224,0,43,.35) !important;
|
||||
}
|
||||
`,
|
||||
});
|
||||
await page.evaluate(() => {
|
||||
(window as any).__pwForceCssInjected = true;
|
||||
});
|
||||
}
|
||||
|
||||
const els = await locator.elementHandles();
|
||||
for (const el of els) {
|
||||
await el.evaluate((node: unknown, ms: number) => {
|
||||
const n = node as HTMLElement;
|
||||
n.classList.add("pw-force-outline");
|
||||
window.setTimeout(() => n.classList.remove("pw-force-outline"), ms);
|
||||
}, durationMs);
|
||||
}
|
||||
|
||||
await expect(locator).toBeVisible();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import type { Locator, Page } from "@playwright/test";
|
||||
import { expect } from "@playwright/test";
|
||||
import type { Page } from "@playwright/test";
|
||||
import { highlightAndExpectVisible } from "@playwright/utils/highlight";
|
||||
|
||||
export async function runCableMonitoringTest(page: Page) {
|
||||
await page.goto("/kabelueberwachung");
|
||||
@@ -378,40 +378,3 @@ export async function runCableMonitoringTest(page: Page) {
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
export async function highlightAndExpectVisible(
|
||||
page: Page,
|
||||
locator: Locator,
|
||||
durationMs = 800
|
||||
) {
|
||||
// CSS nur einmal pro Page injizieren
|
||||
const alreadyInjected = await page.evaluate(
|
||||
() => (window as any).__pwForceCssInjected === true
|
||||
);
|
||||
|
||||
if (!alreadyInjected) {
|
||||
await page.addStyleTag({
|
||||
content: `
|
||||
.pw-force-outline {
|
||||
outline: 3px solid #ff1744 !important;
|
||||
outline-offset: 2px !important;
|
||||
box-shadow: 0 0 0 3px rgba(224,0,43,.35) !important;
|
||||
}
|
||||
`,
|
||||
});
|
||||
await page.evaluate(() => {
|
||||
(window as any).__pwForceCssInjected = true;
|
||||
});
|
||||
}
|
||||
|
||||
const els = await locator.elementHandles();
|
||||
for (const el of els) {
|
||||
await el.evaluate((node: unknown, ms: number) => {
|
||||
const n = node as HTMLElement;
|
||||
n.classList.add("pw-force-outline");
|
||||
window.setTimeout(() => n.classList.remove("pw-force-outline"), ms);
|
||||
}, durationMs);
|
||||
}
|
||||
|
||||
await expect(locator).toBeVisible();
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { Locator, Page } from "@playwright/test";
|
||||
import type { Page } from "@playwright/test";
|
||||
import { expect } from "@playwright/test";
|
||||
import { highlightAndExpectVisible } from "@playwright/utils/highlight";
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import type { Locator, Page } from "@playwright/test";
|
||||
import { expect } from "@playwright/test";
|
||||
import type { Page } from "@playwright/test";
|
||||
import { highlightAndExpectVisible } from "@playwright/utils/highlight";
|
||||
|
||||
export async function runSettingsPageTest(page: Page) {
|
||||
await page.goto("http://localhost:3000/einstellungen");
|
||||
@@ -259,42 +259,3 @@ export async function runSettingsPageTest(page: Page) {
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
export async function highlightAndExpectVisible(
|
||||
page: Page,
|
||||
locator: Locator,
|
||||
durationMs = 800
|
||||
) {
|
||||
// CSS nur einmal pro Page injizieren
|
||||
const alreadyInjected = await page.evaluate(
|
||||
() => (window as any).__pwForceCssInjected === true
|
||||
);
|
||||
|
||||
if (!alreadyInjected) {
|
||||
await page.addStyleTag({
|
||||
content: `
|
||||
.pw-force-outline {
|
||||
outline: 3px solid #ff1744 !important;
|
||||
outline-offset: 2px !important;
|
||||
box-shadow: 0 0 0 3px rgba(224,0,43,.35) !important;
|
||||
}
|
||||
`,
|
||||
});
|
||||
await page.evaluate(() => {
|
||||
(window as any).__pwForceCssInjected = true;
|
||||
});
|
||||
}
|
||||
|
||||
// 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) => {
|
||||
const n = node as HTMLElement;
|
||||
n.classList.add("pw-force-outline");
|
||||
window.setTimeout(() => n.classList.remove("pw-force-outline"), ms);
|
||||
}, durationMs);
|
||||
}
|
||||
|
||||
await expect(locator).toBeVisible();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import type { Locator, Page } from "@playwright/test";
|
||||
import type { Page } from "@playwright/test";
|
||||
import { expect } from "@playwright/test";
|
||||
import { highlightAndExpectVisible } from "@playwright/utils/highlight";
|
||||
|
||||
export async function runSystemTest(page: Page) {
|
||||
await page.goto("/system");
|
||||
@@ -143,40 +144,3 @@ export async function runSystemTest(page: Page) {
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
export async function highlightAndExpectVisible(
|
||||
page: Page,
|
||||
locator: Locator,
|
||||
durationMs = 800
|
||||
) {
|
||||
// CSS nur einmal pro Page injizieren
|
||||
const alreadyInjected = await page.evaluate(
|
||||
() => (window as any).__pwForceCssInjected === true
|
||||
);
|
||||
|
||||
if (!alreadyInjected) {
|
||||
await page.addStyleTag({
|
||||
content: `
|
||||
.pw-force-outline {
|
||||
outline: 3px solid #ff1744 !important;
|
||||
outline-offset: 2px !important;
|
||||
box-shadow: 0 0 0 3px rgba(224,0,43,.35) !important;
|
||||
}
|
||||
`,
|
||||
});
|
||||
await page.evaluate(() => {
|
||||
(window as any).__pwForceCssInjected = true;
|
||||
});
|
||||
}
|
||||
|
||||
const els = await locator.elementHandles();
|
||||
for (const el of els) {
|
||||
await el.evaluate((node: unknown, ms: number) => {
|
||||
const n = node as HTMLElement;
|
||||
n.classList.add("pw-force-outline");
|
||||
window.setTimeout(() => n.classList.remove("pw-force-outline"), ms);
|
||||
}, durationMs);
|
||||
}
|
||||
|
||||
await expect(locator).toBeVisible();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user