| 3 | import type { Page, Locator } from '@playwright/test' |
| 4 | |
| 5 | export class DevtoolsPage { |
| 6 | constructor(private readonly page: Page) {} |
| 7 | |
| 8 | async goto(path = '/') { |
| 9 | await this.page.goto(path) |
| 10 | } |
| 11 | |
| 12 | trigger(): Locator { |
| 13 | return this.page.getByRole('button', { name: SELECTORS.triggerName }) |
| 14 | } |
| 15 | |
| 16 | panel(): Locator { |
| 17 | return this.page.getByTestId(SELECTORS.mainPanel) |
| 18 | } |
| 19 | |
| 20 | async openViaTrigger() { |
| 21 | await this.trigger().click() |
| 22 | await this.expectOpen() |
| 23 | } |
| 24 | |
| 25 | async closeViaButton() { |
| 26 | await this.page.getByTestId(SELECTORS.closeButton).click() |
| 27 | } |
| 28 | |
| 29 | tab(id: TabId): Locator { |
| 30 | return this.page.getByTestId(SELECTORS.tab(id)) |
| 31 | } |
| 32 | |
| 33 | async isOpen(): Promise<boolean> { |
| 34 | return (await this.panel().getAttribute('data-open')) === 'true' |
| 35 | } |
| 36 | |
| 37 | async expectOpen() { |
| 38 | await this.panel().and(this.page.locator('[data-open="true"]')).waitFor() |
| 39 | } |
| 40 | |
| 41 | async expectClosed() { |
| 42 | await this.panel().and(this.page.locator('[data-open="false"]')).waitFor() |
| 43 | } |
| 44 | |
| 45 | // --- plugin workspace --- |
| 46 | |
| 47 | workspace(): Locator { |
nothing calls this directly
no outgoing calls
no test coverage detected