Clean up validations for confirmation page
This commit is contained in:
parent
68d914dd0e
commit
e44ca49c8c
1 changed files with 34 additions and 37 deletions
|
|
@ -13,7 +13,7 @@ export class OrderConfirmationPage extends BasePage {
|
||||||
|
|
||||||
readonly serviceText: Locator;
|
readonly serviceText: Locator;
|
||||||
readonly workOrderNumberText: Locator;
|
readonly workOrderNumberText: Locator;
|
||||||
readonly emailText: Locator;
|
readonly confirmationText: Locator;
|
||||||
readonly appointmentTypeText: Locator;
|
readonly appointmentTypeText: Locator;
|
||||||
readonly apptDetailsText: Locator;
|
readonly apptDetailsText: Locator;
|
||||||
readonly deductibleText: Locator;
|
readonly deductibleText: Locator;
|
||||||
|
|
@ -21,7 +21,7 @@ export class OrderConfirmationPage extends BasePage {
|
||||||
readonly totalAmountDueText: Locator;
|
readonly totalAmountDueText: Locator;
|
||||||
readonly amountPaidText: Locator;
|
readonly amountPaidText: Locator;
|
||||||
readonly finalAmountDue: Locator;
|
readonly finalAmountDue: Locator;
|
||||||
readonly cartServicePackageText: Locator;
|
readonly cartLineItemsText: Locator;
|
||||||
readonly unverifiedCoverageDeductibleText: Locator;
|
readonly unverifiedCoverageDeductibleText: Locator;
|
||||||
|
|
||||||
issPageValue = 'order-confirmation';
|
issPageValue = 'order-confirmation';
|
||||||
|
|
@ -33,7 +33,7 @@ export class OrderConfirmationPage extends BasePage {
|
||||||
this.successCheckmark = this.page.locator('img[src*="-checkmark.svg"]');
|
this.successCheckmark = this.page.locator('img[src*="-checkmark.svg"]');
|
||||||
this.successHeader = this.page.locator('[class="header-text"]');
|
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.serviceText = this.page.locator('[class="service-description confirmation-section"]');
|
||||||
this.workOrderNumberText = this.page.locator('[class="work-order-description"]');
|
this.workOrderNumberText = this.page.locator('[class="work-order-description"]');
|
||||||
this.appointmentTypeText = this.page.locator('[class="appointment-title"]');
|
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.totalAmountDueText = this.page.locator('#total-value');
|
||||||
this.amountPaidText = this.page.locator('#amount-paid-value');
|
this.amountPaidText = this.page.locator('#amount-paid-value');
|
||||||
this.finalAmountDue = this.page.locator('#bottom-amount-due-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' });
|
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,
|
const { vehicleDetails, customerDetails, servicePackage, isItac,
|
||||||
isNoComp, isPolicyFound, claimDetails, paymentDetails, isUseVehicleOnPolicy } = testData;
|
isNoComp, isPolicyFound, claimDetails, paymentDetails, isUseVehicleOnPolicy } = testData;
|
||||||
|
|
||||||
await expect.soft(this.successHeader).toBeVisible();
|
|
||||||
await this.serviceText.waitFor({ state: "visible" });
|
|
||||||
await this.logOrderNumber();
|
|
||||||
|
|
||||||
// Grab text
|
// Grab text
|
||||||
const serviceTextValue = await this.serviceText.textContent();
|
const serviceTextValue = await this.serviceText.textContent();
|
||||||
const apptDetailsValue = await this.apptDetailsText.textContent();
|
const apptDetailsValue = await this.apptDetailsText.textContent();
|
||||||
const appointmentTypeValue = await this.appointmentTypeText.textContent();
|
const appointmentTypeValue = await this.appointmentTypeText.textContent();
|
||||||
|
|
||||||
// Validate header for appointment details matches inshop or mobile
|
|
||||||
await this.validateAppointmentTypeHeader();
|
|
||||||
|
|
||||||
// Derived conditions
|
// Derived conditions
|
||||||
const isItacOrNoComp = !!(isItac || isNoComp);
|
const isItacOrNoComp = !!(isItac || isNoComp);
|
||||||
const isUnverified = !isPolicyFound;
|
const isUnverified = !isPolicyFound;
|
||||||
|
const isUnverifiedPolicyAfterVehicleLookup = testData.isUnverifiedPolicyAfterVehicleLookup === true;
|
||||||
const hasPremiumOrStandard =
|
const hasPremiumOrStandard =
|
||||||
claimDetails!.policyDeductible >= 0 &&
|
claimDetails!.policyDeductible >= 0 &&
|
||||||
(servicePackage === ServicePackage.Premium || servicePackage === ServicePackage.Standard);
|
(servicePackage === ServicePackage.Premium || servicePackage === ServicePackage.Standard);
|
||||||
|
|
@ -86,34 +82,36 @@ export class OrderConfirmationPage extends BasePage {
|
||||||
condition ? await locator.textContent() : null;
|
condition ? await locator.textContent() : null;
|
||||||
|
|
||||||
// Grab text content for elements that are expected on-screen
|
// 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 deductibleTextValue = await textIf(!isItacOrNoComp, this.deductibleText);
|
||||||
const subtotalTextValue = await textIf(hasPremiumOrStandard || isItacOrNoComp, this.subtotalText);
|
const subtotalTextValue = await textIf((hasPremiumOrStandard || isItacOrNoComp || !isUnverified) && !isUnverifiedPolicyAfterVehicleLookup, this.subtotalText);
|
||||||
const totalAmountDueValue = await textIf((hasPremiumOrStandard && !payAtService) || (isItacOrNoComp && !payAtService), this.totalAmountDueText);
|
const totalAmountDueValue = await textIf(((hasPremiumOrStandard && !payAtService) || (isItacOrNoComp && !payAtService) || !isUnverified) && !isUnverifiedPolicyAfterVehicleLookup, this.totalAmountDueText);
|
||||||
const amountPaidTextValue = await textIf((hasPremiumOrStandard && !payAtService) || (isItacOrNoComp && !payAtService), this.totalAmountDueText);
|
const amountPaidTextValue = await textIf(((hasPremiumOrStandard && !payAtService) || (isItacOrNoComp && !payAtService) || !isUnverified) && !isUnverifiedPolicyAfterVehicleLookup, this.totalAmountDueText);
|
||||||
const finalAmountDueValue = await textIf(hasPremiumOrStandard || isItacOrNoComp || isUnverified, this.finalAmountDue);
|
const finalAmountDueValue = await textIf(hasPremiumOrStandard || isItacOrNoComp || isUnverified || isUnverifiedPolicyAfterVehicleLookup, this.finalAmountDue);
|
||||||
|
const confirmationTextValue = await this.confirmationText.textContent();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// General Validations
|
// 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(serviceTextValue).toContain(`${vehicleDetails!.year} ${vehicleDetails!.make} ${vehicleDetails!.model}`);
|
||||||
//expect.soft(apptDateValue).toContain(customerDetails!.apptDate);
|
|
||||||
//expect.soft(emailTextValue).toContain(customerDetails!.email);
|
|
||||||
|
|
||||||
// Service package validations
|
// Validate order number and appointment type header
|
||||||
/* if ((servicePackage === ServicePackage.Premium && testData.isReplace === true) || (servicePackage === ServicePackage.Standard && testData.isReplace === true)) {
|
await this.validateOrderNumber();
|
||||||
expect.soft(servicePackageValue).toContain('Front advanced beam blades');
|
await this.validateAppointmentTypeHeader();
|
||||||
} else if (servicePackage === ServicePackage.Premium) {
|
|
||||||
expect.soft(servicePackageValue).toContain('Safelite Rain Repellent Treatment');
|
// Validate line items
|
||||||
} else {
|
if (servicePackage === ServicePackage.Premium) {
|
||||||
expect.soft(Number.parseFloat(deductibleTextValue!.split('$')[1].replaceAll(',', ''))).toEqual(claimDetails!.policyDeductible);
|
expect.soft(lineItemsValue).toContain('Front advanced beam blades');
|
||||||
} commenting out needs reworked for ITAC/no comp flows*/
|
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))) {
|
if (isPolicyFound && (claimDetails!.policyDeductible === 0 && (servicePackage === ServicePackage.GlassOnly))) {
|
||||||
const zeroDeductibleText = await this.deductibleText.textContent();
|
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;
|
const deductibleAmt = deductibleTextValue ? Number.parseFloat(deductibleTextValue.split('$')[1].replaceAll(',', '')) : 0;
|
||||||
expect.soft(deductibleAmt).toEqual(claimDetails!.policyDeductible);
|
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
|
// Extract numbers
|
||||||
const deductibleAmt = deductibleTextValue ? Number.parseFloat(deductibleTextValue.split('$')[1].replaceAll(',', '')) : null;
|
const deductibleAmt = deductibleTextValue ? Number.parseFloat(deductibleTextValue.split('$')[1].replaceAll(',', '')) : null;
|
||||||
|
|
||||||
const subtotalAmt = subtotalTextValue ? Number.parseFloat(subtotalTextValue!.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 totalAmountDueAmt = Number.parseFloat(totalAmountDueValue!.split('$')[1].replaceAll(',', ''));
|
||||||
const finalAmountDueAmt = finalAmountDueValue ? Number.parseFloat(finalAmountDueValue!.split('$')[1].replaceAll(',', '')) : null;
|
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 sessionStorage = JSON.parse(await this.page.evaluate('sessionStorage.getItem(\'submittedOrder\')'));
|
||||||
const workOrderNumber = sessionStorage.workOrderNumber;
|
const workOrderNumber = sessionStorage.workOrderNumber;
|
||||||
await test.step(`SessionStorage Work Order Number:${workOrderNumber}`, async () => {
|
const workOrderNumberValue = await this.workOrderNumberText.textContent();
|
||||||
console.log(`SessionStorage Work Order Number:${workOrderNumber}`);
|
expect.soft(workOrderNumberValue).toEqual(workOrderNumber);
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async validateAppointmentTypeHeader() {
|
async validateAppointmentTypeHeader() {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue