All files / runtime/_services field-page-object.ts

100% Statements 56/56
100% Branches 11/11
100% Functions 10/10
100% Lines 56/56

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 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 571x 1x 1x 1x 1x 1x 1x 1x 9x 9x 9x 9x 9x 9x 9x 9x 9x 14x 14x 9x 9x 9x 9x 9x 9x 9x 2x 2x 2x 2x 2x 9x 9x 1x 1x 1x 9x 9x 1x 1x 1x 9x 9x 1x 1x 1x 9x 9x 1x 1x 1x 9x 9x 1x 1x 9x  
import type { Locator, Page } from '@playwright/test';
import { DyE2E_TestId_Util } from '../../contracts/_collections/utils/test-id.util';
 
/**
 * Page-object egy konkrét Forms v2 field-hez.
 *
 * Konvenció: a testId `${formKey}-${fieldKey}` (lásd `DyE2E_TestId_Util.field`).
 */
export class DyE2E_FieldPageObject {
  constructor(
    private readonly page: Page,
    private readonly formKey: string,
    private readonly fieldKey: string,
    private readonly explicitTestId?: string,
  ) {}
 
  get testId(): string {
    return this.explicitTestId ?? DyE2E_TestId_Util.field(this.formKey, this.fieldKey);
  }
 
  get input(): Locator {
    return this.page.getByTestId(this.testId);
  }
 
  /** A field gyökér-eleme (text-red-400 error-msg scope). */
  get root(): Locator {
    return this.page
      .locator(`[data-testid="${this.testId}"]`)
      .locator('xpath=ancestor-or-self::*[starts-with(local-name(),"dynamo-")]')
      .first();
  }
 
  async fill(value: string): Promise<void> {
    await this.input.fill(value);
    await this.input.blur();
  }
 
  async clear(): Promise<void> {
    await this.input.fill('');
    await this.input.blur();
  }
 
  async check(): Promise<void> {
    await this.input.check();
    await this.input.blur();
  }
 
  async uncheck(): Promise<void> {
    await this.input.uncheck();
    await this.input.blur();
  }
 
  errorMessage(): Locator {
    return this.root.locator('.text-red-400.mt-1').first();
  }
}