Update locators and logic to validate cart behavior for deductible scenarios
This commit is contained in:
parent
531c5c7cd3
commit
58b497fcc4
1 changed files with 51 additions and 29 deletions
|
|
@ -3,38 +3,56 @@ import { BasePage } from './BasePage';
|
||||||
import { ICustomerDetails, IVehicleDetails } from '@business-logic/types/CustomerDetails';
|
import { ICustomerDetails, IVehicleDetails } from '@business-logic/types/CustomerDetails';
|
||||||
import { PaymentType, ServicePackage } from '@business-logic/types/Enums';
|
import { PaymentType, ServicePackage } from '@business-logic/types/Enums';
|
||||||
import { ITestData } from '@business-logic/types/ITestData';
|
import { ITestData } from '@business-logic/types/ITestData';
|
||||||
|
import { log } from 'console';
|
||||||
|
|
||||||
export class OrderConfirmationPage extends BasePage {
|
export class OrderConfirmationPage extends BasePage {
|
||||||
readonly page: Page;
|
readonly page: Page;
|
||||||
|
|
||||||
|
readonly successCheckmark: Locator;
|
||||||
|
readonly successHeader: Locator;
|
||||||
|
|
||||||
readonly serviceText: Locator;
|
readonly serviceText: Locator;
|
||||||
|
readonly workOrderNumberText: Locator;
|
||||||
readonly emailText: Locator;
|
readonly emailText: Locator;
|
||||||
|
|
||||||
readonly apptDateText: Locator;
|
readonly apptDateText: Locator;
|
||||||
readonly amountDueText: Locator;
|
//readonly amountDueText: Locator;
|
||||||
readonly viewCartButton: Locator;
|
|
||||||
readonly deductibleText: Locator;
|
readonly deductibleText: Locator;
|
||||||
readonly subtotalText: Locator;
|
readonly subtotalText: Locator;
|
||||||
readonly finalAmountDue: Locator;
|
readonly finalAmountDue: Locator;
|
||||||
readonly cartServicePackageText: Locator;
|
readonly cartServicePackageText: Locator;
|
||||||
|
readonly VerifiyingCoverageDeductibleText: Locator;
|
||||||
|
|
||||||
issPageValue = 'order-confirmation';
|
issPageValue = 'order-confirmation';
|
||||||
|
|
||||||
constructor(page: Page) {
|
constructor(page: Page) {
|
||||||
super(page);
|
super(page);
|
||||||
this.page = page;
|
this.page = page;
|
||||||
this.serviceText = this.page.locator('[class="appointment-text text-center lh-base"]');
|
|
||||||
this.emailText = this.page.locator('[class="email-confirmation-text"]');
|
this.successCheckmark = this.page.locator('img[src*="-checkmark.svg"]');
|
||||||
this.apptDateText = this.page.locator('[class="appointment-date-time text-center mt-4"]');
|
this.successHeader = this.page.locator('[class="header-text"]');
|
||||||
this.amountDueText = this.page.getByLabel('expand cart details');
|
|
||||||
this.viewCartButton = this.page.locator('#cart-dropdown-head');
|
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.deductibleText = this.page.locator('#deductible-value');
|
this.serviceText = this.page.locator('[class="service-description confirmation-section"]');
|
||||||
|
this.workOrderNumberText = this.page.locator('[class="work-order-description"]');
|
||||||
|
|
||||||
|
this.apptDateText = this.page.locator('[class="appointment-details confirmation-section"]');
|
||||||
|
|
||||||
|
this.deductibleText = this.page.locator('span#deductible-value, span.deductible-value');
|
||||||
this.subtotalText = this.page.locator("#subtotal-value");
|
this.subtotalText = this.page.locator("#subtotal-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-service-package');
|
this.cartServicePackageText = this.page.locator('.cart-item-list');
|
||||||
|
this.VerifiyingCoverageDeductibleText = this.page.locator('span.price cart-item', { hasText: 'Verifying coverage' });
|
||||||
}
|
}
|
||||||
|
|
||||||
async validateOrderConfirmationPage(testData: Partial<ITestData>) {
|
async validateOrderConfirmationPage(testData: Partial<ITestData>) {
|
||||||
// Destructure data we use
|
// Destructure data we use
|
||||||
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.serviceText.waitFor({ state: "visible" });
|
||||||
await this.logOrderNumber();
|
await this.logOrderNumber();
|
||||||
|
|
||||||
|
|
@ -42,64 +60,68 @@ export class OrderConfirmationPage extends BasePage {
|
||||||
const serviceTextValue = await this.serviceText.textContent();
|
const serviceTextValue = await this.serviceText.textContent();
|
||||||
const apptDateValue = await this.apptDateText.textContent();
|
const apptDateValue = await this.apptDateText.textContent();
|
||||||
const emailTextValue = await this.emailText.textContent();
|
const emailTextValue = await this.emailText.textContent();
|
||||||
const servicePackageValue = await this.cartServicePackageText.textContent();
|
const servicePackageValue = (claimDetails!.policyDeductible >= 0) ? await this.cartServicePackageText.textContent(): null;
|
||||||
const amountDueValue = await this.amountDueText.textContent();
|
//const amountDueValue = await this.amountDueText.textContent();
|
||||||
const deductibleTextValue = (isItac || isNoComp) ? null : await this.deductibleText.textContent();
|
const deductibleTextValue = (isItac || isNoComp) ? null : await this.deductibleText.textContent();
|
||||||
const subtotalTextValue = await this.subtotalText.textContent();
|
const subtotalTextValue = (claimDetails!.policyDeductible >= 0) ? await this.subtotalText.textContent() : null;
|
||||||
const finalAmountDueValue = await this.finalAmountDue.textContent();
|
const finalAmountDueValue = (claimDetails!.policyDeductible >= 0) ? await this.finalAmountDue.textContent() : null;
|
||||||
|
|
||||||
// Extract service package price
|
// Extract service package price
|
||||||
const servicePackageAmt = Number.parseFloat(servicePackageValue!.split('$')[1].replaceAll(',', ''));
|
// const servicePackageAmt = Number.parseFloat(servicePackageValue!.split('$')[1].replaceAll(',', ''));
|
||||||
|
|
||||||
// General Validations
|
// General Validations
|
||||||
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(apptDateValue).toContain(customerDetails!.apptDate);
|
||||||
expect.soft(emailTextValue).toContain(customerDetails!.email);
|
//expect.soft(emailTextValue).toContain(customerDetails!.email);
|
||||||
|
|
||||||
// Service package validations
|
// Service package validations
|
||||||
await expect.soft(this.cartServicePackageText).toContainText(`${servicePackage}`)
|
|
||||||
if ((servicePackage === ServicePackage.Premium && testData.isReplace === true) || servicePackage === ServicePackage.Standard) {
|
if ((servicePackage === ServicePackage.Premium && testData.isReplace === true) || servicePackage === ServicePackage.Standard) {
|
||||||
expect.soft(servicePackageValue).toContain('New wiper blades');
|
expect.soft(servicePackageValue).toContain('Front advanced beam blades');
|
||||||
}
|
}
|
||||||
if (servicePackage === ServicePackage.Premium) {
|
if (servicePackage === ServicePackage.Premium) {
|
||||||
expect.soft(servicePackageValue).toContain('Rain Defense™ treatment');
|
expect.soft(servicePackageValue).toContain('Safelite Rain Repellent Treatment');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Price validations
|
// Price validations
|
||||||
if (servicePackage === ServicePackage.GlassOnly) {
|
/*if (servicePackage === ServicePackage.GlassOnly) {
|
||||||
expect.soft(servicePackageAmt).toEqual(0);
|
expect.soft(servicePackageAmt).toEqual(0);
|
||||||
} else {
|
} else {
|
||||||
expect.soft(servicePackageAmt).toBeGreaterThan(0);
|
expect.soft(servicePackageAmt).toBeGreaterThan(0);
|
||||||
}
|
}*/
|
||||||
|
|
||||||
if (isPolicyFound && (isUseVehicleOnPolicy ?? true)) {
|
if (isPolicyFound && (claimDetails!.policyDeductible === 0 && (servicePackage === ServicePackage.GlassOnly))) {
|
||||||
|
const zeroDeductibleText = await this.deductibleText.textContent();
|
||||||
|
expect.soft(zeroDeductibleText).toEqual('$0.00');
|
||||||
|
} else if (isPolicyFound && (finalAmountDueValue !== null && subtotalTextValue !== null)) {
|
||||||
// Extract numbers
|
// Extract numbers
|
||||||
const amountDueAmt = Number.parseFloat(amountDueValue!.split('$')[1].replaceAll(',', ''));
|
//const amountDueAmt = Number.parseFloat(amountDueValue!.split('$')[1].replaceAll(',', ''));
|
||||||
const deductibleAmt = deductibleTextValue ? Number.parseFloat(deductibleTextValue.split('$')[1].replaceAll(',', '')) : 0;
|
const deductibleAmt = deductibleTextValue ? Number.parseFloat(deductibleTextValue.split('$')[1].replaceAll(',', '')) : 0;
|
||||||
const subtotalAmt = Number.parseFloat(subtotalTextValue!.split('$')[1].replaceAll(',', ''));
|
const subtotalAmt = Number.parseFloat(subtotalTextValue!.split('$')[1].replaceAll(',', ''));
|
||||||
subtotalTextValue?.replaceAll(',', '')
|
subtotalTextValue?.replaceAll(',', '')
|
||||||
const finalAmountDueAmt = Number.parseFloat(finalAmountDueValue!.split('$')[1].replaceAll(',', ''));
|
const finalAmountDueAmt = Number.parseFloat(finalAmountDueValue!.split('$')[1].replaceAll(',', ''));
|
||||||
|
|
||||||
if (!(isItac || isNoComp)) {
|
if (!(isItac || isNoComp)) {
|
||||||
expect.soft(subtotalAmt).toEqual(claimDetails!.policyDeductible + servicePackageAmt);
|
//expect.soft(subtotalAmt).toEqual(claimDetails!.policyDeductible + servicePackageAmt);
|
||||||
expect.soft(deductibleAmt).toEqual(claimDetails!.policyDeductible);
|
expect.soft(deductibleAmt).toEqual(claimDetails!.policyDeductible);
|
||||||
} else {
|
} else {
|
||||||
expect.soft(subtotalAmt).toBeGreaterThan(0);
|
expect.soft(subtotalAmt).toBeGreaterThan(0);
|
||||||
expect.soft(deductibleAmt).toEqual(0);
|
expect.soft(deductibleAmt).toEqual(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (paymentDetails!.paymentType === PaymentType.PayAtService && (claimDetails!.policyDeductible > 0 || servicePackageAmt > 0)) {
|
if ((paymentDetails!.paymentType === PaymentType.PayAtService) && (claimDetails!.policyDeductible >= 0 && (servicePackage === ServicePackage.Standard || servicePackage === ServicePackage.Premium))) {
|
||||||
// Verify amount due > 0
|
// Verify amount due > 0
|
||||||
expect.soft(amountDueAmt).toBeGreaterThan(0);
|
//expect.soft(amountDueAmt).toBeGreaterThan(0);
|
||||||
expect.soft(finalAmountDueAmt).toBeGreaterThan(0);
|
expect.soft(finalAmountDueAmt).toBeGreaterThan(0);
|
||||||
} else {
|
} else {
|
||||||
// Verify amount due 0
|
// Verify amount due 0
|
||||||
expect.soft(amountDueAmt).toEqual(0);
|
//expect.soft(amountDueAmt).toEqual(0);
|
||||||
expect.soft(finalAmountDueAmt).toEqual(0);
|
expect.soft(finalAmountDueAmt).toEqual(0);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
expect.soft(amountDueValue).toContain('Verifying coverage');
|
// essential flows will have deductible and amount due as "Verifying coverage"
|
||||||
expect.soft(subtotalTextValue).toEqual('Verifying coverage');
|
const verifyingCoverageText = this.VerifiyingCoverageDeductibleText;
|
||||||
|
|
||||||
|
expect.soft(verifyingCoverageText).toContainText('Verifying coverage');
|
||||||
expect.soft(finalAmountDueValue).toEqual('Verifying coverage');
|
expect.soft(finalAmountDueValue).toEqual('Verifying coverage');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue