Adds split windshield support and alert test

Adds support for split windshield damage selection and validation.
Introduces new vehicle damage types and corresponding UI elements on the vehicle damage page.
Also, adds a new alert message to handle the scenario where both single-piece and split windshield options are selected.
The changes enhance the accuracy of vehicle damage assessment.
This commit is contained in:
maguire-arman 2025-06-19 13:01:56 -04:00
parent e4e49ac529
commit 54a8036a0d
4 changed files with 62 additions and 13 deletions

View file

@ -31,6 +31,9 @@ export enum VehicleDamage {
WindshieldTwoChips = "WINDSHIELD TWO CHIPS",
WindshieldThreeChips = "WINDSHIELD THREE CHIPS",
WindshieldCrack = "WINDSHIELD",
SingleSplitWindshield = "SINGLE WINDSHIELD",
DriverSplitWindshield = "DRIVER SPLIT WINDSHIELD",
PassengerSplitWindshield = "PASSENGER SPLIT WINDSHIELD",
RearWindow = "BACK GLASS",
RearSliding = "SLIDER",
DriverFrontDoor = "DRIVER FRONT DOOR GLASS",

View file

@ -26,9 +26,13 @@ export class VehicleDamagePage extends BasePage {
readonly rearStationaryBttn: Locator;
readonly rearSlidingGlassBttn: Locator;
readonly editVehicleLink: Locator;
readonly singleSplitWindshieldChkBox: Locator;
readonly driverSplitWindshieldChkBox: Locator;
readonly passengerSplitWindshieldChkBox: Locator;
readonly noReplacementAvailableAlert: Locator;
readonly bothReplaceRepairAlert: Locator;
readonly splitWindshieldAlert: Locator;
url = process.env['BASE_URL']! + '/fmg/?fmgPage=vehicle-damage';
constructor(page: Page) {
@ -50,8 +54,12 @@ export class VehicleDamagePage extends BasePage {
this.passengerVentGlassChkBox = this.page.locator('[aria-labelledby="passengerSideOptions"]').locator('[buttonlabel="Vent glass"]');
this.passengerBackDoorChkBox = this.page.locator('[aria-labelledby="passengerSideOptions"]').locator('[buttonlabel="Back door"]');
this.rearWindowChkBox = this.page.locator('[buttonlabel="Rear window"]');
this.singleSplitWindshieldChkBox = this.page.locator('[aria-labelledby="WindshieldReplaceOptions"]').locator('[buttonlabel="Single windshield"]');
this.driverSplitWindshieldChkBox = this.page.locator('[aria-labelledby="WindshieldReplaceOptions"]').locator('[buttonlabel="Split windshield, driver side"]');
this.passengerSplitWindshieldChkBox = this.page.locator('[aria-labelledby="WindshieldReplaceOptions"]').locator('[buttonlabel="Split windshield, passenger side"]');
this.noReplacementAvailableAlert = this.page.locator('.alert-danger.widget-name-NoReplacementAvailableError');
this.bothReplaceRepairAlert = this.page.locator('div.alert-danger.widget-name-HasReplacementConflict');
this.splitWindshieldAlert = this.page.locator('.alert-danger.widget-name-SplitSingleConflict');
this.rearStationaryBttn = this.page.locator('label').filter({ hasText: 'Stationary' });
this.rearSlidingGlassBttn = this.page.locator('label').filter({ hasText: 'Glass with slider' });
this.editVehicleLink = this.page.getByRole('link', { name: 'Edit vehicle' });
@ -76,6 +84,21 @@ export class VehicleDamagePage extends BasePage {
await this.windshieldChkBox.check();
await this.selectCrack();
break;
case VehicleDamage.SingleSplitWindshield:
await this.windshieldChkBox.check();
await this.selectCrack();
await this.singleSplitWindshieldChkBox.check();
break;
case VehicleDamage.DriverSplitWindshield:
await this.windshieldChkBox.check();
await this.selectCrack();
await this.driverSplitWindshieldChkBox.check();
break;
case VehicleDamage.PassengerSplitWindshield:
await this.windshieldChkBox.check();
await this.selectCrack();
await this.passengerSplitWindshieldChkBox.check();
break;
case VehicleDamage.DriverFrontDoor:
await this.sideDoorButton.check();
await this.driverSideButton.check();
@ -164,10 +187,17 @@ export class VehicleDamagePage extends BasePage {
expect(alertMessage).toContain("Service not availableWe're sorry, but we currently offer only repair service for your vehicle type. Need help with next steps? Call us at800-394-0288.")
}
async checkForSplitWindshieldAlertMessage(): Promise<void> {
await expect(this.splitWindshieldAlert).toBeVisible();
const alertMessage = await this.splitWindshieldAlert.textContent();
console.log(`Alert encountered: ${alertMessage}`);
expect(alertMessage).toContain("Single-piece or split?Please select just one windshield option: single-piece or split.")
}
@step('VehicleDamagePage >> Select Damage')
async handleVehicleDamagePage(testData: Partial<ITestData>): Promise<void> {
const {vehicleDamage} = testData;
const {isRepairReplace, isRepairOnly} = testData.alertFlags || {};
const {isRepairReplace, isRepairOnly, isSplitWindshield} = testData.alertFlags || {};
await this.validateProgressBar(ProgressBarPercentages.VehicleDamagePage);
await this.selectDamage(vehicleDamage!);
@ -180,6 +210,10 @@ export class VehicleDamagePage extends BasePage {
await this.checkForRepairOnlyAlertMessage();
throw new TestSuccessAlert('Both assertions are met successfully.');
}
if (isSplitWindshield) {
await this.checkForSplitWindshieldAlertMessage();
throw new TestSuccessAlert('Both assertions are met successfully.');
}
await this.nextPage();
}
}

View file

@ -61,7 +61,8 @@ export class VehicleSelectionPage extends BasePage {
}
// Handle alert conditions for vehicle selection
if (isHeavyTruckVehicleAlert || isSplitWindshield) {
if (isHeavyTruckVehicleAlert) {
await this.continueButton.click();
await this.checkForAlertMessages();
throw new TestSuccessAlert('Both assertions are met successfully.');
}

View file

@ -2,7 +2,7 @@
import { ITestData } from "@business-logic/types/ITestData";
import TestCase from "@business-logic/types/TestCase";
import { VehicleDamage } from "@business-logic/types/Enums";
import { defaultTestData } from "@business-logic/constants/DefaultTestData";
import { defaultTestData, getDefaultTestData } from "@business-logic/constants/DefaultTestData";
// Windshield selected, when vehicle has split windshield (alert) Test Data
const splitWindshieldData: Partial<ITestData> = {
@ -10,11 +10,21 @@ const splitWindshieldData: Partial<ITestData> = {
// Override specific fields with test-specific data
vehicleDamage: [
VehicleDamage.WindshieldOneChip
VehicleDamage.SingleSplitWindshield,
VehicleDamage.DriverSplitWindshield,
VehicleDamage.PassengerSplitWindshield
],
alertFlags: {
isSplitWindshield: true
}
},
customerDetails: {
...getDefaultTestData().customerDetails!,
address: {
...getDefaultTestData().customerDetails!.address,
postalCode: '55414'
}
},
isHeavyTruck: true, // Flag for heavy truck vehicle
};
const vehiclesToTest = [
@ -35,20 +45,21 @@ const vehiclesToTest = [
make: 'Kenworth',
model: 'T600',
style: 'conventional cab'
}
},
];
const splitWindshieldTests: TestCase[] = [];
// Generate test cases for each vehicle
vehiclesToTest.forEach((vehicle, index) => {
const testData = {
...splitWindshieldData,
vehicleDetails: {
...defaultTestData.vehicleDetails!,
...vehicle
}
};
    const testData = {
        ...splitWindshieldData,
        vehicleDetails: {
            ...defaultTestData.vehicleDetails!,
            ...vehicle
        },
    };
const tc = new TestCase({
name: `alert0003_${vehicle.make.toLowerCase()}_${vehicle.model.toLowerCase()} Windshield selected, when vehicle has split windshield - ${vehicle.make} ${vehicle.model} ${vehicle.year}`,