Add functions to validate provider preference page flow

This commit is contained in:
JennyNou 2026-03-10 13:41:06 -04:00
parent 80663bea23
commit 92f15d5019

View file

@ -3,34 +3,47 @@ import { BasePage } from './BasePage';
export class ProviderPreferencePage extends BasePage { export class ProviderPreferencePage extends BasePage {
readonly page: Page; readonly page: Page;
readonly scheduleWithSafelite: Locator; readonly scheduleNowButton: Locator;
readonly scheduleWithOther: Locator; readonly findAnotherShopButton: Locator;
readonly acknowledgeAdasButton: Locator;
readonly acknowledgeAdasCheckbox: Locator;
readonly gotItButton: Locator; readonly gotItButton: Locator;
readonly learnMoreLink: Locator;
readonly yesButton: Locator;
readonly noButton: Locator;
readonly acknowledgeCheckbox: Locator; readonly acknowledgeCheckbox: Locator;
readonly stateLawModalHeading: Locator; readonly stateLawModalText: Locator;
readonly stateLawModalOkayButton: Locator;
issPageValue = 'provider-preference'; issPageValue = 'provider-preference';
constructor(page: Page) { constructor(page: Page) {
super(page); super(page);
this.page = 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.scheduleNowButton = this.page.getByRole('button', { name: 'Schedule now' });
this.scheduleWithOther = this.page.getByText(/Find another shop|Choose my own shop/).first(); this.findAnotherShopButton = this.page.getByRole('link', { name: 'Find another shop' });
this.acknowledgeAdasButton = this.page.getByLabel('I acknowledge that my vehicle');
//Recal modal
this.learnMoreLink = this.page.locator('#moreDetails');
this.yesButton = this.page.getByRole('button', { name: 'Yes' }); // schedule with Safelite
this.noButton = this.page.getByRole('button', { name: 'No' }); // find another shop (TPA?)
this.acknowledgeAdasCheckbox = this.page.getByRole('checkbox', { name: 'tpaAcknowledgement' }); // shows up when user clicks no on recal modal
this.gotItButton = this.page.getByRole('button', { name: 'Got it' }); this.gotItButton = this.page.getByRole('button', { name: 'Got it' });
this.acknowledgeCheckbox = this.page.locator('#tpaAcknowledgement'); this.acknowledgeCheckbox = this.page.locator('#tpaAcknowledgement');
this.stateLawModalHeading = this.page.getByRole('heading').filter({ hasText: /.* State Law/}); this.stateLawModalText = this.page.getByText(/law prohibits us from requiring you.*You have the right to select the motor vehicle repair shop of your choice\./is);
this.stateLawModalOkayButton = this.page.getByRole('button', { name: 'Okay' })
} }
async selectProvider(isSafelite = true) { async selectProvider(isSafelite = true) {
if (isSafelite) { if (isSafelite) {
await this.scheduleWithSafelite.click(); await this.scheduleNowButton.click();
await this.nextPage(); await this.nextPage();
} }
else { else {
await this.scheduleWithOther.waitFor({ state: 'visible' }); await this.findAnotherShopButton.waitFor({ state: 'visible' });
await this.scheduleWithOther.click(); await this.findAnotherShopButton.click();
await this.continueButton.click(); await this.continueButton.click();
//if(await this.acknowledgeAdasButton.isEnabled({timeout: 2500})){ //if(await this.acknowledgeAdasButton.isEnabled({timeout: 2500})){
// await this.acknowledgeAdasButton.click(); // await this.acknowledgeAdasButton.click();
@ -39,12 +52,20 @@ export class ProviderPreferencePage extends BasePage {
//} //}
} }
} }
async acknowledgeRecalNotificaiton() { async scheduleWithSafeliteADAS() {
await this.acknowledgeAdasButton.click(); await this.learnMoreLink.click();
await this.gotItButton.click(); await this.yesButton.click();
await this.continueButton.click();
}
async scheduleTPAWithAdas() {
await this.learnMoreLink.click();
await this.noButton.click();
await this.acknowledgeAdasCheckbox.click();
await this.continueButton.click();
} }
async validateStateLawModalIsVisible() { async validateStateLawModalIsVisible() {
await expect.soft(this.stateLawModalHeading).toBeVisible(); await expect.soft(this.stateLawModalText).toBeVisible();
} }
} }