All files / runtime/_services wave-2b-page-objects.ts

99.03% Statements 103/104
84% Branches 21/25
100% Functions 20/20
99.03% Lines 103/104

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 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 1051x 1x 1x 1x 1x 1x 1x 1x 4x 4x 4x 4x 4x 4x 4x 4x 1x 1x 1x 4x 4x 4x 3x 3x 3x 3x 3x 4x 1x 2x 2x 2x 2x 2x 2x 2x 2x 1x 1x 1x 1x 1x   1x 1x 2x 2x 2x 1x 1x 1x 2x 1x 2x 2x 2x 2x 2x 2x 2x 2x 1x 1x 2x 2x 1x 1x 2x 1x 3x 3x 3x 3x 3x 3x 3x 3x 2x 2x 3x 3x 3x 1x 1x 3x 1x 2x 2x 2x 2x 2x 2x 2x 2x 1x 1x 1x 2x 2x 2x 1x 1x 1x 2x  
import type { Locator, Page } from '@playwright/test';
 
/**
 * Wave-2b page-objects — a generator emission-mintázatát ember-olvasható
 * page-object API-vá emelik. Consumer-projekt használhatja direktül vagy
 * a `dye2eTest` fixture-en át.
 */
 
export class DyE2E_ChipSelectPageObject {
  constructor(
    private readonly page: Page,
    private readonly fieldTestId: string,
  ) {}
 
  /** Egy chip click-re — option-value-szuffixel a testId-n. */
  async clickChip(optionValue: string | number): Promise<void> {
    const selector: string = `[data-testid="${this.fieldTestId}-${optionValue}"]`;
    await this.page.locator(selector).first().click();
  }
 
  /** Megnézi, hogy egy chip aktív-e (`.selected` vagy `[aria-selected="true"]`). */
  async isSelected(optionValue: string | number): Promise<boolean> {
    const locator: Locator = this.page.locator(`[data-testid="${this.fieldTestId}-${optionValue}"]`).first();
    const cls: string = (await locator.getAttribute('class')) ?? '';
    const aria: string = (await locator.getAttribute('aria-selected')) ?? '';
    return cls.includes('selected') || aria === 'true';
  }
}
 
export class DyE2E_AutocompletePageObject {
  constructor(
    private readonly page: Page,
    private readonly fieldTestId: string,
  ) {}
 
  /** Input fill + suggestion-list várás. */
  async fillAndSuggest(value: string, suggestionsTimeoutMs: number = 2_000): Promise<void> {
    await this.page.getByTestId(this.fieldTestId).fill(value);
    // A suggestion-list selector consumer-szintű override-igényes
    // (default: a fieldTestId + '-suggestions'); Wave-3 page-object spec.
    const suggestions: Locator = this.page.locator(`[data-testid="${this.fieldTestId}-suggestions"]`).first();
    await suggestions.waitFor({ state: 'visible', timeout: suggestionsTimeoutMs }).catch((): void => {
      /* nincs suggestion-list — empty input vagy non-matching */
    });
  }
 
  /** Egy suggestion click-re — index-szel. */
  async selectSuggestion(index: number): Promise<void> {
    const selector: string = `[data-testid="${this.fieldTestId}-suggestion-${index}"]`;
    await this.page.locator(selector).first().click();
  }
}
 
export class DyE2E_ColorPickerPageObject {
  constructor(
    private readonly page: Page,
    private readonly fieldTestId: string,
  ) {}
 
  /** Hex-value fill (pl. '#ff00aa'). */
  async setColor(hexValue: string): Promise<void> {
    await this.page.getByTestId(this.fieldTestId).fill(hexValue);
  }
 
  async getCurrentColor(): Promise<string> {
    return (await this.page.getByTestId(this.fieldTestId).inputValue()) ?? '';
  }
}
 
export class DyE2E_FilePageObject {
  constructor(
    private readonly page: Page,
    private readonly fieldTestId: string,
  ) {}
 
  /** Egy vagy több fájl upload Playwright `setInputFiles`-szel. */
  async upload(filePaths: string | string[]): Promise<void> {
    await this.page.getByTestId(this.fieldTestId).setInputFiles(filePaths);
  }
 
  /** Egy file-input clear (üres fájl-array). */
  async clear(): Promise<void> {
    await this.page.getByTestId(this.fieldTestId).setInputFiles([]);
  }
}
 
export class DyE2E_RichTextPageObject {
  constructor(
    private readonly page: Page,
    private readonly fieldTestId: string,
  ) {}
 
  /** Contenteditable scope-on belüli fill (Wave-2 base). */
  async fill(text: string): Promise<void> {
    const editor: Locator = this.page.locator(`[data-testid="${this.fieldTestId}"] [contenteditable="true"]`).first();
    await editor.fill(text);
  }
 
  /** Pure-text content read. */
  async textContent(): Promise<string> {
    const editor: Locator = this.page.locator(`[data-testid="${this.fieldTestId}"] [contenteditable="true"]`).first();
    return (await editor.textContent()) ?? '';
  }
}