import test, { expect, type Locator, type Page } from '@playwright/test'; import { BasePage } from './BasePage'; export class ProviderPreferencePage extends BasePage { readonly page: Page; readonly scheduleWithSafelite: Locator; readonly scheduleWithOther: Locator; readonly acknowledgeAdasButton: Locator; readonly gotItButton: Locator; readonly acknowledgeCheckbox: Locator; readonly stateLawModalHeading: Locator; issPageValue = 'provider-preference'; constructor(page: Page) { super(page); this.page = page; // this.scheduleWithSafelite = this.page.locator('div').filter({ hasText: /Schedule online with |Safelite AutoGlass/ }).first(); this.scheduleWithSafelite = this.page.getByText(/Schedule online with|Safelite AutoGlass/).first(); this.scheduleWithOther = this.page.getByText(/Find another shop|Choose my own shop/).first(); this.acknowledgeAdasButton = this.page.getByLabel('I acknowledge that my vehicle'); this.gotItButton = this.page.getByRole('button', { name: 'Got it' }); this.acknowledgeCheckbox = this.page.locator('#tpaAcknowledgement'); this.stateLawModalHeading = this.page.getByRole('heading').filter({ hasText: /.* State Law/}); } async selectProvider(isSafelite = true) { if (isSafelite) { await this.scheduleWithSafelite.click(); await this.nextPage(); } else { await this.scheduleWithOther.waitFor({ state: 'visible' }); await this.scheduleWithOther.click(); await this.continueButton.click(); //if(await this.acknowledgeAdasButton.isEnabled({timeout: 2500})){ // await this.acknowledgeAdasButton.click(); // await this.gotItButton.click(); // await this.page.waitForTimeout(1000); //} } } async acknowledgeRecalNotificaiton() { await this.acknowledgeAdasButton.click(); await this.gotItButton.click(); } async validateStateLawModalIsVisible() { await expect.soft(this.stateLawModalHeading).toBeVisible(); } }