import { expect, Locator, Page } from '@playwright/test'; /** The agency overview. */ export class DashboardPage { readonly greeting: Locator; readonly tiles: Locator; readonly recentRows: Locator; readonly topRoutes: Locator; constructor(private readonly page: Page) { this.greeting = page.locator('h1'); this.tiles = page.locator('.tile'); this.recentRows = page.locator('table.data tbody tr'); this.topRoutes = page.locator('.route-row'); } async goto(): Promise { await this.page.goto('/dashboard'); await this.settled(); } async settled(): Promise { await expect(this.page.locator('.skeleton')).toHaveCount(0); await expect(this.tiles.first()).toBeVisible(); } /** Reads one headline figure by its label, e.g. "Revenue" or "Seats sold". */ async tileValue(label: string): Promise { const tile = this.tiles.filter({ has: this.page.locator('.tile-label', { hasText: label }) }); const text = await tile.locator('.tile-value').innerText(); return Number(text.replace(/[^0-9.]/g, '')); } }