Skip to content

Commit

Permalink
feat(playwright): make fields private
Browse files Browse the repository at this point in the history
  • Loading branch information
ilyamore88 committed Aug 28, 2024
1 parent b6772e2 commit d28dac5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
18 changes: 9 additions & 9 deletions packages/playground/tests/fixtures/PlaygroundPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@ import type { Locator, Page } from '@playwright/test';
* Playground page fixture to help access the page elements
*/
export class PlaygroundPage {
private readonly inputLocator: Locator;
private readonly textareaLocator: Locator;
private readonly contenteditableLocator: Locator;
readonly #input: Locator;
readonly #textarea: Locator;
readonly #contenteditable: Locator;

/**
* Sets locators for input, textarea and contenteditable elements
*
* @param page - Playwright page object
*/
constructor(public readonly page: Page) {
this.inputLocator = page.locator('input');
this.textareaLocator = page.locator('textarea');
this.contenteditableLocator = page.locator('[contenteditable]').first(); // hack to get the first contenteditable element
this.#input = page.locator('input');
this.#textarea = page.locator('textarea');
this.#contenteditable = page.locator('[contenteditable]').first(); // hack to get the first contenteditable element
}

/**
Expand All @@ -30,20 +30,20 @@ export class PlaygroundPage {
* Returns the native input locator
*/
public get input(): Locator {
return this.inputLocator;
return this.#input;
}

/**
* Returns the textarea locator
*/
public get textarea(): Locator {
return this.textareaLocator;
return this.#textarea;
}

/**
* Returns the contenteditable locator
*/
public get contenteditable(): Locator {
return this.contenteditableLocator;
return this.#contenteditable;
}
}
1 change: 1 addition & 0 deletions packages/playground/tsconfig.playwright.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"strict": true,
},
Expand Down

0 comments on commit d28dac5

Please sign in to comment.