Updated methods for payment method page validations
This commit is contained in:
parent
736674cdb0
commit
cfda5a92d7
1 changed files with 39 additions and 48 deletions
|
|
@ -1,7 +1,7 @@
|
||||||
import { expect, type Locator, type Page } from '@playwright/test';
|
import { expect, type Locator, type Page } from '@playwright/test';
|
||||||
import { BasePage } from './BasePage';
|
import { BasePage } from './BasePage';
|
||||||
import { IPaymentDetails, Soft, waitUntil } from 'safelite-playwright-core';
|
import { IPaymentDetails, Soft, waitUntil } from 'safelite-playwright-core';
|
||||||
import { AppointmentTimeslot, ServiceLocation, PaymentType, ServicePackage, VehicleDamage } from 'safelite-playwright-core';
|
import { AppointmentTimeslot, ServiceLocation, PaymentType, ServicePackage, VehicleDamage, } from 'safelite-playwright-core';
|
||||||
import { PaymentMethod, ProgressBarPercentages } from 'framework/localTypes/Enums';
|
import { PaymentMethod, ProgressBarPercentages } from 'framework/localTypes/Enums';
|
||||||
import { PaymentPage } from './PaymentPage';
|
import { PaymentPage } from './PaymentPage';
|
||||||
import { AfterpayPage } from './AfterpayPage';
|
import { AfterpayPage } from './AfterpayPage';
|
||||||
|
|
@ -29,11 +29,9 @@ export class PaymentMethodPage extends BasePage {
|
||||||
|
|
||||||
// Payment detail page validation locators
|
// Payment detail page validation locators
|
||||||
readonly reviewTable: Locator;
|
readonly reviewTable: Locator;
|
||||||
readonly vehicleSection: Locator;
|
|
||||||
readonly damageSection: Locator;
|
|
||||||
readonly serviceDetailsSection: Locator;
|
readonly serviceDetailsSection: Locator;
|
||||||
readonly serviceLocationSection: Locator;
|
readonly serviceLocationDateandTimeSection: Locator;
|
||||||
readonly appointmentDateSection: Locator;
|
readonly vehicleDamageLocationsSection: Locator;
|
||||||
readonly contactDetailsSection: Locator;
|
readonly contactDetailsSection: Locator;
|
||||||
readonly cartPanelDetails: Locator;
|
readonly cartPanelDetails: Locator;
|
||||||
readonly subtotalText: Locator;
|
readonly subtotalText: Locator;
|
||||||
|
|
@ -65,11 +63,8 @@ export class PaymentMethodPage extends BasePage {
|
||||||
this.reviewTable = this.page.locator('div.review-table');
|
this.reviewTable = this.page.locator('div.review-table');
|
||||||
|
|
||||||
// Section locators - find by heading text
|
// Section locators - find by heading text
|
||||||
this.vehicleSection = this.page.locator('.review-table').locator('div', { hasText: 'Vehicle' }).first();
|
this.serviceLocationDateandTimeSection = this.page.locator('.review-table').locator('div .service-location');
|
||||||
this.damageSection = this.page.locator('.review-table').locator('div', { hasText: 'Damage' }).first();
|
this.vehicleDamageLocationsSection= this.page.locator('.review-table').locator('div.py-3[damagelocationswidgetname="DamageLocationsWidget"]');
|
||||||
this.serviceDetailsSection = this.page.locator('.review-table').locator('div', { hasText: 'Glass service only' }).first();
|
|
||||||
this.serviceLocationSection = this.page.locator('.review-table').locator('div', { hasText: "We're coming to you" }).first();
|
|
||||||
this.appointmentDateSection = this.page.locator('.review-table').locator('div', { hasText: 'Appointment date + time' }).first();
|
|
||||||
this.contactDetailsSection = this.page.locator('.review-table').locator('div', { hasText: 'Contact details' }).first();
|
this.contactDetailsSection = this.page.locator('.review-table').locator('div', { hasText: 'Contact details' }).first();
|
||||||
|
|
||||||
// Cart panel elements
|
// Cart panel elements
|
||||||
|
|
@ -99,15 +94,12 @@ export class PaymentMethodPage extends BasePage {
|
||||||
);
|
);
|
||||||
|
|
||||||
let expectedAppointmentDetails = new Map<string, string[]>();
|
let expectedAppointmentDetails = new Map<string, string[]>();
|
||||||
expectedAppointmentDetails = await this.getExpectedVehicleDetails(testData, expectedAppointmentDetails);
|
expectedAppointmentDetails = await this.getExpectedServiceLocationDateAndTimeSection(testData, expectedAppointmentDetails);
|
||||||
expectedAppointmentDetails = await this.getExpectedVehicleDamage(testData, expectedAppointmentDetails);
|
expectedAppointmentDetails = await this.getExpectedVehicleDamageLocations(testData, expectedAppointmentDetails);
|
||||||
// expectedAppointmentDetails = await this.expectedServicePackageDetails(testData, expectedAppointmentDetails);
|
expectedAppointmentDetails = await this.getExpectedContactDetails(testData, expectedAppointmentDetails);
|
||||||
expectedAppointmentDetails = await this.getExpectedServiceLocation(testData, expectedAppointmentDetails);
|
expectedAppointmentDetails = await this.getExpectedTextServiceUpdatesOptInOrOut(testData, expectedAppointmentDetails);
|
||||||
expectedAppointmentDetails = await this.getExpectedAppointmentDate(testData, expectedAppointmentDetails);
|
|
||||||
expectedAppointmentDetails = await this.getExpectedCustomerDetails(testData, expectedAppointmentDetails);
|
|
||||||
|
|
||||||
let actualAppointmentDetails = await this.getActualAppointmentDetails();
|
let actualAppointmentDetails = await this.getActualAppointmentDetails();
|
||||||
|
|
||||||
for (const key in expectedAppointmentDetails) {
|
for (const key in expectedAppointmentDetails) {
|
||||||
Soft.expect(actualAppointmentDetails[key]?.map(item => item.toLowerCase()))
|
Soft.expect(actualAppointmentDetails[key]?.map(item => item.toLowerCase()))
|
||||||
.toEqual(expectedAppointmentDetails[key].map(item => item.toLowerCase()));
|
.toEqual(expectedAppointmentDetails[key].map(item => item.toLowerCase()));
|
||||||
|
|
@ -399,55 +391,43 @@ l
|
||||||
return expectedServicePackageDetails;
|
return expectedServicePackageDetails;
|
||||||
}
|
}
|
||||||
|
|
||||||
async getExpectedServiceLocation(testData: Partial<ITestData>, expectedServicePackageDetails: Map<string, string[]>): Promise<any> {
|
async getExpectedServiceLocationDateAndTimeSection(testData: Partial<ITestData>, expectedServicePackageDetails: Map<string, string[]>): Promise<any> {
|
||||||
const { appointmentDetails } = testData;
|
const { customerDetails, appointmentDetails } = testData;
|
||||||
let serviceLocationTitle = appointmentDetails?.serviceLocation == ServiceLocation.Mobile
|
let serviceLocationTitle = appointmentDetails?.serviceLocation == ServiceLocation.Mobile
|
||||||
? "We're coming to you"
|
? "We're coming to you"
|
||||||
: "You're coming to us";
|
: "You're coming to us";
|
||||||
let serviceLocation: string[] = [];
|
let serviceLocation: string[] = [];
|
||||||
|
let serviceLocationText = appointmentDetails?.serviceLocation == ServiceLocation.Mobile
|
||||||
serviceLocation.push(
|
|
||||||
appointmentDetails?.serviceLocation == ServiceLocation.Mobile
|
|
||||||
? appointmentDetails?.serviceAddress
|
? appointmentDetails?.serviceAddress
|
||||||
? appointmentDetails.serviceAddress.street + ", " + appointmentDetails.serviceAddress.city + ", " + appointmentDetails.serviceAddress.state + " " + appointmentDetails.serviceAddress.postalCode
|
? appointmentDetails.serviceAddress.street + ", " + appointmentDetails.serviceAddress.city + ", " + appointmentDetails.serviceAddress.state + " " + appointmentDetails.serviceAddress.postalCode
|
||||||
: ""
|
: ""
|
||||||
: appointmentDetails?.shopAddress
|
: appointmentDetails?.shopAddress
|
||||||
? appointmentDetails.shopAddress
|
? appointmentDetails.shopAddress
|
||||||
: ""
|
: "";
|
||||||
|
serviceLocationText += " on "
|
||||||
|
serviceLocationText += customerDetails?.apptDate ? await this.getFormattedAppointmentDate(customerDetails.apptDate) + " " + customerDetails?.apptTime?.replace("-", "—") : "";
|
||||||
|
serviceLocation.push(
|
||||||
|
serviceLocationText
|
||||||
);
|
);
|
||||||
|
|
||||||
expectedServicePackageDetails[serviceLocationTitle] = serviceLocation;
|
expectedServicePackageDetails[serviceLocationTitle] = serviceLocation;
|
||||||
return expectedServicePackageDetails;
|
return expectedServicePackageDetails;
|
||||||
}
|
}
|
||||||
|
|
||||||
async getExpectedAppointmentDate(testData: Partial<ITestData>, expectedServicePackageDetails: Map<string, string[]>): Promise<any> {
|
async getExpectedVehicleDamageLocations(testData: Partial<ITestData>, expectedServicePackageDetails: Map<string, string[]>): Promise<any> {
|
||||||
const { customerDetails, appointmentDetails } = testData;
|
const { customerDetails } = testData;
|
||||||
let appointmentDateText: string[] = [];
|
let VehicleDamageLocationsText: string[] = [];
|
||||||
const isMobileAppointment = appointmentDetails?.serviceLocation == ServiceLocation.Mobile
|
if (VehicleDamage.WindshieldCrack) {
|
||||||
if (isMobileAppointment) {
|
let VehicleDamageLocationsText: string[] = [];
|
||||||
let localStorage= JSON.parse(await this.page.evaluate('localStorage.getItem(\'vuex\')'));
|
VehicleDamageLocationsText.push("Replace the windshield");
|
||||||
let jobMinMinutes = localStorage.order.schedule.jobMinMinutes as number;
|
};
|
||||||
let jobMaxMinutes = localStorage.order.schedule.jobMaxMinutes as number;
|
|
||||||
|
|
||||||
if (jobMinMinutes < 60) {
|
expectedServicePackageDetails["VehicleDamageLocationsText"] = VehicleDamageLocationsText;
|
||||||
customerDetails!.apptDuration = `${jobMinMinutes} - ${jobMaxMinutes} minutes`;
|
|
||||||
} else {
|
|
||||||
const minHours = Math.floor(jobMinMinutes / 60);
|
|
||||||
const maxHours = Math.floor(jobMaxMinutes / 60);
|
|
||||||
customerDetails!.apptDuration = `${minHours} - ${maxHours} hours`;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
appointmentDateText.push(
|
|
||||||
customerDetails?.apptDate ? await this.getFormattedAppointmentDate(customerDetails.apptDate) + " " + customerDetails?.apptTime?.replace("-", "—") : "",
|
|
||||||
customerDetails?.apptDuration ? "Estimated appointment length: " + customerDetails.apptDuration : ""
|
|
||||||
);
|
|
||||||
|
|
||||||
expectedServicePackageDetails["Appointment Date + Time"] = appointmentDateText;
|
|
||||||
return expectedServicePackageDetails;
|
return expectedServicePackageDetails;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async getExpectedCustomerDetails(testData: Partial<ITestData>, expectedServicePackageDetails: Map<string, string[]>): Promise<any> {
|
async getExpectedContactDetails(testData: Partial<ITestData>, expectedServicePackageDetails: Map<string, string[]>): Promise<any> {
|
||||||
const { customerDetails } = testData;
|
const { customerDetails } = testData;
|
||||||
let customerDetailsText: string[] = [];
|
let customerDetailsText: string[] = [];
|
||||||
|
|
||||||
|
|
@ -455,13 +435,24 @@ l
|
||||||
// customerDetails?.firstName.toUpperCase() + " " + customerDetails?.lastName.toUpperCase(),
|
// customerDetails?.firstName.toUpperCase() + " " + customerDetails?.lastName.toUpperCase(),
|
||||||
customerDetails?.email ? customerDetails?.email.toUpperCase() : "",
|
customerDetails?.email ? customerDetails?.email.toUpperCase() : "",
|
||||||
customerDetails?.phoneNumber ? customerDetails?.phoneNumber : "",
|
customerDetails?.phoneNumber ? customerDetails?.phoneNumber : "",
|
||||||
"Opted out of text message updates"
|
|
||||||
);
|
);
|
||||||
|
|
||||||
expectedServicePackageDetails["Contact details"] = customerDetailsText;
|
expectedServicePackageDetails["Contact details"] = customerDetailsText;
|
||||||
return expectedServicePackageDetails;
|
return expectedServicePackageDetails;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async getExpectedTextServiceUpdatesOptInOrOut(testData: Partial<ITestData>, expectedServicePackageDetails: Map<string, string[]>): Promise<any> {
|
||||||
|
const { customerDetails } = testData;
|
||||||
|
|
||||||
|
let isOptedInForTextMessages = testData.isOptedInForTextMessages ?? false;
|
||||||
|
|
||||||
|
let expectedText = isOptedInForTextMessages ? customerDetails?.phoneNumber : "Not opted in";
|
||||||
|
|
||||||
|
|
||||||
|
expectedServicePackageDetails["We’ll text service updates to"] = expectedText
|
||||||
|
return expectedServicePackageDetails;
|
||||||
|
}
|
||||||
|
|
||||||
async getFormattedAppointmentDate(appointmentDate: string) {
|
async getFormattedAppointmentDate(appointmentDate: string) {
|
||||||
|
|
||||||
// Parse the original date
|
// Parse the original date
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue