diff --git a/playwright-tests/framework/TestPages.ts b/playwright-tests/framework/TestPages.ts index bc98e44b5..7ec1b5da7 100644 --- a/playwright-tests/framework/TestPages.ts +++ b/playwright-tests/framework/TestPages.ts @@ -33,8 +33,10 @@ import { EndorsementsPage } from "../pages/EndorsementsPage" import { PolicyDriverPage } from "../pages/PolicyDriverPage" import { ServiceZipPage } from "../pages/ServiceZipPage" import { MobileDetailsPage } from "pages/MobileDetailsPage"; +import { BailoutPage } from '../pages/BailoutPage'; export interface ITestPages { + bailoutPage: BailoutPage, capabilityQuestionsPage: CapabilityQuestionsPage, ccPolicyInfoPage: CCPolicyInfoPage, contactDetailsPage: ContactDetailsPage, @@ -72,6 +74,7 @@ export interface ITestPages { export const createTestPages: TestPagesFactory = (page: Page) => { const pages: ITestPages = { + bailoutPage: new BailoutPage(page), capabilityQuestionsPage: new CapabilityQuestionsPage(page), ccPolicyInfoPage: new CCPolicyInfoPage(page), contactDetailsPage: new ContactDetailsPage(page), diff --git a/playwright-tests/pages/BailoutPage.ts b/playwright-tests/pages/BailoutPage.ts new file mode 100644 index 000000000..002464e9b --- /dev/null +++ b/playwright-tests/pages/BailoutPage.ts @@ -0,0 +1,51 @@ +import { type Locator, type Page, expect } from '@playwright/test'; +import { BasePage } from './BasePage'; +import { step } from 'framework/localTypes/Step'; +import { ICustomerDetails } from 'safelite-playwright-core'; +import { ITestData } from 'framework/TestData'; + +export class BailoutPage extends BasePage { + readonly page: Page; + readonly firstNameTextBox: Locator; + readonly lastNameTextBox: Locator; + readonly emailAddressTextBox: Locator; + readonly phoneNumberTextBox: Locator; + readonly textOptInBox: Locator; + + constructor(page: Page) { + super(page); + this.page = page; + + this.firstNameTextBox = this.page.getByRole('textbox', { name: 'First name' }); + this.lastNameTextBox = this.page.getByRole('textbox', { name: 'Last name' }); + this.emailAddressTextBox = this.page.getByRole('textbox', { name: 'Email address' }); + this.phoneNumberTextBox = this.page.getByRole('textbox', { name: 'Phone number' }); + this.textOptInBox = this.page.getByRole('checkbox', { name: 'Opt in to SMS' }); + } + + async fillOutBailoutForm(customerDetails: ICustomerDetails) { + await this.firstNameTextBox.fill(customerDetails!.firstName!); + await this.lastNameTextBox.fill(customerDetails!.lastName!); + await this.emailAddressTextBox.fill(customerDetails!.email!); + await this.phoneNumberTextBox.fill(customerDetails!.phoneNumber!); + } + + async checkTextMeUpdates(customerDetails: ICustomerDetails) { + await this.textOptInBox.check(); + } + + @step("BailoutPage >> Fill out bailout form: ") + async handleBailoutPage(testData: Partial) { + + const { customerDetails } = testData; + + await expect(this.page).toHaveURL(/bailout/); + await this.fillOutBailoutForm(customerDetails!); + + if (testData.isOptedInForTextMessages) { + await this.checkTextMeUpdates(customerDetails!); + } + + await this.nextPage(); + } +} diff --git a/playwright-tests/tests/0000__M.test.ts b/playwright-tests/tests/0000__M.test.ts index 987bd542a..ec6ad718d 100644 --- a/playwright-tests/tests/0000__M.test.ts +++ b/playwright-tests/tests/0000__M.test.ts @@ -41,6 +41,7 @@ import { getTestObject, TestCase, prepareTest, RuleEngine, TestInfo } from 'fram import { createTestPages } from "framework/TestPages"; import cashReplaceSwitchToInsuranceProgressiveNoCompTests from "./CashReplaceSwitchToInsuranceProgressiveNoComp"; import insuranceBigTruckVerifiedTests from "./InsuranceBigTruckVerified"; +import partsNotFoundBailoutTests from "./PartsNotFoundBailout"; import insuranceUnverifiedTests from "./InsuranceUnverified"; import CashReplaceSplitWindshieldTests from "./CashReplaceSplitWindshield"; import insuranceMeemicNearSchoolVerifiedTests from "./InsuranceMeemicNearSchoolVerified"; @@ -101,6 +102,7 @@ const allStandardTests = [ // {name: "InsuranceGeico", tests: insuranceGeicoTests}, // {name: "InsuranceITACOptimizedPriceValidationAllState", tests: insuranceITACOptimizedPriceValidationAllStateTests} { name: "InsuranceMeemicNearSchoolVerified", tests: insuranceMeemicNearSchoolVerifiedTests }, + { name: "PartsNotFoundBailout", tests: partsNotFoundBailoutTests }, ]; @@ -275,6 +277,12 @@ async function runWorkflow(page: Page, testCase: TestCase) { await serviceZipPage.handleServiceZipPage(testCase.testData); } + // Handle bailout page if parts bailout scenario + if (testCase.testData.bailoutFlags?.isVehicleLookupBailout) { + let bailoutPage = testCase.pages.bailoutPage; + await bailoutPage.handleBailoutPage(testCase.testData); + } + // Handle part questions if applicable if (partQuestions && partQuestions.length > 0) { let partQuestionsPage = testCase.pages.partQuestionsPage; diff --git a/playwright-tests/tests/PartsNotFoundBailout.ts b/playwright-tests/tests/PartsNotFoundBailout.ts new file mode 100644 index 000000000..1ec10c36c --- /dev/null +++ b/playwright-tests/tests/PartsNotFoundBailout.ts @@ -0,0 +1,52 @@ +import { ITestData, getDefaultExperimentsData } from 'framework/TestData'; +import { VehicleDamage, VehicleLookupType } from 'safelite-playwright-core'; +import { ITestCase } from '../framework/Typedefs'; +import { getDefaultTestData, setFakerSeedFromTestName } from 'safelite-playwright-core'; + +setFakerSeedFromTestName("CashDiamondReoBailout"); + +const partsNotFoundBailoutTestData: Partial = { + ...getDefaultTestData(), + + isHeavyTruck: true, + + customerDetails: { + ...getDefaultTestData().customerDetails!, + address: { + ...getDefaultTestData().customerDetails!.address, + postalCode: '43085' + } + }, + + vehicleDetails: { + ...getDefaultTestData().vehicleDetails!, + year: '1974', + make: 'Diamond Reo', + model: 'CF65', + style: 'cabover', + vehicleLookupType: VehicleLookupType.Zip, + }, + + vehicleDamage: [ + VehicleDamage.WindshieldCrack + ], + + bailoutFlags: { + isVehicleLookupBailout: true + }, + + experiments: { + ...getDefaultExperimentsData() + } +}; + +const partsNotFoundBailoutTests: ITestCase[] = []; + +const tc = { + name: `PartsNotFoundBailout`, + tags: ['@E2E', '@PartsNotFoundBailout', '@test_report', '@Bailout'], + testData: partsNotFoundBailoutTestData +}; +partsNotFoundBailoutTests.push(tc); + +export default partsNotFoundBailoutTests;