diff --git a/playwright-tests/business-logic/types/ITestData.ts b/playwright-tests/business-logic/types/ITestData.ts index 61ed18128..72c6758fd 100644 --- a/playwright-tests/business-logic/types/ITestData.ts +++ b/playwright-tests/business-logic/types/ITestData.ts @@ -35,4 +35,5 @@ export interface ITestData { promoCode: string, policyZip: string, isPolicyUnverified: boolean + isCashToInsurance: boolean } \ No newline at end of file diff --git a/playwright-tests/pages/OrderConfirmationPage.ts b/playwright-tests/pages/OrderConfirmationPage.ts index 489ed1678..64348fea4 100644 --- a/playwright-tests/pages/OrderConfirmationPage.ts +++ b/playwright-tests/pages/OrderConfirmationPage.ts @@ -43,7 +43,7 @@ export class OrderConfirmationPage extends BasePage { async validateOrderConfirmationPage(testData: Partial) { // Destructure data we use - const { vehicleDetails, customerDetails, servicePackage, promoCode, + const { vehicleDetails, customerDetails, servicePackage, promoCode, isCashToInsurance: isCashInsuranceFlow, isPolicyFound, claimDetails, paymentDetails, isUseVehicleOnPolicy, paymentMethod, isPolicyUnverified } = testData; await this.serviceText.waitFor({ state: "visible" }); @@ -61,7 +61,7 @@ export class OrderConfirmationPage extends BasePage { const servicePackageAmt = Number.parseFloat(servicePackageValue!.split('$')[1].replaceAll(',', '')); // General Validations - expect.soft(emailTextValue).toContain(customerDetails!.email); + expect.soft(emailTextValue?.toLowerCase()).toContain(customerDetails!.email); // Service package validations await expect.soft(this.cartServicePackageText).toContainText(`${servicePackage}`) @@ -91,14 +91,14 @@ export class OrderConfirmationPage extends BasePage { expect.soft(subtotalAmt).toBeGreaterThan(0); // expect.soft(deductibleAmt).toEqual(0); - if (paymentDetails!.paymentType === PaymentType.PayAtService && (servicePackageAmt > 0)) { + if ((paymentDetails!.paymentType === PaymentType.PayAtService || isCashInsuranceFlow) && (servicePackageAmt > 0)) { // Verify amount due > 0 expect.soft(amountDueAmt).toBeGreaterThan(0); expect.soft(finalAmountDueAmt).toBeGreaterThan(0); - if (isPolicyUnverified && PaymentType.PayWithInsurance){ - expect.soft(finalAmountDueAmt).toContain('Verifying coverage') - } + if (isPolicyUnverified && PaymentType.PayWithInsurance){ + expect.soft(finalAmountDueAmt).toContain('Verifying coverage') + } } else { // Verify amount due 0 expect.soft(amountDueAmt).toEqual(0); diff --git a/playwright-tests/tests/0000__M.test.ts b/playwright-tests/tests/0000__M.test.ts index 213835484..e62fdeeb4 100644 --- a/playwright-tests/tests/0000__M.test.ts +++ b/playwright-tests/tests/0000__M.test.ts @@ -31,6 +31,7 @@ import cashRepairInShopAfterPayTests from "./CashRepairInShopAfterPay"; import cashRepairInShopPayPalTests from "./CashRepairInShopPayPal"; import cashReplaceMultiSlidingGlassDropoffTests from "./CashReplaceMultiSlidingGlassDropoff"; import cashReplaceMultiGlassMobileTests from "./CashReplaceMultiGlassMobile"; +import cashReplaceSwitchToInsuranceProgressiveNoCompTests from "./CashReplaceSwitchToInsuranceProgressiveNoComp"; import insuranceBigTruckVerifiedTests from "./InsuranceBigTruckVerified"; import insuranceUnverifiedTests from "./InsuranceUnverified"; @@ -69,6 +70,7 @@ const allStandardTests = [ {name: "CashReplaceWiperPromoInshop", tests: cashReplaceWiperPromoInShopTests}, {name: "InsuranceAcuityPaypal", tests: insuranceAcuityPaypalTests}, {name: "InsuranceITAC21stCentury", tests: insuranceITAC21stCenturyTests}, + {name: "CashReplaceSwitchToInsuranceProgressiveNoComp", tests: cashReplaceSwitchToInsuranceProgressiveNoCompTests}, {name: "InsuranceBigTruckVerified", tests: insuranceBigTruckVerifiedTests}, {name: "InsuranceUnverified", tests: insuranceUnverifiedTests}, // {name: "InsuranceGeico", tests: insuranceGeicoTests}, @@ -300,7 +302,7 @@ async function runWorkflow(page: Page, testCase: TestCase) { } export async function handleInsuranceFlow(testCase: TestCase) { - const { isPolicyFound, isPolicyDriver, endorsements, isRecalVehicle } = testCase.testData; + const { isPolicyFound, isPolicyDriver, endorsements, isRecalVehicle, isCashToInsurance: isCashInsuranceFlow } = testCase.testData; // Check if the insurance policy has endorsements const hasEndorsements = endorsements && endorsements.length > 0; @@ -353,4 +355,20 @@ export async function handleInsuranceFlow(testCase: TestCase) { //handle coveraage statement page let coverageStatementPage = testCase.pages.coverageStatementPage; await coverageStatementPage.handleCoverageStatementPage(testCase.testData); + + if (isCashInsuranceFlow) { + let serviceLocationPage = testCase.pages.serviceLocationPage; + await serviceLocationPage.nextPage(); + + //schedule + let schedulePage = testCase.pages.schedulePage; + await schedulePage.nextPage(); + //customer dertails + let contactDetailsPage = testCase.pages.contactDetailsPage; + await contactDetailsPage.nextPage(); + + //paymentmethods + let paymentMethodPage = testCase.pages.paymentMethodPage; + await paymentMethodPage.nextPage(); + } } \ No newline at end of file diff --git a/playwright-tests/tests/CashReplaceSwitchToInsuranceProgressiveNoComp.ts b/playwright-tests/tests/CashReplaceSwitchToInsuranceProgressiveNoComp.ts new file mode 100644 index 000000000..542f7e601 --- /dev/null +++ b/playwright-tests/tests/CashReplaceSwitchToInsuranceProgressiveNoComp.ts @@ -0,0 +1,80 @@ +//Imports here +import { ITestData } from "@business-logic/types/ITestData"; +import { PaymentMethod, AppointmentType, DamageType, PartQuestionType, PaymentType } from "@business-logic/types/Enums"; +import TestCase from "@business-logic/types/TestCase"; +import { getDefaultTestData, setFakerSeedFromTestName } from "@business-logic/constants/DefaultTestData"; + +// Set the seed for consistent data generation +setFakerSeedFromTestName("CashReplaceSwitchToInsuranceProgressiveNoComp"); + +// Define insurance test data for Progressive +const cashReplaceSwitchToInsuranceProgressiveNoCompData: Partial = { + ...getDefaultTestData(), + + isCashToInsurance: true, + + // Override customer details based on provided ZIP code + customerDetails: { + ...getDefaultTestData().customerDetails!, + address: { + ...getDefaultTestData().customerDetails!.address, + postalCode: "70458", + }, + }, + + // Vehicle details for a 2012 Chrysler 300 + vehicleDetails: { + ...getDefaultTestData().vehicleDetails!, + year: "2012", + make: "Chrysler", + model: "300", + style: "4 door sedan" + }, + + partQuestions: [ + { + partQuestionType: PartQuestionType.GeneralQuestion1, + isOnPage: true, + optionToSelect: 'Yes' + }, + ], + + // Override payment details + paymentDetails: { + paymentType: PaymentType.PayWithInsurance, // Ensures insurance payment method is selected + }, + + // Insurance claim details + claimDetails: { + client: "Progressive", + policyNumber: "Mock495646B", + policyDeductible: 0, + damageDate: new Date(new Date().setDate(new Date().getDate() - 1)).toLocaleDateString("en-US", { month: "2-digit", day: "2-digit", year: "numeric" }), + damageCause: DamageType.Rock, + }, + + isPolicyFound: true, + isUseVehicleOnPolicy: true, + isPolicyDriver: true, + + // Appointment details for in-shop service + appointmentDetails: { + serviceLocation: AppointmentType.InShop, + shopAddress: "8985 Yellow Brick Rd, Rosedale, MD 21237", + appointmentDate: getDefaultTestData().appointmentDetails?.appointmentDate, + }, + + +}; + +// Create and register the test case +const cashReplaceSwitchToInsuranceProgressiveNoCompTests: TestCase[] = []; + +const tc = new TestCase({ + name: `CashReplaceSwitchToInsuranceProgressiveNoComp`, + tags: ["@E2E", "@CashReplaceSwitchToInsuranceProgressiveNoComp", "@test_report", "@CASH"], + testData: cashReplaceSwitchToInsuranceProgressiveNoCompData, +}, undefined, "CashReplaceSwitchToInsuranceProgressiveNoComp"); +cashReplaceSwitchToInsuranceProgressiveNoCompTests.push(tc); + +export default cashReplaceSwitchToInsuranceProgressiveNoCompTests;