diff --git a/playwright-tests/pages/OrderConfirmationPage.ts b/playwright-tests/pages/OrderConfirmationPage.ts index 9a776587..40f5a29f 100644 --- a/playwright-tests/pages/OrderConfirmationPage.ts +++ b/playwright-tests/pages/OrderConfirmationPage.ts @@ -13,7 +13,7 @@ export class OrderConfirmationPage extends BasePage { readonly serviceText: Locator; readonly workOrderNumberText: Locator; - readonly emailText: Locator; + readonly confirmationText: Locator; readonly appointmentTypeText: Locator; readonly apptDetailsText: Locator; readonly deductibleText: Locator; @@ -21,7 +21,7 @@ export class OrderConfirmationPage extends BasePage { readonly totalAmountDueText: Locator; readonly amountPaidText: Locator; readonly finalAmountDue: Locator; - readonly cartServicePackageText: Locator; + readonly cartLineItemsText: Locator; readonly unverifiedCoverageDeductibleText: Locator; issPageValue = 'order-confirmation'; @@ -33,7 +33,7 @@ export class OrderConfirmationPage extends BasePage { this.successCheckmark = this.page.locator('img[src*="-checkmark.svg"]'); this.successHeader = this.page.locator('[class="header-text"]'); - this.emailText = this.page.locator('[class="subheader-text"]', { hasText: 'Your appointment is on Safelite\'s schedule and your confirmation email is on the way.' }); + this.confirmationText = this.page.locator('[class="subheader-text"]', { hasText: 'Your appointment is on Safelite\'s schedule and your confirmation email is on the way.' }); this.serviceText = this.page.locator('[class="service-description confirmation-section"]'); this.workOrderNumberText = this.page.locator('[class="work-order-description"]'); this.appointmentTypeText = this.page.locator('[class="appointment-title"]'); @@ -45,7 +45,7 @@ export class OrderConfirmationPage extends BasePage { this.totalAmountDueText = this.page.locator('#total-value'); this.amountPaidText = this.page.locator('#amount-paid-value'); this.finalAmountDue = this.page.locator('#bottom-amount-due-value'); - this.cartServicePackageText = this.page.locator('.cart-item-list'); + this.cartLineItemsText = this.page.locator('.cart-item-list'); this.unverifiedCoverageDeductibleText = this.page.locator('span#deductible-value', { hasText: 'Verifying coverage' }); } @@ -54,21 +54,17 @@ export class OrderConfirmationPage extends BasePage { const { vehicleDetails, customerDetails, servicePackage, isItac, isNoComp, isPolicyFound, claimDetails, paymentDetails, isUseVehicleOnPolicy } = testData; - await expect.soft(this.successHeader).toBeVisible(); - await this.serviceText.waitFor({ state: "visible" }); - await this.logOrderNumber(); // Grab text const serviceTextValue = await this.serviceText.textContent(); const apptDetailsValue = await this.apptDetailsText.textContent(); const appointmentTypeValue = await this.appointmentTypeText.textContent(); - // Validate header for appointment details matches inshop or mobile - await this.validateAppointmentTypeHeader(); // Derived conditions const isItacOrNoComp = !!(isItac || isNoComp); const isUnverified = !isPolicyFound; + const isUnverifiedPolicyAfterVehicleLookup = testData.isUnverifiedPolicyAfterVehicleLookup === true; const hasPremiumOrStandard = claimDetails!.policyDeductible >= 0 && (servicePackage === ServicePackage.Premium || servicePackage === ServicePackage.Standard); @@ -86,34 +82,36 @@ export class OrderConfirmationPage extends BasePage { condition ? await locator.textContent() : null; // Grab text content for elements that are expected on-screen - const servicePackageValue = await textIf(hasPremiumOrStandard, this.cartServicePackageText); + const lineItemsValue = await textIf(hasPremiumOrStandard, this.cartLineItemsText); const deductibleTextValue = await textIf(!isItacOrNoComp, this.deductibleText); - const subtotalTextValue = await textIf(hasPremiumOrStandard || isItacOrNoComp, this.subtotalText); - const totalAmountDueValue = await textIf((hasPremiumOrStandard && !payAtService) || (isItacOrNoComp && !payAtService), this.totalAmountDueText); - const amountPaidTextValue = await textIf((hasPremiumOrStandard && !payAtService) || (isItacOrNoComp && !payAtService), this.totalAmountDueText); - const finalAmountDueValue = await textIf(hasPremiumOrStandard || isItacOrNoComp || isUnverified, this.finalAmountDue); + 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 confirmationTextValue = await this.confirmationText.textContent(); + + - // General Validations + expect.soft(this.serviceText).toBeVisible();; + expect.soft(this.successHeader).toBeVisible(); + expect.soft(confirmationTextValue).toContain('Your appointment is on Safelite\'s schedule and your confirmation email is on the way.'); expect.soft(serviceTextValue).toContain(`${vehicleDetails!.year} ${vehicleDetails!.make} ${vehicleDetails!.model}`); - //expect.soft(apptDateValue).toContain(customerDetails!.apptDate); - //expect.soft(emailTextValue).toContain(customerDetails!.email); - // Service package validations - /* if ((servicePackage === ServicePackage.Premium && testData.isReplace === true) || (servicePackage === ServicePackage.Standard && testData.isReplace === true)) { - expect.soft(servicePackageValue).toContain('Front advanced beam blades'); - } else if (servicePackage === ServicePackage.Premium) { - expect.soft(servicePackageValue).toContain('Safelite Rain Repellent Treatment'); - } else { - expect.soft(Number.parseFloat(deductibleTextValue!.split('$')[1].replaceAll(',', ''))).toEqual(claimDetails!.policyDeductible); - } commenting out needs reworked for ITAC/no comp flows*/ + // Validate order number and appointment type header + await this.validateOrderNumber(); + await this.validateAppointmentTypeHeader(); + + // Validate line items + if (servicePackage === ServicePackage.Premium) { + expect.soft(lineItemsValue).toContain('Front advanced beam blades'); + expect.soft(lineItemsValue).toContain('Safelite Rain Repellent Treatment'); + } else { + if (servicePackage === ServicePackage.Standard) { + expect.soft(lineItemsValue).toContain('Front advanced beam blades'); + } + } - // Price validations - /*if (servicePackage === ServicePackage.GlassOnly) { - expect.soft(servicePackageAmt).toEqual(0); - } else { - expect.soft(servicePackageAmt).toBeGreaterThan(0); - }*/ if (isPolicyFound && (claimDetails!.policyDeductible === 0 && (servicePackage === ServicePackage.GlassOnly))) { const zeroDeductibleText = await this.deductibleText.textContent(); @@ -123,12 +121,12 @@ export class OrderConfirmationPage extends BasePage { 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) && (finalAmountDueValue !== null && subtotalTextValue !== null))) { + } 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; - //subtotalTextValue?.replaceAll(',', '') + //const totalAmountDueAmt = Number.parseFloat(totalAmountDueValue!.split('$')[1].replaceAll(',', '')); const finalAmountDueAmt = finalAmountDueValue ? Number.parseFloat(finalAmountDueValue!.split('$')[1].replaceAll(',', '')) : null; @@ -158,12 +156,11 @@ export class OrderConfirmationPage extends BasePage { } } - async logOrderNumber() { + async validateOrderNumber() { const sessionStorage = JSON.parse(await this.page.evaluate('sessionStorage.getItem(\'submittedOrder\')')); const workOrderNumber = sessionStorage.workOrderNumber; - await test.step(`SessionStorage Work Order Number:${workOrderNumber}`, async () => { - console.log(`SessionStorage Work Order Number:${workOrderNumber}`); - }); + const workOrderNumberValue = await this.workOrderNumberText.textContent(); + expect.soft(workOrderNumberValue).toEqual(workOrderNumber); } async validateAppointmentTypeHeader() {