test: playwright funktion highlight in separate Datei
This commit is contained in:
@@ -1,33 +1,6 @@
|
||||
import { expect } from "../fixtures";
|
||||
import type { Locator, Page } from "@playwright/test";
|
||||
|
||||
import type { Page } from "@playwright/test";
|
||||
import { highlightAndExpectVisible } from "./highlight";
|
||||
// Kombinierte Helper-Funktion: injiziert CSS (nur einmal), hebt hervor und prüft Sichtbarkeit
|
||||
async function highlightAndExpectVisible(
|
||||
page: Page,
|
||||
locator: Locator,
|
||||
durationMs = 800
|
||||
) {
|
||||
// CSS nur einmal pro Page injizieren
|
||||
if (!(await page.evaluate(() => (window as any).__pwForceCssInjected))) {
|
||||
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();
|
||||
}
|
||||
|
||||
export async function runAnalogInputsTest(page: Page) {
|
||||
await page.goto("/analogInputs");
|
||||
|
||||
@@ -1,33 +1,5 @@
|
||||
import type { Locator, Page } from "@playwright/test";
|
||||
import { expect } from "../fixtures";
|
||||
|
||||
// Kombinierte Helper-Funktion: injiziert CSS (nur einmal), hebt hervor und prüft Sichtbarkeit
|
||||
async function highlightAndExpectVisible(
|
||||
page: Page,
|
||||
locator: Locator,
|
||||
durationMs = 800
|
||||
) {
|
||||
// CSS nur einmal pro Page injizieren
|
||||
if (!(await page.evaluate(() => (window as any).__pwForceCssInjected))) {
|
||||
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();
|
||||
}
|
||||
import type { Page } from "@playwright/test";
|
||||
import { highlightAndExpectVisible } from "./highlight";
|
||||
|
||||
export async function runDashboardTest(page: Page) {
|
||||
await page.goto("http://localhost:3000/dashboard");
|
||||
|
||||
29
playwright/tests/highlight.ts
Normal file
29
playwright/tests/highlight.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
// Kombinierte Helper-Funktion: injiziert CSS (nur einmal), hebt hervor und prüft Sichtbarkeit
|
||||
import type { Locator, Page } from "@playwright/test";
|
||||
import { expect } from "../fixtures";
|
||||
export async function highlightAndExpectVisible(
|
||||
page: Page,
|
||||
locator: Locator,
|
||||
durationMs = 800
|
||||
) {
|
||||
// CSS nur einmal pro Page injizieren
|
||||
if (!(await page.evaluate(() => (window as any).__pwForceCssInjected))) {
|
||||
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