Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 2x 2x 2x 1x 1x 1x 1x 1x 1x 1x 1x | import { expect } from '@playwright/test';
import type { Locator } from '@playwright/test';
/**
* Assertion-helpers a Forms v2 + CWV-szintű ellenőrzésekhez.
*
* Konvenció: a Tailwind error-class `.text-red-400.mt-1` az error-msg
* (Forms v2 stable). A red-border `.border-red-500` a field-input-on.
*/
export class DyE2E_AssertionHelpers_Util {
/** Field-en NINCS error-msg + NINCS red-border. */
static async expectFieldValid(fieldScope: Locator): Promise<void> {
await expect(fieldScope.locator('.text-red-400.mt-1')).toHaveCount(0);
}
/** Field-en VAN látható error-msg. Opcionálisan ellenőrzi a szöveget. */
static async expectFieldInvalid(fieldScope: Locator, errorTextContains?: string): Promise<void> {
const errorMsg: Locator = fieldScope.locator('.text-red-400.mt-1').first();
await expect(errorMsg).toBeVisible();
if (errorTextContains) {
await expect(errorMsg).toContainText(errorTextContains);
}
}
/** Field-input red-border. */
static async expectRedBorder(fieldInput: Locator): Promise<void> {
const cls: string = (await fieldInput.getAttribute('class')) ?? '';
expect(cls).toContain('border-red-500');
}
/** Viewport overflow: document.scrollWidth ≤ window.innerWidth. */
static async expectNoHorizontalOverflow(page: { evaluate: <T>(fn: () => T) => Promise<T> }): Promise<void> {
const overflow: { scrollWidth: number; innerWidth: number } = await page.evaluate((): { scrollWidth: number; innerWidth: number } => ({
scrollWidth: document.documentElement.scrollWidth,
innerWidth: window.innerWidth,
}));
expect(overflow.scrollWidth, 'horizontal overflow detected').toBeLessThanOrEqual(overflow.innerWidth);
}
}
|