diff --git a/playwright-tests/tests/0000__M.test.ts b/playwright-tests/tests/0000__M.test.ts index 9026a21a..0e3fa2a5 100644 --- a/playwright-tests/tests/0000__M.test.ts +++ b/playwright-tests/tests/0000__M.test.ts @@ -5,7 +5,7 @@ import { RuleEngine, ValidationOptions } from "@business-logic/types/RuleEngine" import { ICustomerDetails } from "@business-logic/types/CustomerDetails"; import essentialHpTestCases from "./0016_EssentialRepairInShop"; import essentialReplaceTestCases from "./0013_EssentialReplace"; -import { BailoutCode, VehicleDamage, VehicleLookupType } from "@business-logic/types/Enums"; +import { BailoutCode, ServiceLocation, VehicleDamage, VehicleLookupType } from "@business-logic/types/Enums"; import essentialTpaNotEnabledTestCases from "./0003_EssentialTpaNotEnabledBailout"; import essentialDoNotSeeShopTestCases from "./0011_EssentialDoNotSeeShopBailout"; import essentialVehicleNotFoundTestCases from "./0010_EssentialVehicleNotFoundBailout"; @@ -61,6 +61,7 @@ import advancedScenario0029aTestCases from "./advanced/0029a_HeavyVehicleBailout import advancedScenario0030aTestCases from "./advanced/0030a_PartsServiceBailout"; import advancedScenario0031aTestCases from "./advanced/0031a_ReplaceServiceableBigTruck"; import advancedScenario0032aTestCases from "./advanced/0032a_DeclineNonServiceableBigTruck"; +import { getDefaultTestData } from "safelite-playwright-core"; @@ -382,8 +383,8 @@ async function runWorkflow(page: Page, testCase: TestCase) { // Destructure data for easy access const { customerDetails, claimDetails, vehicleDetails, vehicleDamage, appointmentDetails, isSafelite, endorsements, - partQuestions, paymentDetails, isNoComp, isItac, isRecalNotification, - isRecalWarning, servicePackage, hasStateLawPopup, otherVehiclesOnPolicy, + partQuestions, paymentDetails, isNoComp, isItac, isRecalNotification, isUnverifiedPolicyAfterVehicleLookup, + isRecalWarning, servicePackage, hasOemEndorsement, hasStateLawPopup, otherVehiclesOnPolicy, isSeparateApptsWarning, vehiclePartQuestions, editVehicleDetails, isAddressLookupValidations, hasMilitaryWarning, capabilityQuestions, isUseVehicleOnPolicy, isVehicleLookupValidations, isMoldingQuestion, isNonServiceable, isNonServiceableVin } = testCase.testData; @@ -401,7 +402,7 @@ async function runWorkflow(page: Page, testCase: TestCase) { vehiclePartQuestionsPage, capabilityQuestionsPage, moldingQuestionsPage, addressLookupPage } = testCase.pages; // Destructure bailout flags - const { isVehicleSelectBailout, isDoNotSeeMyShopBailout, isTpaNotEnabledBailout, + const { isVehicleSelectBailout, isTpaNotEnabledBailout, isPartsServiceErrorBailout, isVehicleLookupBailout, isPriceServiceErrorBailout, isRequestCallbackBailout } = testCase.testData.bailoutFlags || {}; @@ -420,7 +421,7 @@ async function runWorkflow(page: Page, testCase: TestCase) { await test.step('WelcomePage >> Populate Customer Details', async () => { await welcomePage.populatePage(customerDetails!, claimDetails!, await welcomePage.hasCityInfo()); - await welcomePage.nextPage(); + await welcomePage.GetStartedButton.click(); }); if (testCase.testData.isDuplicateClaim) { @@ -445,26 +446,28 @@ async function runWorkflow(page: Page, testCase: TestCase) { } } if (!(isUseVehicleOnPolicy ?? true)) { - await policyVehiclesPage.selectVehicleNotListed(); + await policyVehiclesPage.addAnotherVehicle(); await policyVehiclesPage.nextPage(); await vehicleSelectionPage.selectVehicle(vehicleDetails!); await policyVehiclesPage.nextPage(); + + await test.step('PolicyHolderDetailsPage >> Enter customer data', async () => { + await policyHolderDetailsPage.validateURL(policyHolderDetailsPage.issPageValue); + await policyHolderDetailsPage.fillCustomerDetails(customerDetails!); + await policyHolderDetailsPage.nextPage(); + }); } else { // Select vehicle await policyVehiclesPage.selectVehicle(vehicleDetails!); + if (isNonServiceable) { await policyVehiclesPage.assertNonServiceableAlertBehavior(); return; } await policyVehiclesPage.nextPage(); - } - }); + await policyVehiclesPage.logReferralNumber(); - if (isNonServiceable) { - return; - } - - if (hasEndorsements) { + if (hasEndorsements) { await test.step('EndorsementsPage >> Select Endorsements', async () => { await endorsementsPage.validateURL(endorsementsPage.issPageValue); await endorsementsPage.verifyEndorsements(endorsements); @@ -472,20 +475,23 @@ async function runWorkflow(page: Page, testCase: TestCase) { await endorsementsPage.nextPage(); }); } - - } else { - await policyVehiclesPage.logReferralNumber(); - await test.step('PolicyHolderDetailsPage >> Enter customer data', async () => { - await policyHolderDetailsPage.validateURL(policyHolderDetailsPage.issPageValue); - await policyHolderDetailsPage.fillCustomerDetails(customerDetails!); - await policyHolderDetailsPage.nextPage(); + await test.step('PolicyHolderDetailsPage >> Enter customer data', async () => { + await policyHolderDetailsPage.validateURL(policyHolderDetailsPage.issPageValue); + await policyHolderDetailsPage.fillCustomerDetails(customerDetails!); + await policyHolderDetailsPage.nextPage(); }); + } + }); + + if (isNonServiceable) { + return; + } if (isVehicleLookupBailout) { forceAPIError(page, '/vehicle/api/v1/vehicle/lookup') } - await test.step('VehicleDetailsPage >> Select Vehicle', async () => { + /*await test.step('VehicleDetailsPage >> Select Vehicle', async () => { await vehicleSelectionPage.validateURL(vehicleSelectionPage.issPageValue); await vehicleSelectionPage.selectVehicle(vehicleDetails!); if (isNonServiceable) { @@ -493,7 +499,7 @@ async function runWorkflow(page: Page, testCase: TestCase) { return; } await vehicleSelectionPage.nextPage(); - }); + });*/ if (isNonServiceable) { return; @@ -508,20 +514,26 @@ async function runWorkflow(page: Page, testCase: TestCase) { } } - if (editVehicleDetails) { - isPolicyFound = false; // Flow proceeds as unverified + // Essential flow when policy is not found + if (isPolicyFound === false) { testCase.testData.isPolicyFound = false; - await test.step('VehicleDamagePage >> Click Edit Vehicle', async () => { + /* await test.step('VehicleDamagePage >> Click Edit Vehicle', async () => { await vehicleDamagePage.validateURL(vehicleDamagePage.issPageValue); await vehicleDamagePage.editVehicleButton.click(); }); + */ // commented out for now because is there an edit vehicle flow? - await test.step('VehicleDetailsPage >> Select edited vehicle', async () => { - await test.step('VehicleDetailsPage >> Select Vehicle', async () => { + await test.step('VehicleSelectionPage >> Select vehicle for essential flow', async () => { await vehicleSelectionPage.validateURL(vehicleSelectionPage.issPageValue); - await vehicleSelectionPage.selectVehicle(editVehicleDetails); + await vehicleSelectionPage.selectVehicle(vehicleDetails!); await vehicleSelectionPage.nextPage(); - }); + }); + + await test.step('PolicyHolderDetailsPage >> Enter customer data', async () => { + await policyHolderDetailsPage.validateURL(policyHolderDetailsPage.issPageValue); + await policyHolderDetailsPage.fillCustomerDetails(customerDetails!); + + await policyHolderDetailsPage.nextPage(); }); } @@ -584,10 +596,14 @@ async function runWorkflow(page: Page, testCase: TestCase) { await test.step('Address Lookup validations >> Vehicle Lookup by address: ' + customerDetails!.address.street, async () => { if (Array.isArray(vehicleDetails?.address)) { await addressLookupPage.validateURL(addressLookupPage.issPageValue); - await addressLookupPage.validateAddressLookupAlerts(vehicleDetails?.address); + await addressLookupPage.validateAddressLookupAlerts(vehicleDetails?.address!); await addressLookupPage.nextPage(); } }); + + await test.step('Address Vehicles >> Next page', async () => { + await addressLookupPage.nextPage(); + }); } else { await test.step('VehicleLookupAddressPage >> Lookup by address: ' + customerDetails!.address.street, async () => { await vehicleLookupAddressPage.validateURL(vehicleLookupAddressPage.issPageValue); @@ -627,6 +643,7 @@ async function runWorkflow(page: Page, testCase: TestCase) { break; } } + if (isMoldingQuestion) { await test.step('Molding Questions Page >> Select Yes', async () => { await moldingQuestionsPage.validateURL(moldingQuestionsPage.issPageValue); @@ -637,6 +654,7 @@ async function runWorkflow(page: Page, testCase: TestCase) { await moldingQuestionsPage.nextPage(); }); } + if (capabilityQuestions && capabilityQuestions.length > 0) { await capabilityQuestionsPage.validateURL(capabilityQuestionsPage.issPageValue); await capabilityQuestionsPage.validatePartQuestions(capabilityQuestions); @@ -645,6 +663,7 @@ async function runWorkflow(page: Page, testCase: TestCase) { } if (partQuestions && partQuestions.length > 0) { + let partQuestionsPage = testCase.pages.partQuestionsPage; await partQuestionsPage.validateURL(partQuestionsPage.issPageValue); await partQuestionsPage.validatePartQuestions(partQuestions); await partQuestionsPage.selectPartQuestionResponses(partQuestions); @@ -653,12 +672,13 @@ async function runWorkflow(page: Page, testCase: TestCase) { if (vehiclePartQuestions && vehiclePartQuestions.length > 0) { await vehiclePartQuestionsPage.validateURL(vehiclePartQuestionsPage.issPageValue); - await vehiclePartQuestionsPage.validatePartQuestions(vehiclePartQuestions); + //await vehiclePartQuestionsPage.validatePartQuestions(vehiclePartQuestions); await vehiclePartQuestionsPage.selectPartQuestionResponses(vehiclePartQuestions); await vehiclePartQuestionsPage.nextPage(); } + if (isRequestCallbackBailout) { - await test.step('CoverageStatementPage >> Cancel My claim', async () => { + await test.step('CoverageStatementPage >> Cancel my claim', async () => { await coverageStatementPage.validateURL(coverageStatementPage.issPageValue); await coverageStatementPage.cancelMyClaim(); }); @@ -669,44 +689,95 @@ async function runWorkflow(page: Page, testCase: TestCase) { }); return; } + await test.step('CoverageStatementPage >> Next page', async () => { await coverageStatementPage.validateURL(coverageStatementPage.issPageValue); - // Confirm no coverage - if (isPolicyFound && (isItac || isNoComp)) { - await coverageStatementPage.continueToScheduleButton.click(); - } - await coverageStatementPage.nextPage(); + if (hasOemEndorsement) { + await coverageStatementPage.validateOEMBullet(); + } + // For essential/unverified flows + if (!isPolicyFound) { + await coverageStatementPage.handleUnverifiedFlow(claimDetails!); + } + + // For No Comp flows + if (isPolicyFound && isNoComp === true) { + await coverageStatementPage.handleNoCompFlow(); + } + + // For ITAC flows + if (isPolicyFound && isItac === true) { + await coverageStatementPage.handleITACFlow(); + } + + // For replacements with deductible + if (isPolicyFound && claimDetails?.policyDeductible! > 0 && claimDetails?.policyDeductible !== 9999 && testCase.testData.isUnverifiedPolicyAfterVehicleLookup !== true) { + await coverageStatementPage.handleReplacementWithDeductibleFlow(claimDetails!); + } + + // For replacements or repairs with 0 deductible + if (isPolicyFound && claimDetails?.policyDeductible === 0) { + await coverageStatementPage.handleReplacementOrRepairWithNoDeductibleFlow(claimDetails!, VehicleDamage!); + } + + // For unverified policy after vehicle lookup + if (isPolicyFound && testCase.testData.isUnverifiedPolicyAfterVehicleLookup === true) { + await coverageStatementPage.handleUnverifiedPolicyAfterVehicleLookupFlow(); + } + }); if (hasStateLawPopup) { await test.step('ProviderPreferencePage >> Dismiss state law popup', async () => { await providerPreferencePage.validateURL(providerPreferencePage.issPageValue); - await providerPreferencePage.validateStateLawModalIsVisible(); - await providerPreferencePage.gotItButton.click(); - }); + if (vehicleDamage!.includes(VehicleDamage.WindshieldCrack)) { + //await providerPreferencePage.validateStateLawModalIsVisible(); + await providerPreferencePage.stateLawModalOkayButton.click(); + } else { + //await providerPreferencePage.validateStateLawRepairModalIsVisible(); + await providerPreferencePage.stateLawModalOkayButton.click(); + } + }); } - if (!isPolicyFound || !(isItac || isNoComp)) { + if (!isPolicyFound || !(isItac || isNoComp) && !isUnverifiedPolicyAfterVehicleLookup) { await test.step('ProviderPreferencePage >> Select Provider ' + isSafelite ? "Safelite" : "Other shops(Non-Safelite)", async () => { await providerPreferencePage.validateURL(providerPreferencePage.issPageValue); await providerPreferencePage.selectProvider(isSafelite); + }); } - // validations for Recal warning mesage - if (isRecalWarning) { + if (isSafelite && isUnverifiedPolicyAfterVehicleLookup) { + await test.step('ProviderPreferencePage >> Select Provider ' + isSafelite ? "Safelite" : "Other shops(Non-Safelite)", async () => { + await providerPreferencePage.validateURL(providerPreferencePage.issPageValue); + await providerPreferencePage.selectProvider(isSafelite); + + }); + } + + // validations for Recal warning mesage on schedule page + // commented out for now will add back in to validate recal banner on schedule page + /*if (isRecalWarning) { await serviceLocationPage.validateURL(serviceLocationPage.issPageValue); await serviceLocationPage.validateRecalWarning(); - } + }*/ // if isRecalNotifidation flag true additional step to acknowledge Recal notification. if (isRecalNotification) { await providerPreferencePage.validateURL(providerPreferencePage.issPageValue); - await providerPreferencePage.acknowledgeRecalNotificaiton(); + //await providerPreferencePage.acknowledgeRecalNotificaiton(); + } + + if (!isSafelite && isUnverifiedPolicyAfterVehicleLookup) { + await test.step('ProviderPreferencePage >> Schedule TPA without Adas', async () => { + await providerPreferencePage.validateURL(providerPreferencePage.issPageValue); + await providerPreferencePage.scheduleTPAWithoutAdas(); + }); } // If No-Comp or ITAC, ProviderPreferencePage does not appear - if (!isPolicyFound || !(isItac || isNoComp)) { + if (!isPolicyFound || !(isItac || isNoComp) || isUnverifiedPolicyAfterVehicleLookup) { if (!isSafelite) { @@ -728,16 +799,6 @@ async function runWorkflow(page: Page, testCase: TestCase) { return; } - if (isDoNotSeeMyShopBailout) { - await test.step('TpaSearchPage >> Select "Do Not See My Shop"', async () => { - await tpaSearchPage.validateURL(tpaSearchPage.issPageValue); - await tpaSearchPage.selectDoNotSeeMyShop(); - }); - await bailoutPage.validateURL(bailoutPage.issPageValue); - await bailoutPage.validateBailoutDetails(customerDetails!, BailoutCode.DoNotSeeMyShop); - return; - } - await test.step('TpaSearchPage >> TPA Search', async () => { await tpaSearchPage.validateURL(tpaSearchPage.issPageValue); await tpaSearchPage.selectFirstLocation(); @@ -745,9 +806,13 @@ async function runWorkflow(page: Page, testCase: TestCase) { }); await test.step('TpaSubmitPage >> TPA Submit', async () => { - // TODO: Validations await tpaSubmitPage.validateURL(tpaSubmitPage.issPageValue); + //await tpaSubmitPage.validateRecalAlert(); + if (!isUnverifiedPolicyAfterVehicleLookup) { + await tpaSubmitPage.validateDeductible(claimDetails!); + } else { await tpaSubmitPage.nextPage(); + } }); await test.step('TpaConfirmationPage >> TPA Confirmation', async () => { @@ -756,43 +821,42 @@ async function runWorkflow(page: Page, testCase: TestCase) { return; }); return; - } - } - - await test.step('ServiceLocationPage >> Select service location', async () => { - await serviceLocationPage.validateURL(serviceLocationPage.issPageValue); - await serviceLocationPage.selectLocation(appointmentDetails!); - if (hasMilitaryWarning) { - await expect.soft(serviceLocationPage.militaryWarningMessage).toBeVisible(); - } - await serviceLocationPage.nextPage(); - }); + }} await test.step('SchedulePage >> Select day and time', async () => { await schedulePage.validateURL(schedulePage.issPageValue); - customerDetails!.apptDate = await schedulePage.scheduleFirstAppointment(appointmentDetails!.serviceLocation); - }); - await test.step('ContactDetailsPage >> Validate contact details', async () => { - const expectedContactDetails: Partial = { - firstName: customerDetails!.firstName, - lastName: customerDetails!.lastName, - email: customerDetails!.email, - phoneNumber: customerDetails!.phoneNumber - }; - await contactDetailsPage.validateURL(contactDetailsPage.issPageValue); - const actualContactDetails = await contactDetailsPage.getContactDetails(); - expect.soft(actualContactDetails).toEqual(expectedContactDetails); - - await contactDetailsPage.fillNotes(customerDetails!.notes); - - if (isPriceServiceErrorBailout) { - forceAPIError(page, '/price/api/v1/price/combined-quote'); + if (appointmentDetails?.serviceLocation === ServiceLocation.Mobile) { + await schedulePage.scheduleMobile(appointmentDetails); } - await contactDetailsPage.nextPage(); + if (appointmentDetails?.serviceLocation === ServiceLocation.InShop || appointmentDetails?.serviceLocation === ServiceLocation.DropOff) { + await schedulePage.scheduleInShop(appointmentDetails); + } }); + + await test.step('ServicePackagesPage >> Choose service package', async () => { + await servicePackagesPage.validateURL(servicePackagesPage.issPageValue); + await servicePackagesPage.selectServicePackage(servicePackage!); + }); + + if (appointmentDetails?.serviceLocation === ServiceLocation.Mobile) { + await test.step('ContactDetailsPage >> Validate contact details', async () => { + await contactDetailsPage.validateURL(contactDetailsPage.issPageValue); + + + await contactDetailsPage.fillContactDetails(customerDetails!); + //await contactDetailsPage.validateAlertsAreVisible(); + //await contactDetailsPage.fillNotes(customerDetails!.notes!); + + await contactDetailsPage.nextPage(); + }); + /* if (isPriceServiceErrorBailout) { + forceAPIError(page, '/price/api/v1/price/combined-quote'); + }*/ + } + if (isPriceServiceErrorBailout) { await test.step('BailoutPage >> Price Service Error Bailout', async () => { await bailoutPage.validateURL(bailoutPage.issPageValue); @@ -801,22 +865,29 @@ async function runWorkflow(page: Page, testCase: TestCase) { return; } - await test.step('ServicePackagesPage >> Choose service package', async () => { - await servicePackagesPage.validateURL(servicePackagesPage.issPageValue); - customerDetails!.packagePrice = await servicePackagesPage.selectServicePackage(servicePackage!); - await servicePackagesPage.nextPage(); - }); - if (isPolicyFound && (isUseVehicleOnPolicy ?? true) && claimDetails!.policyDeductible > 0) { await test.step('PaymentMethodPage >> Execute Payment', async () => { await paymentMethodPage.validateURL(paymentMethodPage.issPageValue); - await paymentMethodPage.executePayment(paymentDetails!); + await paymentMethodPage.executePayment(paymentDetails!, claimDetails!, servicePackage!); await paymentMethodPage.nextPage(); + }); } else { await test.step('PaymentMethodPage >> Skip to Order Confirmation', async () => { await paymentMethodPage.validateURL(paymentMethodPage.issPageValue); - await paymentMethodPage.nextPage(); + + if (isPolicyFound && (isUseVehicleOnPolicy ?? true) && claimDetails!.policyDeductible === 0) { + await paymentMethodPage.submitOrderWithoutPIA(); + } + + if (!isPolicyFound) { + await paymentMethodPage.submitOrderWithoutPIA(); + } + + if (isPolicyFound && testCase.testData.isUnverifiedPolicyAfterVehicleLookup === true) { + await paymentMethodPage.submitOrderWithoutPIA(); + } + }); }