Skip to content
Source
Sign inSign up
TanStack/devtools
Open History to see the last commit

devtools.ts

44 lines1.0 KB

1import { SELECTORS } from '../selectors'
2import type { TabId } from '../selectors'
3import type { Page, Locator } from '@playwright/test'
4​
5export 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 }