Test: playwright done

This commit is contained in:
ISA
2025-09-02 10:40:12 +02:00
parent 7dc64ca972
commit 8da1457e4d
13 changed files with 31 additions and 50 deletions

View File

View File

View File

View File

@@ -1,5 +1,6 @@
import type { Locator, Page } from "@playwright/test";
import { expect } from "@playwright/test";
import { highlightAndExpectVisible } from "@playwright/utils/highlight";
export async function runMeldungenTest(page: Page) {
await page.goto("/meldungen");
@@ -178,42 +179,3 @@ export async function runMeldungenTest(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();
}

View File

@@ -7,16 +7,27 @@ export async function highlightAndExpectVisible(
durationMs = 800
) {
// CSS nur einmal pro Page injizieren
if (!(await page.evaluate(() => (window as any).__pwForceCssInjected))) {
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; }
`,
.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) => {
@@ -25,5 +36,6 @@ export async function highlightAndExpectVisible(
window.setTimeout(() => n.classList.remove("pw-force-outline"), ms);
}, durationMs);
}
await expect(locator).toBeVisible();
}