From 9143df10e4b4f6203784c0f0f38bd8837e2c6c7a Mon Sep 17 00:00:00 2001 From: kpatel8hs4io <31411746+kpatel8hs4io@users.noreply.github.com> Date: Fri, 25 Apr 2025 12:09:21 -0400 Subject: [PATCH] few minor changes. --- .../pages/OrderConfirmationPage.ts | 47 ++++++++++++++++--- playwright-tests/pages/PaymentMethodPage.ts | 7 ++- playwright-tests/pages/SchedulePage.ts | 5 +- 3 files changed, 49 insertions(+), 10 deletions(-) diff --git a/playwright-tests/pages/OrderConfirmationPage.ts b/playwright-tests/pages/OrderConfirmationPage.ts index af05c132d..1c6158c68 100644 --- a/playwright-tests/pages/OrderConfirmationPage.ts +++ b/playwright-tests/pages/OrderConfirmationPage.ts @@ -2,7 +2,7 @@ import { expect, type Locator, type Page } from '@playwright/test'; import { BasePage } from './BasePage'; import { test } from '@business-logic/types/Test'; import { ICustomerDetails, IVehicleDetails } from '@business-logic/types/CustomerDetails'; -import { ServicePackage, PaymentType, PaymentMethod } from '@business-logic/types/Enums'; +import { ServicePackage, PaymentType, PaymentMethod, AppointmentType } from '@business-logic/types/Enums'; import { ITestData } from '@business-logic/types/ITestData'; import { step } from '@business-logic/types/Step'; @@ -19,6 +19,7 @@ export class OrderConfirmationPage extends BasePage { readonly cartServicePackageText: Locator; readonly winshieldWiper: Locator; readonly rainDefense: Locator; + readonly appointmentSummarySection: Locator; url = process.env['BASE_URL']! + '/fmg/?fmgPage=confirmation'; @@ -36,6 +37,7 @@ export class OrderConfirmationPage extends BasePage { this.subtotalText = this.page.locator('.sub-total'); this.finalAmountDue = this.page.locator('div.amount-due'); this.cartServicePackageText = this.cartServicePackageText = this.page.locator('.cart-panel'); + this.appointmentSummarySection = this.page.locator('.main .scheduleText, .main .add-to-calendar-text, .main .appointment-text, .main .duration-text-block'); // this.validateURL(this.url); } @@ -44,10 +46,10 @@ export class OrderConfirmationPage extends BasePage { const { vehicleDetails, customerDetails, servicePackage, promoCode, isPolicyFound, claimDetails, paymentDetails, isUseVehicleOnPolicy, paymentMethod } = testData; await this.serviceText.waitFor({ state: "visible" }); + + expect.soft((await this.getActualAppointmentSummary()).map(item => item.toLowerCase())).toEqual((await this.getExpectedAppointmentSummary(testData)).map(item => item.toLowerCase())); // Grab text - const serviceTextValue = await this.serviceText.textContent(); - const apptDateValue = await this.apptDateText.textContent(); const emailTextValue = await this.emailText.textContent(); const servicePackageValue = await this.cartServicePackageText.textContent(); const amountDueValue = await this.amountDueText.textContent(); @@ -59,9 +61,6 @@ export class OrderConfirmationPage extends BasePage { const servicePackageAmt = Number.parseFloat(servicePackageValue!.split('$')[1].replaceAll(',', '')); // General Validations - expect.soft(serviceTextValue).toContain(`${vehicleDetails!.year} ${vehicleDetails!.make} ${vehicleDetails!.model}`); - const formattedExpectedAppointmentDate = await this.getFormattedAppointmentDate(customerDetails!.apptDate!); - expect.soft(apptDateValue).toContain(formattedExpectedAppointmentDate); expect.soft(emailTextValue).toContain(customerDetails!.email); // Service package validations @@ -141,6 +140,42 @@ export class OrderConfirmationPage extends BasePage { return sessionStorage.order.workOrderNumber; } + async getActualAppointmentSummary(): Promise { + let appointmentSummary: string[] = []; + for (let element of await this.appointmentSummarySection.all()){ + let text = (await element.textContent() || "").replaceAll(/\u00A0| /g, ' '); + appointmentSummary.push(text.trim()); + } + return appointmentSummary; + } + + async getExpectedAppointmentSummary(testData: Partial): Promise { + const { appointmentDetails, customerDetails, vehicleDetails } = testData; + let appointmentSummary: string[] = []; + + // Format the expected appointment date + const formattedExpectedAppointmentDate = await this.getFormattedAppointmentDate(customerDetails!.apptDate!); + appointmentSummary.push( + appointmentDetails?.serviceLocation == AppointmentType.Mobile + ? formattedExpectedAppointmentDate + `${customerDetails!.apptTime?.replace("arriving between", "Between").replaceAll(":00", "")}` + : appointmentDetails?.serviceLocation == AppointmentType.InShop + ? formattedExpectedAppointmentDate + `${customerDetails!.apptTime}` + : formattedExpectedAppointmentDate + "Drop off before 9:30 AM" + ); + appointmentSummary.push("Add to calendar"); + appointmentSummary.push( + appointmentDetails?.serviceLocation == AppointmentType.Mobile + ? appointmentDetails?.serviceAddress + ? ("We're coming to you at" + appointmentDetails.serviceAddress.street + ", " + appointmentDetails.serviceAddress.city + ", " + appointmentDetails.serviceAddress.state + " " + appointmentDetails.serviceAddress.postalCode + "to service your " + `${vehicleDetails!.year} ${vehicleDetails!.make} ${vehicleDetails!.model}`) + : "" + : appointmentDetails?.shopAddress + ? ("You're going to a Safelite shop at" + appointmentDetails.shopAddress + "to service your " + `${vehicleDetails!.year} ${vehicleDetails!.make} ${vehicleDetails!.model}`) + : ""); + appointmentSummary.push("Duration: " + customerDetails!.apptDuration!); + + return appointmentSummary; + } + @step("OrderConfirmationPage >> Validate order") async verifyOrderConfirmationPage(testData: Partial) { await this.validateOrderConfirmationPage(testData); diff --git a/playwright-tests/pages/PaymentMethodPage.ts b/playwright-tests/pages/PaymentMethodPage.ts index 7971cef59..92d0da651 100644 --- a/playwright-tests/pages/PaymentMethodPage.ts +++ b/playwright-tests/pages/PaymentMethodPage.ts @@ -350,8 +350,11 @@ l hasNonWindshieldGlass = localStorage.order.lineItems.glassParts.find((item: any) => item.partType !== "WINDSHIELD") ? true : false; } let isCaliforniaState = localStorage.order.serviceLocation.state as string == 'CA' ? true : false; - let recalRequired = !isRepair && (isInsurance || isCaliforniaState) && - localStorage.order.lineItems.glassParts.find((item: any) => item["requiresRecalibration"].value === true) ? true : false; + let hasRecalPart: boolean = false; + if (!isRepair) { + hasRecalPart = localStorage.order.lineItems.glassParts.find((item: any) => item.requiresRecalibration === true) ? true : false; + } + let recalRequired = !isRepair && (isInsurance || isCaliforniaState) && hasRecalPart let stringForRepair: string[] = ["Expert windshield repair", "Exclusive resin sealant", "Nationwide lifetime guarantee"]; let stringIfRecal = isRepair ? "" diff --git a/playwright-tests/pages/SchedulePage.ts b/playwright-tests/pages/SchedulePage.ts index dd81a4f94..5daa3060e 100644 --- a/playwright-tests/pages/SchedulePage.ts +++ b/playwright-tests/pages/SchedulePage.ts @@ -51,8 +51,9 @@ export class SchedulePage extends BasePage { while (!(await this.firstAvailableDate.isVisible())) { await this.viewMoreDatesLink.click(); } - await this.firstAvailableDate.click(); - customerDetails.apptDate = `${await this.firstAvailableDate.getAttribute("id")}` + await this.firstAvailableDate.click().then(async () => { + customerDetails.apptDate = `${await this.firstAvailableDate.getAttribute("id")}` + }); // const timeSlots = this.timeSlots; const timeSlotCount = await this.timeSlots.count();