diff --git a/playwright-tests/pages/OrderConfirmationPage.ts b/playwright-tests/pages/OrderConfirmationPage.ts index 9c8f22fd..6e957c54 100644 --- a/playwright-tests/pages/OrderConfirmationPage.ts +++ b/playwright-tests/pages/OrderConfirmationPage.ts @@ -62,7 +62,7 @@ export class OrderConfirmationPage extends BasePage { // Derived conditions const isItacOrNoComp = !!(isItac || isNoComp); - const isUnverified = !isPolicyFound; + const isUnverified = !isPolicyFound && claimDetails!.policyDeductible === -1; const isUnverifiedPolicyAfterVehicleLookup = testData.isUnverifiedPolicyAfterVehicleLookup === true; const hasPremiumOrStandard = (claimDetails!.policyDeductible >= 0 || !isPolicyFound) && @@ -84,13 +84,11 @@ export class OrderConfirmationPage extends BasePage { const lineItemsValue = await textIf(hasPremiumOrStandard, this.cartLineItemsText); const deductibleTextValue = await textIf(!isItacOrNoComp, this.deductibleText); const subtotalTextValue = await textIf((hasPremiumOrStandard || isItacOrNoComp) && !isUnverified && !isUnverifiedPolicyAfterVehicleLookup, this.subtotalText); - const totalAmountDueValue = await textIf((hasPremiumOrStandard && !payAtService) || (isItacOrNoComp && !payAtService) && !isUnverified && !isUnverifiedPolicyAfterVehicleLookup, this.totalAmountDueText); - const amountPaidTextValue = await textIf((hasPremiumOrStandard && !payAtService) || (isItacOrNoComp && !payAtService) && !isUnverified && !isUnverifiedPolicyAfterVehicleLookup, this.totalAmountDueText); - const finalAmountDueValue = await textIf(hasPremiumOrStandard || isItacOrNoComp || isUnverified || isUnverifiedPolicyAfterVehicleLookup, this.finalAmountDue); + const totalAmountDueValue = await textIf((hasPremiumOrStandard && !payAtService) && (isItacOrNoComp && !payAtService) && !isUnverified && !isUnverifiedPolicyAfterVehicleLookup, this.totalAmountDueText); + const amountPaidTextValue = await textIf((hasPremiumOrStandard && !payAtService) && (isItacOrNoComp && !payAtService) && !isUnverified && !isUnverifiedPolicyAfterVehicleLookup, this.totalAmountDueText); + const finalAmountDueValue = await textIf((hasPremiumOrStandard && isItacOrNoComp) || (hasPremiumOrStandard && isUnverified), this.finalAmountDue); const confirmationTextValue = await this.confirmationText.textContent(); - - // General Validations expect.soft(this.serviceText).toBeVisible();; expect.soft(this.successHeader).toBeVisible(); @@ -115,15 +113,24 @@ export class OrderConfirmationPage extends BasePage { if (isPolicyFound && (claimDetails!.policyDeductible === 0 && (servicePackage === ServicePackage.GlassOnly))) { const zeroDeductibleText = await this.deductibleText.textContent(); expect.soft(zeroDeductibleText).toEqual('$0.00'); - } else if (isPolicyFound && claimDetails!.policyDeductible > 0 && !(isItac || isNoComp) && servicePackage === ServicePackage.GlassOnly){ + } else if (isPolicyFound && claimDetails!.policyDeductible > 0 && !(isItac || isNoComp) && !isUnverifiedPolicyAfterVehicleLookup && servicePackage === ServicePackage.GlassOnly){ expect.soft(deductibleTextValue).not.toBeNull(); const deductibleAmt = deductibleTextValue ? Number.parseFloat(deductibleTextValue.split('$')[1].replaceAll(',', '')) : 0; expect.soft(deductibleAmt).toEqual(claimDetails!.policyDeductible); - - } else if ((isPolicyFound || isItac || (isNoComp && paymentDetails!.paymentType === PaymentType.PayAtService)) && !isUnverifiedPolicyAfterVehicleLookup && finalAmountDueValue !== null && subtotalTextValue !== null) { + + } else if (isPolicyFound && claimDetails!.policyDeductible > 0 && !(isItac || isNoComp) && !isUnverifiedPolicyAfterVehicleLookup && hasPremiumOrStandard && !payAtService) { + // Policy found, deductible > 0, Standard/Premium package, paid with PIA (not pay-at-service) + expect.soft(deductibleTextValue).not.toBeNull(); + const deductibleAmt = deductibleTextValue ? Number.parseFloat(deductibleTextValue.split('$')[1].replaceAll(',', '')) : 0; + expect.soft(deductibleAmt).toEqual(claimDetails!.policyDeductible); + + const totalAmountDueAmt = totalAmountDueValue ? Number.parseFloat(totalAmountDueValue!.split('$')[1].replaceAll(',', '')) : null; + const amountPaidValue = amountPaidTextValue ? Number.parseFloat(amountPaidTextValue!.split('$')[1].replaceAll(',', '')) : null; + expect.soft(amountPaidValue).toEqual(totalAmountDueAmt); + + } else if ((isPolicyFound && isItac && (isNoComp && paymentDetails!.paymentType === PaymentType.PayAtService)) && !isUnverifiedPolicyAfterVehicleLookup && finalAmountDueValue !== null && subtotalTextValue !== null) { // Extract numbers const deductibleAmt = deductibleTextValue ? Number.parseFloat(deductibleTextValue.split('$')[1].replaceAll(',', '')) : null; - const subtotalAmt = subtotalTextValue ? Number.parseFloat(subtotalTextValue!.split('$')[1].replaceAll(',', '')) : null; @@ -146,13 +153,15 @@ export class OrderConfirmationPage extends BasePage { expect.soft(amountPaidValue).toEqual(totalAmountDueAmt); expect.soft(finalAmountDueAmt).toEqual(0); } + } else if (isUnverified && servicePackage === ServicePackage.GlassOnly) { + expect.soft(deductibleTextValue).toEqual('Verifying coverage'); } else { - // essential flows will have deductible and amount due as "Verifying coverage" - const verifyingCoverageText = this.unverifiedCoverageDeductibleText; - - expect.soft(verifyingCoverageText).toContainText('Verifying coverage'); + if (isUnverified && servicePackage !== ServicePackage.GlassOnly) { + // essential flows will have deductible and amount due as "Verifying coverage"; + expect.soft(deductibleTextValue).toEqual('Verifying coverage'); expect.soft(finalAmountDueValue).toEqual('Verifying coverage'); - } + } + } } async validateOrderNumber() {