import { Locator, Page } from '@playwright/test'; /** * The cart, where the reservation countdown lives. * * The countdown is the reason this page object exists: it is the one place in * the app whose output depends on the clock, so a test has to be able to name * the text without re-deriving the locator each time. */ export class CartPage { readonly continueShoppingButton: Locator; readonly emptyNotice: Locator; constructor(private readonly page: Page) { this.continueShoppingButton = page.getByRole('button', { name: 'Continue Shopping' }); this.emptyNotice = page.getByText('Your cart is empty'); } async goto(): Promise { await this.page.goto('/cart'); } row(itemName: string): Locator { return this.page.getByRole('listitem').filter({ hasText: itemName }); } /** The "2h 15m left" / "expiring…" line for one held item. */ remaining(itemName: string): Locator { return this.row(itemName).getByText(/left|expiring/); } removeButton(itemName: string): Locator { return this.row(itemName).getByRole('button', { name: 'Remove' }); } }