few minor changes.
This commit is contained in:
parent
554841a9b9
commit
9143df10e4
3 changed files with 49 additions and 10 deletions
|
|
@ -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<string[]> {
|
||||
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<ITestData>): Promise<string[]> {
|
||||
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<ITestData>) {
|
||||
await this.validateOrderConfirmationPage(testData);
|
||||
|
|
|
|||
|
|
@ -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
|
||||
? ""
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
Loading…
Reference in a new issue