diff --git a/playwright-tests/framework/TestPages.ts b/playwright-tests/framework/TestPages.ts index c2cc04b35..bc98e44b5 100644 --- a/playwright-tests/framework/TestPages.ts +++ b/playwright-tests/framework/TestPages.ts @@ -20,6 +20,7 @@ import VehiclePartQuestionsPage from "../pages/VehiclePartsPage" import CapabilityQuestionsPage from "../pages/CapabilityQuestionsPage" import MoldingQuestionsPage from "../pages/MoldingQuestionsPage" import { InsuranceCompanyPage } from "../pages/InsuranceCompanyPage" +import { InsuranceDetailsPage } from "../pages/InsuranceDetailsPage" import { CCPolicyInfoPage } from "../pages/CCPolicyInfoPage" import { DuplicateCheckPage } from "../pages/DuplicateCheckPage" import { PolicyVehiclesPage } from "../pages/PolicyVehiclesPage" @@ -42,6 +43,7 @@ export interface ITestPages { estimatePage: EstimatePage, homePage: HomePage, insuranceCompanyPage: InsuranceCompanyPage, + insuranceDetailsPage: InsuranceDetailsPage, leadgenHomePage: LeadgenHomePage, moldingQuestionsPage: MoldingQuestionsPage, orderConfirmationPage: OrderConfirmationPage, @@ -78,6 +80,7 @@ export const createTestPages: TestPagesFactory = (page: Page) => { estimatePage: new EstimatePage(page), homePage: new HomePage(page), insuranceCompanyPage: new InsuranceCompanyPage(page), + insuranceDetailsPage: new InsuranceDetailsPage(page), leadgenHomePage: new LeadgenHomePage(page), moldingQuestionsPage: new MoldingQuestionsPage(page), orderConfirmationPage: new OrderConfirmationPage(page), diff --git a/playwright-tests/pages/InsuranceDetailsPage.ts b/playwright-tests/pages/InsuranceDetailsPage.ts new file mode 100644 index 000000000..4b00e98a3 --- /dev/null +++ b/playwright-tests/pages/InsuranceDetailsPage.ts @@ -0,0 +1,61 @@ +import { type Locator, type Page } from '@playwright/test'; +import { BasePage } from './BasePage'; +import { step } from 'framework/localTypes/Step'; +import { ITestData } from 'framework/TestData'; +import { ProgressBarPercentages } from 'framework/localTypes/Enums'; + +export class InsuranceDetailsPage extends BasePage { + + readonly page: Page; + readonly insuranceCompany: Locator; + readonly policyNumber: Locator; + readonly dateOfLoss: Locator; + readonly damageCause: Locator; + readonly claimNumber: Locator; // conditional — only shown for certain insurers like Kentucky Farm Bureau + readonly streetAddress: Locator; + readonly apartment: Locator; + readonly city: Locator; + readonly policyState: Locator; + readonly policyZip: Locator; + + constructor(page: Page) { + super(page); + this.page = page; + + this.insuranceCompany = page.getByLabel('Insurance company'); + this.policyNumber = page.getByLabel('Policy number'); + this.dateOfLoss = page.getByLabel('Approximate date of loss'); + this.claimNumber = page.getByLabel('Claim Number'); + this.damageCause = page.getByLabel('How did the damage occur?'); + this.streetAddress = page.getByLabel('Street address'); + this.apartment = page.getByLabel('Apt. number (optional)'); + this.city = page.getByLabel('City'); + this.policyState = page.getByLabel('State'); + this.policyZip = page.getByLabel('Zip'); + } + + private async populatePage(testData: Partial): Promise { + const { claimDetails, customerDetails } = testData; + + await this.policyNumber.fill(claimDetails!.policyNumber); + await this.dateOfLoss.fill(claimDetails!.damageDate); + await this.damageCause.selectOption(claimDetails!.damageCause); + await this.streetAddress.fill(customerDetails!.address.street); + await this.apartment.fill(customerDetails!.address.aptNumber ?? ''); + await this.city.fill(customerDetails!.address.city); + await this.policyState.selectOption(customerDetails!.address.state); + await this.policyZip.fill(customerDetails!.address.postalCode); + + if (await this.claimNumber.isVisible()) { + await this.claimNumber.fill(claimDetails!.claimNumber ?? ''); + } + } + + @step("InsuranceDetailsPage >> Fill out insurance details for non integrated insurance flow") + async handleInsuranceDetailsPage(testData: Partial): Promise { + await this.validateProgressBar(ProgressBarPercentages.InsuranceDetailsPage); + await this.populatePage(testData); + await this.nextPage(); + } + +} \ No newline at end of file