diff --git a/playwright-tests/business-logic/types/Enums.ts b/playwright-tests/business-logic/types/Enums.ts index a2d633dab..58595528f 100644 --- a/playwright-tests/business-logic/types/Enums.ts +++ b/playwright-tests/business-logic/types/Enums.ts @@ -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", diff --git a/playwright-tests/pages/VehicleDamagePage.ts b/playwright-tests/pages/VehicleDamagePage.ts index da83d63fc..bdb8441a6 100644 --- a/playwright-tests/pages/VehicleDamagePage.ts +++ b/playwright-tests/pages/VehicleDamagePage.ts @@ -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 { + 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): Promise { 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(); } } \ No newline at end of file diff --git a/playwright-tests/pages/VehicleSelectionPage.ts b/playwright-tests/pages/VehicleSelectionPage.ts index c2d638d12..8ab577839 100644 --- a/playwright-tests/pages/VehicleSelectionPage.ts +++ b/playwright-tests/pages/VehicleSelectionPage.ts @@ -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.'); } diff --git a/playwright-tests/tests/alert-validation/alert0003_SplitWindshield.ts b/playwright-tests/tests/alert-validation/alert0003_SplitWindshield.ts index f01151b05..82022284b 100644 --- a/playwright-tests/tests/alert-validation/alert0003_SplitWindshield.ts +++ b/playwright-tests/tests/alert-validation/alert0003_SplitWindshield.ts @@ -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 = { @@ -10,11 +10,21 @@ const splitWindshieldData: Partial = { // 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}`,