import { Locator, Page } from '@playwright/test'; /** * The modal offered when a customer favorites an item: an opt-in to hear if it * sells, with the reason for asking. * * `getByRole('dialog')` unqualified is deliberate and safe — the storefront * shows one modal at a time, and a signed-out visitor clicking the heart gets * the auth prompt instead, which is a different object. * * The opt-in is deliberately not the marketing consent. Accepting item alerts * must not sign anyone up for marketing, which is why the tests read both flags * back off the API rather than trusting the copy. */ export class FavoritePrompt { readonly dialog: Locator; readonly acceptAlertsButton: Locator; readonly declineAlertsButton: Locator; constructor(page: Page) { this.dialog = page.getByRole('dialog'); this.acceptAlertsButton = this.dialog.getByRole('button', { name: 'Yes, email me' }); this.declineAlertsButton = this.dialog.getByRole('button', { name: 'No thanks' }); } async acceptAlerts(): Promise { await this.acceptAlertsButton.click(); } /** Declining keeps the favorite; only the alerts are refused. */ async declineAlerts(): Promise { await this.declineAlertsButton.click(); } }