Update validations for various deductible types

This commit is contained in:
JennyNou 2026-03-10 13:32:35 -04:00
parent ad228f735c
commit 31d2d7d5f5

View file

@ -1,30 +1,44 @@
import { expect, type Locator, type Page } from '@playwright/test';
import { BasePage } from './BasePage';
import { IClaimDetails, ICustomerDetails } from '@business-logic/types/CustomerDetails';
import { defaultTestData, ITestData, VehicleDamage } from 'safelite-playwright-core';
export class CoverageStatementPage extends BasePage {
readonly page: Page;
readonly scheduleOnlineButton: Locator;
readonly cancelMyClaimButton: Locator;
readonly cancelMyClaimConfirm: Locator;
readonly deductibleAmount: Locator;
readonly verfiyingCoverageText: Locator;
readonly continueToScheduleButton: Locator; // For ITAC/NoComp
readonly noDeductibleRepairText: Locator; // For essential flow when there is no deductible and repair is covered
readonly youPayYourDeductibleText: Locator;
readonly verifiedCoverageHeader: Locator; // For essential flow when coverage is verified
readonly headerForITAC: Locator; // For ITAC when coverage is found
readonly headerForNoComp: Locator; // For NoComp when coverage is found
readonly unverifiedCoverageHeader: Locator; // For essential flows when verifying deductible
readonly continueSchedulingButton: Locator; // For ITAC/NoComp
readonly continueButton: Locator; // For essential flows
issPageValue = 'coverage-statement';
constructor(page: Page) {
super(page);
this.page = page;
this.scheduleOnlineButton = this.page.getByText('Continue to schedule online');
this.cancelMyClaimButton = this.page.getByText('Cancel my claim');
this.cancelMyClaimConfirm = this.page.getByText('No, I want to cancel');
this.cancelMyClaimConfirm = this.page.getByRole('link', { name: "No, I want to cancel" }); // seen for ITAC/NoComp flows
this.deductibleAmount = this.page.getByText('$');
this.verfiyingCoverageText = this.page.getByRole('heading', { name: 'Were verifying your coverage' });
this.continueToScheduleButton = page.locator('div[class*="button-content"]', {hasText:'Continue to schedule online'});
this.deductibleAmount = this.page.locator('.cost-underline');
this.noDeductibleRepairText = this.page.getByText('According to your policy, there is no deductible for a repair.'); // no deductible for repair text
this.youPayYourDeductibleText = this.page.getByText('You pay your deductible:'); // no deductible for replacement text
this.verifiedCoverageHeader = this.page.getByRole('heading', { name: 'We have verified your coverage' });
this.unverifiedCoverageHeader = this.page.getByRole('heading', { level: 5, name: "Were verifying your coverage" });
this.headerForITAC = this.page.getByRole('heading', { name: 'Good news! Safelite\'s price is lower than your deductible' });
this.headerForNoComp = this.page.getByRole('heading', { name: 'Looks like your policy doesn\'t include comprehensive coverage.\nSafelite can still get you fixed up and safely back on the road.' });
this.continueSchedulingButton = page.getByRole('button', { name: 'Continue scheduling' }); // continue button for ITAC/NoComp flow
this.continueButton = page.getByRole('button', { name: 'Continue' }); // continue button for essential flow
}
async scheduleOnline(){
await this.scheduleOnlineButton.click();
async scheduleOnline(){
await this.continueSchedulingButton.click();
}
async cancelMyClaim(){
@ -32,11 +46,61 @@ export class CoverageStatementPage extends BasePage {
await this.cancelMyClaimConfirm.click();
}
async validateDeductibleAmount(customer){
await expect(this.deductibleAmount). toContainText(`$${customer.deductibleAmount}`, {timeout: 60000});
async handleRepairWithNoDeductibleFlow() {
if (VehicleDamage.WindshieldOneChip || VehicleDamage.WindshieldTwoChips || VehicleDamage.WindshieldThreeChips) {
await expect(this.verifiedCoverageHeader).toBeVisible();
await expect(this.noDeductibleRepairText).toBeVisible();
}
}
async validateUnverifiedText(){
await expect(this.verfiyingCoverageText).toBeEnabled();
async handleReplacementOrRepairWithNoDeductibleFlow(claimDetails: IClaimDetails, VehicleDamage){
const noDeductibleFlow = claimDetails.policyDeductible === 0;
if (noDeductibleFlow && VehicleDamage === VehicleDamage.WindshieldOneChip || VehicleDamage.WindshieldTwoChips || VehicleDamage.WindshieldThreeChips) {
// await expect(this.noDeductibleRepairText).toBeVisible();
await this.continueButton.click();
} else {
await expect(this.youPayYourDeductibleText).toBeVisible();
await expect(this.deductibleAmount).toContainText(`$0`, {timeout: 60000});
await this.continueButton.click();
}
}
async handleReplacementWithDeductibleFlow(claimDetails: IClaimDetails){
const replaceWithDeductibleFlow = claimDetails.policyDeductible! > 0 && claimDetails.policyDeductible !== 9999;
if (replaceWithDeductibleFlow) {
await expect(this.youPayYourDeductibleText).toBeVisible();
await expect(this.deductibleAmount).toContainText(`$${claimDetails.policyDeductible?.toLocaleString()}`, {timeout: 60000});
await this.continueButton.click();
}
}
async handleUnverifiedFlow(claimDetails: IClaimDetails){
const unVerifiedCustomer = claimDetails.policyDeductible === -1; // if deductible is -1, we treat it as unverified flow
if (unVerifiedCustomer) {
await expect(this.unverifiedCoverageHeader).toBeVisible();
await this.continueButton.click();
}
}
async handleITACFlow(){
await expect(this.headerForITAC).toBeVisible(); // verify ITAC header is visible
await this.continueSchedulingButton.click(); // happy path to scheduling for ITAC
}
async handleNoCompFlow(){
await expect(this.headerForNoComp).toBeVisible(); // verify NoComp header is visible
await this.continueSchedulingButton.click(); // happy path to scheduling for NoComp
}
}
}